Skip to content

Commit 3d355a1

Browse files
committed
Convert Dockerfile to use distroless base image
- Replace Alpine base with gcr.io/distroless/static-debian12:nonroot - Use multi-stage build to copy CA certificates from temporary Alpine stage - Remove user creation since distroless images handle non-root execution - Improve security and reduce image size with distroless approach - Maintain same functionality while following security best practices
1 parent de99805 commit 3d355a1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# syntax=docker/dockerfile:1
22

3-
FROM alpine:3.22@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412
3+
# Build stage to extract CA certificates
4+
FROM alpine:3.22@sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412 AS certs
5+
RUN apk add --no-cache ca-certificates
46

5-
# Install CA certificates and create non-root user
6-
RUN apk add --no-cache ca-certificates && \
7-
adduser -u 1000 -D temporal
7+
# Final distroless stage
8+
FROM gcr.io/distroless/static-debian12:nonroot
9+
10+
# Copy CA certificates from certs stage
11+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
812

913
# Copy the appropriate binary for target architecture
1014
ARG TARGETARCH
1115
COPY dist/nix_linux_${TARGETARCH}/temporal /temporal
1216

13-
# Run as non-root user temporal
14-
USER temporal:temporal
15-
17+
# Set entrypoint
1618
ENTRYPOINT ["/temporal"]

0 commit comments

Comments
 (0)