From 3dbe95235ee828bbbf645fd86d50e570e4026dec Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Sat, 6 Apr 2024 09:31:18 -0700 Subject: [PATCH] fix: add build/version/time to docker images --- .github/workflows/docker.yaml | 4 ++++ Dockerfile | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index f8e8d0a..1805384 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -43,3 +43,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ github.event.release.tag_name }} + TIME=${{ github.event.release.published_at }} + BUILD=${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index d8a711f..9c8e06f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,15 @@ FROM golang:latest +# Set build arguments with default values +ARG VERSION="none" +ARG BUILD="none" +ARG TIME="none" + +# Set environment variables +ENV VERSION=${VERSION} +ENV BUILD=${BUILD} +ENV TIME=${TIME} + WORKDIR /app COPY go.mod ./ @@ -9,7 +19,7 @@ COPY ./ ./ WORKDIR /app/cmd/versitygw ENV CGO_ENABLED=0 -RUN go build -o versitygw +RUN go build -ldflags "-X=main.Build=${BUILD} -X=main.BuildTime=${TIME} -X=main.Version=${VERSION}" -o versitygw FROM alpine:latest