From a4b92c2d5530c588c5bf5f642a173403134c5357 Mon Sep 17 00:00:00 2001 From: Marcus Kida Date: Thu, 19 Feb 2026 11:22:44 +0100 Subject: [PATCH] Use git repo to compute version hash --- Dockerfile | 5 +++-- compose.yml | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c6f7d7..ad9b802 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ FROM golang:1.25-alpine AS builder -ARG GIT_COMMIT=unknown +RUN apk add --no-cache git WORKDIR /build +COPY .git ./.git COPY go.mod go.sum ./ RUN go mod download COPY *.go ./ COPY migrations/ ./migrations/ -RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${GIT_COMMIT}" -o dmrmap . +RUN CGO_ENABLED=0 go build -ldflags "-X main.version=$(git rev-parse --short HEAD)" -o dmrmap . FROM alpine:3.19 WORKDIR /app diff --git a/compose.yml b/compose.yml index 60d6e77..a274412 100644 --- a/compose.yml +++ b/compose.yml @@ -10,10 +10,7 @@ services: restart: unless-stopped dmrmap: - build: - context: . - args: - GIT_COMMIT: ${GIT_COMMIT:-unknown} + build: . depends_on: - postgres environment: