security: harden Dockerfile and add .dockerignore#40
Open
sylvainkalache wants to merge 4 commits intomainfrom
Open
security: harden Dockerfile and add .dockerignore#40sylvainkalache wants to merge 4 commits intomainfrom
sylvainkalache wants to merge 4 commits intomainfrom
Conversation
Change auto_promote condition from 'main' to 'master' to match the actual branch name used in Semaphore CI.
This reverts commit dbf6aa8.
- Add non-root user (appuser) to run the container process, reducing blast radius if the container is compromised. - Create .dockerignore to exclude .git, .venv, tests, coverage files, and other dev artifacts from the Docker image.
Greptile OverviewGreptile SummaryThis PR hardens the Docker configuration by running the container as a non-root user and excluding development files from the image. Key changes:
Critical issue:
Confidence Score: 2/5
Important Files Changed
|
| RUN uv pip install --system --no-cache-dir -e . | ||
|
|
||
| # Create non-root user | ||
| RUN useradd -m -u 1000 appuser |
There was a problem hiding this comment.
appuser won't have write permissions to /app but the application writes swagger.json there (server.py:3564). Either change ownership of /app to appuser after copying files, or create a writable cache directory.
Suggested change
| RUN useradd -m -u 1000 appuser | |
| RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app |
Prompt To Fix With AI
This is a comment left during a code review.
Path: Dockerfile
Line: 22:22
Comment:
`appuser` won't have write permissions to `/app` but the application writes `swagger.json` there (server.py:3564). Either change ownership of `/app` to `appuser` after copying files, or create a writable cache directory.
```suggestion
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
```
How can I resolve this? If you propose a fix, please make it concise.Pin codecov/codecov-action and astral-sh/setup-uv to specific commit SHAs to prevent supply chain attacks via compromised tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
appuser) to Dockerfile so the container process doesn't run as root, reducing blast radius if compromised.dockerignoreto exclude.git,.venv, tests, coverage files, CI configs, and other dev artifacts from the Docker imageTest plan
.gitand other excluded files are not in the built image