diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index bdbb27a..c2cfe16 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -130,6 +130,10 @@ jobs: platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.service_ref.outputs.image_ref }} + build-args: | + BUILD_COMMIT=${{ github.sha }} + BUILD_DATE=${{ github.event.head_commit.timestamp || github.event.repository.pushed_at }} + BUILD_VERSION=v1.0-beta2 - name: Write image ref artifact run: | diff --git a/Dockerfile b/Dockerfile index 7515be4..cc08202 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ # Stage 1 - build the bridge binary FROM golang:1.25.1 AS builder +ARG BUILD_COMMIT=unknown +ARG BUILD_DATE=unknown +ARG BUILD_VERSION=v1.0-beta2 + WORKDIR /src COPY go.mod go.sum ./ @@ -9,10 +13,8 @@ RUN go mod download COPY . . RUN set -euo pipefail; \ - build_commit="$(git rev-parse --short HEAD)"; \ - build_date="$(git log -1 --format=%cI)"; \ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \ - -ldflags="-s -w -X main.buildCommit=${build_commit} -X main.buildVersion=v1.0-beta2 -X main.buildDate=${build_date}" \ + -ldflags="-s -w -X main.buildCommit=${BUILD_COMMIT} -X main.buildVersion=${BUILD_VERSION} -X main.buildDate=${BUILD_DATE}" \ -o /out/xworkmate-bridge . # Stage 2 - minimal runtime image