Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions deployment/base/hg-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ spec:
spec:
securityContext:
fsGroup: 33
runAsGroup: 33 #www-data
runAsUser: 33
runAsNonRoot: true

containers:
- name: hgweb
Expand Down Expand Up @@ -158,10 +161,6 @@ spec:
memory: 400Mi
ports:
- containerPort: 8080
securityContext:
runAsGroup: 33 #www-data
runAsUser: 33
runAsNonRoot: true

env:
- name: URLS
Expand Down
10 changes: 10 additions & 0 deletions hgweb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ COPY opentelemetry_module.conf /usr/local/apache2/conf/
# Ensure /var/hg and /var/hg/repos are owned by www-data user
RUN install -d /var/hg/repos -o www-data -g www-data

# Make Apache's runtime dir writable by www-data so the container can run as
# non-root. Apache keeps its PID file, mod_wsgi socket (WSGISocketPrefix
# logs/wsgi), mod_cgid socket, and file-based mutexes under this dir; without
# this, startup fails as UID 33.
RUN chown -R www-data:www-data /usr/local/apache2/logs

# Configure hgweb
COPY hgweb.hgrc /var/hg/
COPY hgweb.wsgi /usr/local/www/wsgi-scripts/
Expand All @@ -50,3 +56,7 @@ VOLUME /var/hg/repos
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
ENV OTEL_RESOURCE_ATTRIBUTES_FROM_BUILD="service.name=hgweb,service.version=${APP_VERSION}"

# Run as an unprivileged user. hgweb listens on 8088 (unprivileged), so no
# root-only startup step remains.
USER www-data
Loading