Skip to content

Commit 5dcf7ff

Browse files
feat(gnmi-test-server): run container image as non-root
1 parent 2c3995e commit 5dcf7ff

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

test/gnmi/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ RUN --mount=type=bind,target=. \
2626

2727
FROM alpine:${ALPINE_VERSION}
2828

29+
# Create a non-root user
30+
RUN addgroup -g 65532 -S nonroot && \
31+
adduser -u 65532 -S nonroot -G nonroot
32+
2933
# Switch into workspace
3034
WORKDIR /
3135

32-
# Copy executable from build
33-
COPY --from=build /usr/bin/server /
36+
# Copy executable from build and set ownership to non-root user
37+
COPY --from=build --chown=nonroot:nonroot /usr/bin/server /server
38+
39+
# Switch to non-root user
40+
USER nonroot
3441

3542
# Start the server application
3643
CMD ["/server", "--port=9339", "--http-port=8000"]

0 commit comments

Comments
 (0)