-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (23 loc) · 811 Bytes
/
Dockerfile
File metadata and controls
33 lines (23 loc) · 811 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
# Build stage
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS builder
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY pkg pkg
COPY main.go main.go
# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o valkey-leader .
# Final stage
FROM --platform=$BUILDPLATFORM debian:trixie-slim
# Install ca-certificates for TLS connections
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd --system --create-home --shell /bin/false valkey-leader
# Copy binary from builder stage
COPY --from=builder /app/valkey-leader /usr/local/bin/valkey-leader
# Switch to non-root user
USER valkey-leader
# Set the entrypoint
ENTRYPOINT ["/usr/local/bin/valkey-leader"]