Use git repo to compute version hash

This commit is contained in:
Marcus Kida 2026-02-19 11:22:44 +01:00
parent 93c8179dae
commit a4b92c2d55
2 changed files with 4 additions and 6 deletions

View file

@ -1,11 +1,12 @@
FROM golang:1.25-alpine AS builder FROM golang:1.25-alpine AS builder
ARG GIT_COMMIT=unknown RUN apk add --no-cache git
WORKDIR /build WORKDIR /build
COPY .git ./.git
COPY go.mod go.sum ./ COPY go.mod go.sum ./
RUN go mod download RUN go mod download
COPY *.go ./ COPY *.go ./
COPY migrations/ ./migrations/ 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 FROM alpine:3.19
WORKDIR /app WORKDIR /app

View file

@ -10,10 +10,7 @@ services:
restart: unless-stopped restart: unless-stopped
dmrmap: dmrmap:
build: build: .
context: .
args:
GIT_COMMIT: ${GIT_COMMIT:-unknown}
depends_on: depends_on:
- postgres - postgres
environment: environment: