From e029736803ec5d305d2570322b954b25e2b465df Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 4 Nov 2025 15:02:45 +0800 Subject: [PATCH] perf: update action build --- .dockerignore | 1 - .github/workflows/build-image.yml | 17 ++++++++++++++- Dockerfile.action | 35 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.action diff --git a/.dockerignore b/.dockerignore index 04f47f9..89282d9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ vendor -build/* logs/* data/* release/* diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 2244f66..9b4f9c7 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -10,6 +10,11 @@ on: required: true default: 'latest' type: string + version: + description: 'Version' + required: true + default: 'master' + type: string # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. @@ -27,10 +32,18 @@ jobs: packages: write attestations: write id-token: write - # steps: - name: Checkout repository uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: 'stable' # The Go version to download (if necessary) and use. + - name: Make Build + id: make_build + env: + VERSION: ${{ inputs.version }} + run: | + make linux-amd64 linux-arm64 -s && ls build # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry uses: docker/login-action@v3 @@ -58,6 +71,8 @@ jobs: with: platforms: linux/amd64,linux/arm64 context: . + build-args: VERSION=${{ inputs.version }} push: true + file: Dockerfile.action tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile.action b/Dockerfile.action new file mode 100644 index 0000000..3bebb93 --- /dev/null +++ b/Dockerfile.action @@ -0,0 +1,35 @@ +FROM debian:bullseye-slim AS stage-build +ARG TARGETARCH +ARG VERSION +ENV VERSION=$VERSION +WORKDIR /opt/wisp + +ENV WISP_BUILD_NAME=wisp-${VERSION}-linux-${TARGETARCH} + +COPY ./build/${WISP_BUILD_NAME}.tar.gz . +RUN tar -xzvf ${WISP_BUILD_NAME}.tar.gz && mv ${WISP_BUILD_NAME}/wisp /usr/local/bin/wisp + +FROM debian:bullseye-slim + +ARG TARGETARCH +ENV LANG=en_US.UTF-8 +ARG APT_MIRROR=http://deb.debian.org +ARG DEPENDENCIES=" \ + bash-completion \ + jq \ + less \ + ca-certificates" + +RUN set -ex \ + && sed -i "s@http://.*.debian.org@${APT_MIRROR}@g" /etc/apt/sources.list \ + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ + && apt-get update \ + && apt-get install -y --no-install-recommends ${DEPENDENCIES} \ + && apt-get clean all \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/wisp + +COPY --from=stage-build /usr/local/bin/wisp . + +CMD ["./wisp"] \ No newline at end of file