Skip to content

Commit 77fc426

Browse files
committed
build(docker): copy only runtime files into the gateway, backend and migrations images
The component runtime stages copied the builder's whole /app, which is the entire repository plus build output: six lockfiles, helm, terraform, docs, .env.example and the Rust build tree. Measured at runtime with an audit hook on a booted container, the gateway reads only gateway/, litellm/ and enterprise/ from /app, the backend only backend/, litellm/ and enterprise/, and the migrations job only litellm/ and run.py. The pyproject.toml read is prisma-python's optional [tool.prisma] lookup, which ours does not define Copy just those, plus .venv, the entrypoint script and schema.prisma for the gateway and backend. PYTHONPATH=/app and the in-Dockerfile asserts are unchanged
1 parent b027ce7 commit 77fc426

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎backend/Dockerfile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ ENV HOME=/home/nonroot \
9494
PYTHONUNBUFFERED=1 \
9595
PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries
9696

97-
COPY --from=builder --chown=nonroot:nonroot /app /app
97+
COPY --from=builder --chown=nonroot:nonroot /app/.venv /app/.venv
98+
COPY --from=builder --chown=nonroot:nonroot /app/litellm /app/litellm
99+
COPY --from=builder --chown=nonroot:nonroot /app/enterprise /app/enterprise
100+
COPY --from=builder --chown=nonroot:nonroot /app/backend /app/backend
101+
COPY --from=builder --chown=nonroot:nonroot /app/docker/component_entrypoint.sh /app/docker/component_entrypoint.sh
102+
COPY --from=builder --chown=nonroot:nonroot /app/schema.prisma /app/schema.prisma
98103
COPY --from=builder /opt/prisma /opt/prisma
99104

100105
RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \

‎gateway/Dockerfile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ ENV HOME=/home/nonroot \
110110
PYTHONUNBUFFERED=1 \
111111
PRISMA_BINARY_CACHE_DIR=/opt/prisma/binaries
112112

113-
COPY --from=builder --chown=nonroot:nonroot /app /app
113+
COPY --from=builder --chown=nonroot:nonroot /app/.venv /app/.venv
114+
COPY --from=builder --chown=nonroot:nonroot /app/litellm /app/litellm
115+
COPY --from=builder --chown=nonroot:nonroot /app/enterprise /app/enterprise
116+
COPY --from=builder --chown=nonroot:nonroot /app/gateway /app/gateway
117+
COPY --from=builder --chown=nonroot:nonroot /app/docker/component_entrypoint.sh /app/docker/component_entrypoint.sh
118+
COPY --from=builder --chown=nonroot:nonroot /app/schema.prisma /app/schema.prisma
114119
COPY --from=builder /opt/prisma /opt/prisma
115120
COPY --from=pgbouncer-builder /usr/local/bin/pgbouncer /usr/local/bin/pgbouncer
116121

‎migrations/Dockerfile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ ENV HOME=/home/nonroot \
108108
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
109109
PRISMA_OFFLINE_MODE=true
110110

111-
COPY --from=builder --chown=nonroot:nonroot /app /app
111+
COPY --from=builder --chown=nonroot:nonroot /app/.venv /app/.venv
112+
COPY --from=builder --chown=nonroot:nonroot /app/litellm /app/litellm
113+
COPY --from=builder --chown=nonroot:nonroot /app/run.py /app/run.py
112114
COPY --from=builder /opt/prisma /opt/prisma
113115

114116
RUN chmod -R a+rX /opt/prisma && \

0 commit comments

Comments
 (0)