Skip to content

Commit 044eb3d

Browse files
harden(pii): quote PII_WORKERS expansion + raise healthcheck start-period for multi-worker
- Quote ${PII_WORKERS} so a malformed value fails uvicorn arg-parsing instead of being shell-interpreted (verified: '1; echo X' rejected as non-integer, X not run) - Bump HEALTHCHECK start-period 180s -> 300s: N workers load the spaCy models in parallel, stretching cold start beyond the single-worker case
1 parent 65878cf commit 044eb3d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

docker/pii.Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@ USER pii
4242
# 5001 avoids colliding with the app's 3000 in local/compose runs on one host.
4343
EXPOSE 5001
4444

45-
# start-period is generous: five large spaCy models load at import before
46-
# /health responds. Tune against measured cold-start once built.
47-
HEALTHCHECK --interval=30s --timeout=5s --start-period=180s --retries=3 \
45+
# start-period covers the model cold start. With PII_WORKERS>1 each worker loads
46+
# the five spaCy models independently and in parallel, so allow generous headroom
47+
# (memory-bandwidth contention stretches the wall-time beyond the single-worker case).
48+
HEALTHCHECK --interval=30s --timeout=5s --start-period=300s --retries=3 \
4849
CMD curl -fsS http://localhost:5001/health || exit 1
4950

5051
# Worker count is env-driven so ONE image scales per task size: set PII_WORKERS to
5152
# the task's vCPU count (each worker loads the models independently, ~3 GB each, so
5253
# size task memory ≈ PII_WORKERS × 3 GB + overhead). Defaults to 1 for local/small.
5354
# `sh -c exec` expands the env var while keeping uvicorn as PID 1 for clean SIGTERM.
54-
CMD ["sh", "-c", "exec uvicorn server:app --host 0.0.0.0 --port 5001 --workers ${PII_WORKERS:-1}"]
55+
# Quote the expansion so a malformed PII_WORKERS fails uvicorn arg-parsing rather
56+
# than being interpreted by the shell.
57+
CMD ["sh", "-c", "exec uvicorn server:app --host 0.0.0.0 --port 5001 --workers \"${PII_WORKERS:-1}\""]

0 commit comments

Comments
 (0)