Skip to content

Commit a5ba416

Browse files
Add CRBM User to Containers Namespace
1 parent 42302cc commit a5ba416

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Dockerfile-api

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Use the official Python image from the Docker Hub
22
FROM python:3.13.2-slim-bookworm AS base
33

4+
ARG APP_GID=10000
5+
ARG APP_UID=16997
6+
47
RUN apt-get update && \
58
apt-get install -y --no-install-recommends \
69
openssh-client && \
@@ -11,18 +14,23 @@ ENV PYTHONUNBUFFERED=1
1114

1215
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
1316

17+
# create user/group
18+
RUN groupadd -g $APP_GID appgroup && \
19+
useradd -m -u $APP_UID -g $APP_GID appuser
20+
USER appuser
21+
1422
# Change the working directory to the `app` directory
1523
WORKDIR /app
1624

1725
# Copy the lockfile and `pyproject.toml` into the image
18-
COPY uv.lock /app/uv.lock
19-
COPY pyproject.toml /app/pyproject.toml
26+
COPY --chown=appuser:appgroup uv.lock /app/uv.lock
27+
COPY --chown=appuser:appgroup pyproject.toml /app/pyproject.toml
2028

2129
# Install dependencies
2230
RUN uv sync --frozen --no-install-project
2331

2432
# Copy the project into the image
25-
COPY . /app
33+
COPY --chown=appuser:appgroup . /app
2634

2735
# Sync the project
2836
RUN uv sync --frozen

0 commit comments

Comments
 (0)