Skip to content

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

Open
chernojagne wants to merge 1 commit into
python-gitlab:mainfrom
autar-pr:run-containers-as-non-root-a2153b94
Open

fix(docker): run container as non-root user#3429
chernojagne wants to merge 1 commit into
python-gitlab:mainfrom
autar-pr:run-containers-as-non-root-a2153b94

Conversation

@chernojagne

Copy link
Copy Markdown

Changes

Add a non-root user (app, UID 1001) to the Dockerfile and set USER 1001
before the container entrypoint. Running as root in a container is a security
risk — it widens the blast radius if the process is compromised, and many
Kubernetes deployments enforce a non-zero runAsUser policy that would
reject a root container at admission.

The RUN instruction uses both Alpine-style (addgroup -S / adduser -S)
and glibc-style (groupadd --system / useradd --system) forms so the
image continues to build from either python:3.x-alpine or
python:3.x-slim base images.

Documentation and testing


This change was generated by Autar and reviewed by a
human before submission.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.78%. Comparing base (ede7fd7) to head (2ee9266).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3429      +/-   ##
==========================================
+ Coverage   92.23%   95.78%   +3.54%     
==========================================
  Files         100      100              
  Lines        6172     6172              
==========================================
+ Hits         5693     5912     +219     
+ Misses        479      260     -219     
Flag Coverage Δ
api_func_v4 83.91% <ø> (?)
cli_func_v4 78.79% <ø> (ø)
unit 90.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant