Run the UI container as a non-root user - #159
Conversation
Switches to nginx-unprivileged and moves the internal port to 8080, since ports below 1024 require root. The Service's external port is unchanged.
📝 WalkthroughWhat changed
Risk
Security-sensitive areas
Test coverage impact
Operational concerns
WalkthroughThe production container now uses unprivileged Nginx with UID 101. Nginx listens on port 8080. The Kubernetes Deployment and Service route traffic to port 8080 while keeping the Service port configurable with a default of 80. ChangesUnprivileged Nginx runtime
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Dockerfile`:
- Line 12: Replace the mutable stable-alpine reference in the Dockerfile’s FROM
directive with the tested Nginx unprivileged Alpine version and its verified
sha256 digest, preserving the nginxinc/nginx-unprivileged image while making the
base immutable.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: simplify9/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 61b45760-fd5e-4d20-98d7-ec8dc46de792
📒 Files selected for processing (4)
Dockerfilechart/templates/deployment.yamlchart/templates/service.yamlnginx/nginx.conf
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/Dockerfile
⚙️ CodeRabbit configuration file
**/Dockerfile: Review Dockerfiles for root user usage, unnecessary packages,
unpinned base images, secret leakage, cache poisoning,
excessive image size, and missing health checks.Flag:
- running as root
- copying secrets into the image
- package manager cache left behind
- unpinned base images
- curl | sh installation patterns
- unnecessary build tools in runtime images
Files:
Dockerfile
🔇 Additional comments (4)
Dockerfile (1)
13-17: LGTM!nginx/nginx.conf (1)
2-2: LGTM!chart/templates/deployment.yaml (1)
29-34: LGTM!chart/templates/service.yaml (1)
14-14: LGTM!
|
|
||
| # production environment | ||
| FROM nginx:stable-alpine | ||
| FROM nginxinc/nginx-unprivileged:stable-alpine |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Pin the production base image to an immutable reference.
Line 12 uses the mutable stable-alpine tag. A rebuild can silently pull different Nginx or Alpine contents. Use a tested version with a digest, such as nginxinc/nginx-unprivileged:<tested-version>-alpine@sha256:<verified-digest>.
As per path instructions, Dockerfiles must flag unpinned base images.
Suggested change and verification
-FROM nginxinc/nginx-unprivileged:stable-alpine
+FROM nginxinc/nginx-unprivileged:<tested-version>-alpine@sha256:<verified-digest>#!/usr/bin/env bash
set -euo pipefail
tag_info="$(curl -fsSL \
'https://hub.docker.com/v2/repositories/nginxinc/nginx-unprivileged/tags/stable-alpine')"
digest="$(jq -r '.digest // empty' <<<"$tag_info")"
test -n "$digest"
case "$digest" in
sha256:*) ;;
*) exit 1 ;;
esac
printf '%s\n' "$digest"🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Dockerfile` at line 12, Replace the mutable stable-alpine reference in the
Dockerfile’s FROM directive with the tested Nginx unprivileged Alpine version
and its verified sha256 digest, preserving the nginxinc/nginx-unprivileged image
while making the base immutable.
Switches to nginx-unprivileged and moves the internal port to 8080, since ports below 1024 require root. The Service's external port is unchanged.