Skip to content

Commit bdda82a

Browse files
hurricane1988hurricane1988domdomegg
authored
Configure the Dockerfile to run the application as a non-root user. (#202)
<!-- Provide a brief summary of your changes --> run the application as a non-root user. ## Motivation and Context <!-- Why is this change needed? What problem does it solve? --> run the application as a non-root user. ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> YES, build the docker image. ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] New feature (non-breaking change which adds functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [ ] My code follows the repository's style guidelines - [ ] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> Co-authored-by: hurricane1988 <[email protected]> Co-authored-by: adam jones <[email protected]>
1 parent 6ba6129 commit bdda82a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ WORKDIR /app
99
COPY --from=builder /build/registry .
1010
COPY --from=builder /app/data/seed.json /app/data/seed.json
1111
COPY --from=builder /app/internal/docs/swagger.yaml /app/internal/docs/swagger.yaml
12+
13+
# Create a non-privileged user that the app will run under.
14+
# See https://docs.docker.com/go/dockerfile-user-best-practices/
15+
ARG UID=10001
16+
RUN adduser \
17+
--disabled-password \
18+
--gecos "" \
19+
--home "/nonexistent" \
20+
--shell "/sbin/nologin" \
21+
--no-create-home \
22+
--uid "${UID}" \
23+
appuser
24+
25+
USER appuser
1226
EXPOSE 8080
1327

1428
ENTRYPOINT ["./registry"]

0 commit comments

Comments
 (0)