Stamp git commit into docker builds.

Conditionally include git commit into about page.

The if condition is true when the following docker build arg is included

--build-arg=COMMIT=$(git rev-parse --short HEAD)

or when built via github (release.yml)
This commit is contained in:
Paul 2023-02-16 19:52:09 +01:00
parent aadf099f50
commit ad0b43cd45
4 changed files with 16 additions and 2 deletions

View file

@ -4,6 +4,7 @@ LABEL maintainer="Khanh Ngo <k@ndk.name"
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG COMMIT=
ARG BUILD_DEPENDENCIES="npm \
yarn"
@ -54,7 +55,7 @@ RUN cp -r /build/custom/ assets/
# Build
RUN rice embed-go && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o wg-ui .
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X main.gitCommit=${COMMIT}" -a -o wg-ui .
# Release stage
FROM alpine:3.16