-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (30 loc) · 1 KB
/
Dockerfile
File metadata and controls
39 lines (30 loc) · 1 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Build stage
FROM golang:1.25-alpine AS builder
# Build arguments for version injection
ARG VERSION=dev
ARG GIT_COMMIT=unknown
ARG GIT_TREE_STATE=unknown
ARG BUILD_DATE=unknown
WORKDIR /workspace
# Copy go mod files
COPY go.mod go.mod
COPY go.sum go.sum
# Cache dependencies
RUN go mod download
# Copy source code
COPY cmd/ cmd/
COPY pkg/ pkg/
COPY internal/ internal/
# Build the binary with Activity-specific version information
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-X 'go.miloapis.com/activity/internal/version.Version=${VERSION}' \
-X 'go.miloapis.com/activity/internal/version.GitCommit=${GIT_COMMIT}' \
-X 'go.miloapis.com/activity/internal/version.GitTreeState=${GIT_TREE_STATE}' \
-X 'go.miloapis.com/activity/internal/version.BuildDate=${BUILD_DATE}'" \
-a -o activity ./cmd/activity
# Runtime stage
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/activity .
USER 65532:65532
ENTRYPOINT ["/activity"]