-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: run with non-root users #5114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r to use non-root by default
@shwaddell28 is attempting to deploy a commit to the Danswer Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR introduces non-root user support across the Onyx application stack to comply with Kubernetes pod security policies that prohibit containers running as root. The changes create a consistent onyx
user with UID 1001 in both Docker images and configure all Helm templates to use this non-root user.
The implementation includes three main components:
-
Docker Image Updates: Both
backend/Dockerfile
andbackend/Dockerfile.model_server
now create a non-root user (onyx:1001
) with proper ownership of application directories (/app
,/var/log
) and switch to this user before application startup. -
Centralized Security Configuration: The Helm chart introduces a
celery_shared
section invalues.yaml
containing common security contexts (runAsUser: 1001
,privileged: false
) that all Celery workers inherit by default, reducing configuration duplication. -
Template Updates: All Celery worker templates, model server deployments, and the web server now use Helm's
default
function to fallback to shared security contexts while maintaining the ability to override per-component. This pattern ensures consistent non-root execution across the entire application.
The approach maintains backward compatibility - existing installations with component-specific security contexts will continue to work, while new deployments automatically benefit from the centralized security configuration. The changes align with Kubernetes security best practices by implementing the principle of least privilege and enabling deployment in enterprise environments with restrictive security policies.
Confidence score: 1/5
• This PR has a critical issue that will prevent the model server from starting successfully in production
• The model server's Hugging Face cache management logic expects to move files from /root/.cache/temp_huggingface
to ~/.cache/huggingface
at runtime, but after switching to the non-root user, the /root/.cache/
directory becomes inaccessible
• The model server Docker image needs attention to fix the cache directory ownership and access patterns before this PR can be safely merged
13 files reviewed, 2 comments
As per the contribution guide, we are creating a github issue for discussion before implementation. |
issue #5117 |
Description
We are attempting to deploy using the helm chart provided in this repository. Our kubernetes cluster has policies in place that prohibit any pods running as root. We noticed that the values file for the celery workers and the model-servers support adding "runAsUser" attributes, but the images do not have any non-root users created.
This change introduces a non-root USER to both the onyx-backend and the onyx-model-server images to follow pod security best practices. We updated the values for "celery_shared" to apply the 'podSecurityContext' and 'securityContext' to all celery workloads in one spot. We made sure to add support in the templates to ensure that any edits made to a specific celery worker would be applied. Lastly, we added security context for the web server to explicitly declare the non-root user.
How Has This Been Tested?
We built all docker images locally and ran with
docker run --user 1001 <image> <respective app command>
to ensure that the applications started successfully.Backporting (check the box to trigger backport action)
Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.
Summary by cubic
Added non-root user support to all backend and model server Docker images and updated Helm charts to run all workloads as non-root users by default. This improves security and ensures compatibility with Kubernetes clusters that block root containers.
runAsUser: 1001
and drop root privileges for all workloads, including Celery workers, web server, and model servers.