-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
25 lines (24 loc) · 1.08 KB
/
Copy pathDockerfile
File metadata and controls
25 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# syntax=docker/dockerfile:1
# Local / CI image: compile inside Docker (e.g. make docker-build).
# Release images: GoReleaser (later) builds static binaries, then Dockerfile.release packages them.
# Multi-arch: docker buildx build --platform linux/amd64,linux/arm64 -t gfire:local .
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine AS builder
WORKDIR /src
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG APP_VERSION=0.2.0
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ARG BUILD_DATE=unknown
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath \
-ldflags="-s -w -X github.com/hrodrig/gfire/internal/version.Version=${APP_VERSION} -X github.com/hrodrig/gfire/internal/version.Commit=${GIT_COMMIT} -X github.com/hrodrig/gfire/internal/version.Branch=${GIT_BRANCH} -X github.com/hrodrig/gfire/internal/version.BuildDate=${BUILD_DATE}" \
-o /out/gfire ./cmd/gfire
FROM gcr.io/distroless/static-debian13:nonroot
WORKDIR /app
COPY --from=builder /out/gfire /app/gfire
USER nonroot:nonroot
ENTRYPOINT ["/app/gfire"]
CMD ["version"]