Fix Docker image build metadata

This commit is contained in:
Haitao Pan 2026-04-24 14:59:54 +08:00
parent dfead14145
commit f9c9b3cb68
2 changed files with 9 additions and 3 deletions

View File

@ -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: |

View File

@ -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