From 2449be3ff07ee1620688187d795338fb295be6f7 Mon Sep 17 00:00:00 2001 From: Xuzheng Chen <1092889706@qq.com> Date: Sat, 18 Nov 2023 16:18:23 +0800 Subject: [PATCH] ci: try build tun only mode for docker image --- .github/workflows/docker.yml | 21 ++++++++++++++++++++- Dockerfile | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 23f5577..b565d43 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,6 +14,10 @@ permissions: write-all jobs: build: + strategy: + matrix: + build_tag: [ full, tun ] + runs-on: ubuntu-latest steps: @@ -51,7 +55,8 @@ jobs: type=raw,value=latest,enable=${{ github.event_name == 'release' }} # https://github.com/docker/build-push-action - - name: Build and push + - name: Build and push full version + if: ${{ matrix.build_tag == 'full' }} uses: docker/build-push-action@v3 with: context: . @@ -59,3 +64,17 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + build_tag=${{ matrix.build_tag }} + + - name: Bulid and push not full version + if: ${{ matrix.build_tag != 'full' }} + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }}-${{ matrix.build_tag }} + labels: ${{ steps.meta.outputs.labels }}-${{ matrix.build_tag }} + build-args: | + build_tag=${{ matrix.build_tag }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 561d7b3..2765c21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ENV GO111MODULE=on ENV CGO_ENABLED=0 ENV GOOS=linux ENV GOARCH=amd64 - +ARG build_tag=full RUN go env -w GOPROXY=https://goproxy.cn,direct WORKDIR /src @@ -21,7 +21,7 @@ RUN --mount=target=. \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ # go build -ldflags="-w -s" -o /app/main ./cmd/openwrt-wan-reconnect/*.go - go build -v -o /app/zju-connect -trimpath -ldflags "-s -w -buildid=" . + go build -tags ${build_tag} -v -o /app/zju-connect -trimpath -ldflags "-s -w -buildid=" . # Import the binary from build stage FROM gcr.dockerproxy.com/distroless/static:nonroot as prd