-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 888 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 888 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
38
# Build stage
FROM golang:1.21-alpine AS builder
# Install build dependencies
RUN apk add --no-cache git make ca-certificates
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s -X main.Version=${VERSION:-dev} -X main.GitCommit=${GIT_COMMIT:-unknown} -X main.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o /build/s3-workload \
./cmd/s3-workload
# Runtime stage - distroless
FROM gcr.io/distroless/static:nonroot
# Copy CA certificates from builder
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy binary
COPY --from=builder /build/s3-workload /usr/local/bin/s3-workload
# Use non-root user
USER 10001:10001
# Expose metrics port
EXPOSE 9090
ENTRYPOINT ["/usr/local/bin/s3-workload"]
CMD ["--help"]