From 85d1c53c0bff30743a814ccf031ddc74c81bc5f5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:27:08 +0000 Subject: [PATCH 1/2] Initial plan From a8dea5f8530ad0ef00712c170e86713013070596 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:29:32 +0000 Subject: [PATCH 2/2] Add non-root user (1001:1001) to Dockerfile and Dockerfile.cuda with overridable ARG Agent-Logs-Url: https://github.com/mbari-org/vss/sessions/81fed97a-54da-4d92-aa46-3c7802b12681 Co-authored-by: danellecline <1424813+danellecline@users.noreply.github.com> --- Dockerfile | 10 ++++++++++ Dockerfile.cuda | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Dockerfile b/Dockerfile index ae2e50f..d3c7ea1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,10 +21,16 @@ LABEL vendor="MBARI" LABEL maintainer="dcline@mbari.org" LABEL license="Apache License 2.0" +ARG UID=1001 +ARG GID=1001 + # curl needed for health-check; clean apt in same layer to avoid bloating RUN apt-get update && apt-get install -y --no-install-recommends curl && \ apt-get clean && rm -rf /var/lib/apt/lists/* +RUN groupadd --gid ${GID} appuser && \ + useradd --uid ${UID} --gid ${GID} --no-create-home appuser + ENV PATH="/venv/bin:$PATH" ENV APP_HOME=/app ENV HF_HOME=/tmp/transformers_cache @@ -36,6 +42,10 @@ WORKDIR $APP_HOME COPY --from=builder /venv /venv COPY . . +RUN chown -R appuser:appuser /app /venv + +USER ${UID}:${GID} + EXPOSE 80 WORKDIR $APP_HOME/src/app CMD ["sh", "-c", "exec uvicorn main:app --host 0.0.0.0 --port 80 --ws-max-size 10485760"] diff --git a/Dockerfile.cuda b/Dockerfile.cuda index ed1175e..26484e9 100644 --- a/Dockerfile.cuda +++ b/Dockerfile.cuda @@ -33,6 +33,9 @@ LABEL vendor="MBARI" LABEL maintainer="dcline@mbari.org" LABEL license="Apache License 2.0" +ARG UID=1001 +ARG GID=1001 + RUN apt-get update && \ apt-get install -y --no-install-recommends software-properties-common && \ add-apt-repository ppa:deadsnakes/ppa && \ @@ -42,6 +45,9 @@ RUN apt-get update && \ curl libxcb1 libxcb-xinerama0 libxrender1 libxext6 libsm6 libice6 libgl1 && \ apt-get clean && rm -rf /var/lib/apt/lists/* +RUN groupadd --gid ${GID} appuser && \ + useradd --uid ${UID} --gid ${GID} --no-create-home appuser + ENV PATH="/venv/bin:$PATH" ENV APP_HOME=/app ENV HF_HOME=/tmp/transformers_cache @@ -55,6 +61,10 @@ WORKDIR $APP_HOME COPY --from=builder /venv /venv COPY . . +RUN chown -R appuser:appuser /app /venv + +USER ${UID}:${GID} + ARG NUM_WORKERS=1 ENV NUM_WORKERS=${NUM_WORKERS} EXPOSE 80