build(docker): replace pip-install-at-startup with proper Dockerfile (#171)#518
Merged
Conversation
…171) The jetstream-consumer service was running `sh -c "pip install nats-py -q && python /consumer.py"` as its compose command, which re-downloaded nats-py on every container restart, added ~10s of startup latency, and broke entirely in air-gapped environments. This change introduces a real `jetstream-consumer/Dockerfile` that bakes the pinned dependency at build time (mirroring `exporter/Dockerfile`): multi-stage `python:3.12-slim` base, non-root UID/GID 1000, embedded `HEALTHCHECK` against `/health`, and a stdin-style `pip install -r /tmp/requirements.txt` to avoid `repr()`-quoting bugs from prior HI Hermes Dockerfiles. Dependencies are pinned in `jetstream-consumer/requirements.txt` (nats-py==2.9.0) and tini is deliberately not pinned (it ships with the base image). docker-compose.yml now `build:`s from `./jetstream-consumer` and lets operators pin a published GHCR tag via `JETSTREAM_CONSUMER_IMAGE` (new optional override documented in `.env.example`). A new `publish-jetstream-consumer-image.yml` workflow publishes multi-arch images to GHCR on every main-branch change to `jetstream-consumer/**`, matching the pattern established for `argus-exporter`. The static `test_dockerfile_constraints.py` regression test now also guards the new Dockerfile's Python base version. Closes #171 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The image format validator failed on
${JETSTREAM_CONSUMER_IMAGE:-argus-jetstream-consumer:local} because the
literal ${...:-...} pattern did not match the image-name regex.
Substitute compose env-var interpolations of the form ${VAR:-default}
and ${VAR-default} with their default value before regex validation.
Bare ${VAR} (no default) is skipped since we cannot validate without
a runtime value.
09761ee to
393ee9a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jetstream-consumer/Dockerfile(multi-stagepython:3.12-slim, non-root UID/GID 1000, embeddedHEALTHCHECK /health) bakesnats-py==2.9.0at build time instead of runningpip install nats-pyon every container start.docker-compose.ymlnowbuild:s from./jetstream-consumerand accepts aJETSTREAM_CONSUMER_IMAGEoverride (documented in.env.example) so production can pin a published GHCR tag..github/workflows/publish-jetstream-consumer-image.ymlpublishes multi-arch GHCR images on main, mirroring the existing exporter pipeline.tests/test_dockerfile_constraints.pyextended to guard both Dockerfiles' Python base version.pip installuses-r /tmp/requirements.txt(stdin-style — not therepr()-wrapped form that caused breakage on HI Hermes).tiniand other base-image-moving packages are intentionally not pinned.Closes #171
Test plan
Lint Python,Test exporter, yamllint, env-example drift check).docker compose build jetstream-consumersucceeds locally.docker compose up -d jetstream-consumerreacheshealthywithout 10s startup pip-install delay.curl http://localhost:9101/metricsreturns Prometheus output.Generated with Claude Code