Skip to content

Commit 55b5604

Browse files
Update Dockerfile to use non-root user (#735)
* Update Dockerfile to use non-root user This follows standard security best practices to NOT run applications inside docker containers as the root user if possible Signed-off-by: Matt Norton <matt@carrotmanmatt.com> * Revert sync command argument The dependencies should be synced with `--frozen` not `--locked` because they are already locked in the `uv.lock` file and the `pyproject.toml` does not need checking. See https://docs.astral.sh/uv/reference/cli/#uv-sync Signed-off-by: Matt Norton <matt@carrotmanmatt.com> --------- Signed-off-by: Matt Norton <matt@carrotmanmatt.com> Co-authored-by: automatic-pr-updater[bot] <217796550+automatic-pr-updater[bot]@users.noreply.github.com>
1 parent ff2abf8 commit 55b5604

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ COPY cogs/ /app/cogs/
2222

2323
FROM python:3.13-slim-trixie
2424

25+
RUN groupadd --system --gid 999 nonroot && useradd --system --gid 999 --uid 999 --create-home nonroot
26+
2527
LABEL org.opencontainers.image.source=https://github.com/CSSUoB/TeX-Bot-Py-V2
2628
LABEL org.opencontainers.image.licenses=Apache-2.0
2729

28-
COPY --from=builder --chown=app:app /app /app
30+
COPY --from=builder --chown=nonroot:nonroot /app /app
2931

3032
ENV LANG=C.UTF-8 PATH="/app/.venv/bin:$PATH"
3133

3234
WORKDIR /app
3335

36+
USER nonroot
37+
3438
ENTRYPOINT ["python", "-m", "main"]

0 commit comments

Comments
 (0)