Skip to content

Commit

Permalink
ci: try build tun only mode for docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
cxz66666 committed Nov 18, 2023
1 parent 18d1690 commit 2449be3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ permissions: write-all

jobs:
build:
strategy:
matrix:
build_tag: [ full, tun ]

runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -51,11 +55,26 @@ 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: .
platforms: linux/amd64,linux/arm64
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 }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2449be3

Please sign in to comment.