Skip to content

Commit 848e00d

Browse files
committed
fix backend deployment
1 parent b29f2f5 commit 848e00d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

deployments/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
2328
FROM gcr.io/distroless/static-debian12:nonroot
2429

@@ -29,6 +34,9 @@ LABEL org.opencontainers.image.licenses="MIT"
2934

3035
WORKDIR /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
3341
COPY --from=builder --chown=nonroot:nonroot /app/simulator /app/test-charger ./
3442
COPY --from=builder --chown=nonroot:nonroot /app/configs ./configs

0 commit comments

Comments
 (0)