File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,11 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
1919 --mount=type=cache,target=/go/pkg/mod \
2020 CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o test-charger ./cmd/test-charger
2121
22+ # Use alpine for directory setup, then copy to distroless
23+ FROM alpine:latest AS setup
24+ RUN addgroup -g 65532 -S nonroot && adduser -u 65532 -S nonroot -G nonroot
25+ RUN mkdir -p /app/data && chown -R nonroot:nonroot /app/data && chmod 755 /app/data
26+
2227# Use distroless for minimal, secure image
2328FROM gcr.io/distroless/static-debian12:nonroot
2429
@@ -29,6 +34,9 @@ LABEL org.opencontainers.image.licenses="MIT"
2934
3035WORKDIR /app
3136
37+ # Copy pre-setup data directory with correct ownership
38+ COPY --from=setup --chown=nonroot:nonroot /app/data ./data
39+
3240# Copy binaries and configs
3341COPY --from=builder --chown=nonroot:nonroot /app/simulator /app/test-charger ./
3442COPY --from=builder --chown=nonroot:nonroot /app/configs ./configs
You can’t perform that action at this time.
0 commit comments