ab2b7ed5ac
- Add version variable to main.go, set via -X ldflags at build time - Pass version through to Server, used in the / endpoint response - Makefile passes VERSION from git describe - Dockerfile accepts VERSION build arg - Woodpecker passes CI_COMMIT_TAG as VERSION
22 lines
409 B
Docker
22 lines
409 B
Docker
FROM golang:1.25-alpine AS builder
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
|
|
ARG VERSION=dev
|
|
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION}" -o artifactapi ./cmd/artifactapi
|
|
|
|
FROM gcr.io/distroless/static-debian12:nonroot
|
|
|
|
COPY --from=builder /build/artifactapi /usr/local/bin/artifactapi
|
|
|
|
EXPOSE 8000
|
|
|
|
ENTRYPOINT ["artifactapi"]
|