-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (26 loc) · 766 Bytes
/
Dockerfile
File metadata and controls
38 lines (26 loc) · 766 Bytes
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
# Build stage
FROM golang:1.25.5-alpine AS builder
# Build arguments for version information
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application with version information
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \
-o /app/bin/server \
./cmd/server
# Runtime stage
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/bin/server /app/server
# Use non-root user (distroless provides nonroot user)
USER nonroot:nonroot
EXPOSE 8080
ENTRYPOINT ["/app/server"]