Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build and publish daed docker image with geosite/geoip #19

Merged
merged 7 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build & release
name: Build

on:
push:
Expand All @@ -8,7 +8,6 @@ on:
types: [prereleased]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

jobs:
full-src:
Expand All @@ -18,7 +17,7 @@ jobs:
with:
submodules: 'recursive'

- name: download wing vendor
- name: Download wing vendor
run: |
cd wing && go mod vendor

Expand All @@ -32,7 +31,7 @@ jobs:
shasum -a 256 $FILE >>$DGST
shasum -a 512 $FILE >>$DGST

- name: upload artifact - full source
- name: Upload artifact - full source
uses: actions/upload-artifact@v3
with:
name: daed-full-src.zip
Expand Down Expand Up @@ -62,12 +61,12 @@ jobs:
cache: pnpm
node-version: latest

- name: build
- name: Build
run: |
pnpm install
pnpm build

- name: upload artifact - web
- name: Upload artifact - web
uses: actions/upload-artifact@v3
with:
name: web
Expand All @@ -87,30 +86,26 @@ jobs:
- goos: linux
goarch: arm
goarm: 7
cgo_enabled: 0
- goos: linux
goarch: arm
goarm: 6
cgo_enabled: 0
- goos: linux
goarch: arm
goarm: 5
cgo_enabled: 0
# END Linux ARM 5 6 7

# BEGIN Linux AMD64 v1 v2 v3
- goos: linux
goarch: amd64
goamd64: v1
cgo_enabled: 0
- goos: linux
goarch: amd64
goamd64: v2
cgo_enabled: 0
- goos: linux
goarch: amd64
goamd64: v3
cgo_enabled: 0
# END Linux AMD64 v1 v2 v3

# BEGIN Linux mips
- goos: linux
goarch: mips64
Expand All @@ -129,9 +124,6 @@ jobs:
cgo_enabled: 1
cc: mips-linux-gnu-gcc
# END Linux mips
- goos: linux
goarch: riscv64
cgo_enabled: 0
fail-fast: false

env:
Expand Down Expand Up @@ -162,20 +154,20 @@ jobs:
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV

- name: get filename
- name: Get the filename
id: get_filename
run: |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOAMD64\"].friendlyName" -r < install/friendly-filenames.json)
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=daed-$_NAME" >> $GITHUB_OUTPUT

- name: install build dependencies
- name: Install mips build dependencies
if: ${{ startsWith(matrix.goarch, 'mips') }}
run: |
sudo apt-get update -y
sudo apt-get update
sudo apt-get install -y gcc-mips64-linux-gnuabi64 gcc-mips64el-linux-gnuabi64 gcc-mips-linux-gnu gcc-mipsel-linux-gnu

- name: download artifact - web
- name: Download artifact - web
uses: actions/download-artifact@v3
with:
name: web
Expand Down Expand Up @@ -208,7 +200,7 @@ jobs:
shasum -a 256 $FILE >>$DGST
shasum -a 512 $FILE >>$DGST

- name: upload artifact - bundled
- name: Upload artifact - bundled
uses: actions/upload-artifact@v3
with:
name: daed-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
Expand All @@ -223,28 +215,3 @@ jobs:
file: daed-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
overwrite: true
tag: ${{ github.ref }}

release:
runs-on: ubuntu-latest
needs: [build-bundle, full-src]
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3

- name: download artifact - web
uses: actions/download-artifact@v3
with:
name: web
path: dist/

- name: docker image - quay.io
uses: aevea/action-kaniko@master
with:
registry: quay.io
username: ${{ github.repository_owner }}
password: ${{ secrets.QUAY_PASS }}
image: ${{ github.repository }}
build_file: Dockerfile
tag_with_latest: true
cache: true
cache_registry: quay.io/${{ github.repository_owner }}/cache
41 changes: 41 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Docker Image

on:
release:
types: [prereleased]

jobs:
publish-docker-image:
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to quay.io
uses: docker/login-action@v2
with:
mzz2017 marked this conversation as resolved.
Show resolved Hide resolved
registry: quay.io
username: ${{ github.repository_owner }}
password: ${{ secrets.QUAY_PASS }}

- name: Build quay.io image
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: Dockerfile
platforms: linux/amd64
push: true
tags: |
quay.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
32 changes: 32 additions & 0 deletions .github/workflows/publish-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish Github Pages

on:
push:
branches:
- main

jobs:
publish-gh-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2
with:
version: latest

- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: latest

- name: build
run: |
pnpm install
pnpm build

- name: Publish Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
7 changes: 0 additions & 7 deletions Caddyfile

This file was deleted.

30 changes: 24 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:alpine as builder
FROM node:alpine as build-web

WORKDIR /build

Expand All @@ -9,11 +9,29 @@ RUN corepack prepare pnpm@latest --activate
RUN pnpm install
RUN pnpm build

FROM caddy:alpine
FROM golang:1.20-bullseye as build-bundle
piyoki marked this conversation as resolved.
Show resolved Hide resolved

WORKDIR /srv
ENV CGO_ENABLED=0

COPY --from=builder /build/dist/. .
COPY Caddyfile .
WORKDIR /build

COPY --from=build-web /build/dist web
COPY --from=build-web /build/wing wing

RUN apt-get update && apt-get install -y llvm clang git make
piyoki marked this conversation as resolved.
Show resolved Hide resolved
RUN cd wing && make OUTPUT=daed WEB_DIST=/build/web/ bundle
RUN apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/{apt,dpkg,cache,log}/

FROM alpine

RUN mkdir -p /usr/local/share/daed/
RUN mkdir -p /etc/daed/
RUN wget -O /usr/local/share/daed/geoip.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geoip.dat
RUN wget -O /usr/local/share/daed/geosite.dat https://github.com/v2rayA/dist-v2ray-rules-dat/raw/master/geosite.dat

COPY --from=build-bundle /build/wing/daed /usr/local/bin

EXPOSE 2023

CMD ["caddy", "run"]
CMD ["daed"]
ENTRYPOINT ["daed", "run", "-c", "/etc/daed"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ daed:
all: clean daed

clean:
rm -rf dist && rm -f dae
rm -rf dist && rm -f daed

## Begin Git Submodules
.gitmodules.d.mk: .gitmodules
Expand Down