feat: Add non-root user to Dockerfile for security #59
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.
Configure Docker image to run as 'appuser' instead of root.
Description
This PR addresses a critical security concern by configuring the Docker container to run the application as a dedicated, unprivileged non-root user ('appuser') instead of the default 'root' user.
Running containers as root is against security best practices as it increases the potential impact if the application process is compromised. Switching to a non-root user limits the process's privileges within the container.
This change aligns with Docker security recommendations and hardens the deployment environment.
Changes Made
release
stage of theDockerfile
to:appgroup
) and user (appuser
)./app
directory toappuser:appgroup
.USER appuser
instruction before theENTRYPOINT
to switch to the non-root user.Related Issues/PRs
Checklist