M41: harden trust boundaries and delivery
This commit is contained in:
+11
-4
@@ -1,19 +1,26 @@
|
||||
FROM python:3.12-slim
|
||||
FROM python:3.12-slim-bookworm@sha256:a116514e19457bcb7af7efe9c3dd0b9b71e85b317694e7882a1c52aa15a78134 AS runtime-base
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||
WORKDIR /app
|
||||
COPY backend/requirements.lock ./
|
||||
RUN pip install --no-cache-dir -r requirements.lock
|
||||
COPY backend/requirements-prod.lock ./
|
||||
RUN pip install --no-cache-dir -r requirements-prod.lock
|
||||
COPY backend/pyproject.toml ./
|
||||
COPY backend/app ./app
|
||||
COPY backend/alembic ./alembic
|
||||
COPY backend/alembic.ini ./
|
||||
COPY backend/tests ./tests
|
||||
COPY seed ./seed
|
||||
COPY knowledge ./knowledge
|
||||
COPY backend/entrypoint.sh ./entrypoint.sh
|
||||
RUN pip install --no-cache-dir --no-deps -e . && chmod +x ./entrypoint.sh \
|
||||
&& addgroup --system app && adduser --system --ingroup app --home /app app \
|
||||
&& chown -R app:app /app
|
||||
|
||||
FROM runtime-base AS test
|
||||
COPY backend/requirements.lock ./requirements.lock
|
||||
RUN pip install --no-cache-dir -r requirements.lock
|
||||
COPY backend/tests ./tests
|
||||
USER app
|
||||
|
||||
FROM runtime-base AS runtime
|
||||
# Run migrations and the API as an unprivileged user; nothing here needs root.
|
||||
USER app
|
||||
EXPOSE 8000
|
||||
|
||||
Reference in New Issue
Block a user