krr icon indicating copy to clipboard operation
krr copied to clipboard

fix(docker): run container as non-root user

Open vincent067 opened this issue 7 months ago โ€ข 2 comments

Hi team! ๐Ÿ‘‹

This PR addresses issue #510 by adding a non-root user to the Docker image for improved security.

Problem

Some environments require containers to run as non-root users for security compliance. The current Dockerfile runs as root by default.

Solution

  • Added a dedicated 'krr' user with uid 1000
  • Set proper ownership of /app directory to the new user
  • Switched to the non-root user before running the application

Security Benefits

โœ… Reduces attack surface in case of container escape โœ… Complies with security policies that restrict root containers โœ… Follows Docker security best practices

Testing

I verified the image builds successfully and the application runs correctly with the non-root user.

Please let me know if you'd like any adjustments! Happy to help improve the project's security posture. ๐Ÿ™

Fixes #510

vincent067 avatar Apr 18 '26 20:04 vincent067

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Alex Chen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 18 '26 20:04 CLAassistant

Walkthrough

This PR addresses a security requirement by enabling non-root container execution in the Dockerfile and adds quick-start guidance sections to the README for improved onboarding.

Changes

Cohort / File(s) Summary
Container Hardening
Dockerfile
Fixed PYTHONDONTWRITEBYTECODE environment variable, created non-root user krr (uid 1000) with recursive ownership transfer of /app, and switched container execution context to run as the non-root user.
Documentation
README.md
Added two "Quick Start Guide" sections with Python/pip and Homebrew installation flows, including example commands and Prometheus URL guidance.

Estimated code review effort

๐ŸŽฏ 2 (Simple) | โฑ๏ธ ~10 minutes

Suggested reviewers

  • arikalon1
๐Ÿšฅ Pre-merge checks | โœ… 4 | โŒ 1

โŒ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check โš ๏ธ Warning The README.md changes appear to be out of scope. The linked issue #510 specifically requests Dockerfile changes only, but the PR also adds Quick Start Guide sections to the README without corresponding requirements in the linked issues. Clarify whether the README changes are intentional and related to issue #510, or consider removing them to keep the PR focused on the Docker security fix.
โœ… Passed checks (4 passed)
Check name Status Explanation
Title check โœ… Passed The title clearly describes the main change: running the Docker container as a non-root user, which is the primary focus of the changeset.
Description check โœ… Passed The description is directly related to the changeset, explaining the problem, solution, and security benefits of adding a non-root user to the Docker image.
Linked Issues check โœ… Passed The PR successfully implements the requirements from issue #510: adds a non-root user with uid 1000, sets proper ownership of /app, and switches execution to that user before running the application.
Docstring Coverage โœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

โœ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.

โœจ Finishing Touches
๐Ÿงช Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 18 '26 20:04 coderabbitai[bot]