feat: inject version string into binary via Docker build argument
Release / release (pull_request) Successful in 29s

This commit is contained in:
2026-06-12 14:43:20 +01:00
parent e6d34c730a
commit 416684c0c1
2 changed files with 4 additions and 2 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
- name: Build and push Docker image
run: |
docker build -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} .
docker build --build-arg APP_VERSION=${{ steps.get_version.outputs.VERSION }} -t cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} .
docker push cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }}
docker tag cr.jdbnet.co.uk/public/goencode:${{ steps.get_version.outputs.CLEAN_VERSION }} cr.jdbnet.co.uk/public/goencode:latest
docker push cr.jdbnet.co.uk/public/goencode:latest
+3 -1
View File
@@ -6,11 +6,13 @@ WORKDIR /app
# Copy source code
COPY . .
ARG APP_VERSION=dev
# Run go mod tidy to generate go.sum based on source
RUN go mod tidy
# Build the application
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/bin/goencode ./cmd/goencode
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.Version=${APP_VERSION}" -o /app/bin/goencode ./cmd/goencode
# Final stage
FROM debian:bookworm-slim