Skip to content

Commit 0fb6d6e

Browse files
OriNachumclaude
andcommitted
gateway Dockerfile: merge the two RUN layers into one (Sonar)
The pip-install and useradd both run as root before the USER switch, so there's no reason for two image layers. Combine them with `&&`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 56a7f5d commit 0fb6d6e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

model_gear/templates/fleet/Dockerfile.gateway

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
# run ahead of a PyPI release set it to a published TestPyPI `.devN` build.
1111
FROM python:3.12-slim
1212
ARG MODEL_GEAR_VERSION
13-
RUN pip install --no-cache-dir "model-gear==${MODEL_GEAR_VERSION}"
14-
# Run as a non-root user — the gateway only binds :8000 and makes outbound HTTP
15-
# calls to the backends on the compose network; it needs no elevated privileges.
16-
RUN useradd --create-home --uid 10001 gateway
13+
# One layer: install model-gear (system-wide, as root) and create the unprivileged
14+
# runtime user. The gateway only binds :8000 and makes outbound HTTP calls to the
15+
# backends on the compose network, so it needs no elevated privileges.
16+
RUN pip install --no-cache-dir "model-gear==${MODEL_GEAR_VERSION}" \
17+
&& useradd --create-home --uid 10001 gateway
1718
USER gateway
1819
EXPOSE 8000
1920
ENTRYPOINT ["python", "-m", "model_gear.gateway"]

0 commit comments

Comments
 (0)