Repository navigation
build: speed up and harden image and Compose - #97
Conversation
Dockerfile: install dependencies in their own layer before copying the app, run the app from `/app` instead of an editable install (the Helm chart mounts the config there), and add a health check against the Swagger UI (all API endpoints require authentication). .dockerignore: send only the package, `requirements.txt` and `update-config-map.sh` to the build context. Compose: drop the `version` key, do not publish MongoDB's port, keep data in a named volume, start the app once MongoDB is healthy, and build a local image name instead of a stale public one. CI waits for the containers to be healthy. Closes #77 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Note why `PYTHONPATH` is set and that the health check needs the Swagger UI, move the MongoDB port comment to its service, replace the redundant CI wait loop with one request, and drop the Docker version from the README. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Explain how to keep data from the earlier bind mount, name the Compose volume as Docker shows it, and note the health check assumptions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR makes Docker builds more cacheable and self-contained, runs the application directly from Sequence diagram for health-aware Compose startupsequenceDiagram
participant Compose
participant MongoDB
participant App
participant CI
Compose->>MongoDB: Start container
Compose->>MongoDB: healthcheck mongosh db.adminCommand('ping').ok
MongoDB-->>Compose: Healthy
Compose->>App: Start cloud-registry:local
App->>App: HEALTHCHECK urllib.request.urlopen(HEALTHCHECK_URL)
App-->>Compose: Healthy
CI->>Compose: docker compose up --wait
CI->>App: curl --fail PROBE_ENDPOINT
App-->>CI: 200 response
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #97 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 224 224
=========================================
Hits 224 224 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="Dockerfile" line_range="37-38" />
<code_context>
+## All API endpoints require authentication, so probe the Swagger UI instead;
+## assumes the default port, base path and Swagger UI setting of the config
+## (`server.port`, `api.specs[].connexion.options.swagger_ui`)
+HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
+ CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/ga4gh/registry/v1/ui/', timeout=4)"]
CMD ["python", "-m", "cloud_registry.app"]
</code_context>
<issue_to_address>
**Custom configs stay unhealthy**
When a Docker image is run with a non-default port, API base path, or Swagger UI disabled, `urllib.request.urlopen` keeps probing the hard-coded default URL, so Docker marks an otherwise running app unhealthy when its config changes the port, API base path, or Swagger UI setting; Compose `up --wait` then fails. The Helm chart demonstrates that config can be replaced at runtime.
Use a health endpoint whose availability does not depend on those settings, or make the health-check target configurable alongside the app config.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and compose now stores MongoDB data in a new named volume instead of the existing host directory. Reverting will switch back to the old directory, leaving any records written to the named volume out of view until you reconfigure or copy the data; the old data is not deleted, so the change is recoverable.
Blocking findings: Dockerfile:38
Read the URL probed by the image health check from `HEALTHCHECK_URL`, so that configs with another port, API base path or Swagger UI setting can adjust it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/checks.yaml" line_range="127" />
<code_context>
- done
- echo "App did not respond with 200 at ${PROBE_ENDPOINT} (last status: ${status})"
- exit 1
+ curl --fail --silent --show-error --output /dev/null \
+ --header 'Accept: application/json' "${PROBE_ENDPOINT}"
- name: Show app logs
</code_context>
<issue_to_address>
**Redirects pass the smoke test**
When the probe endpoint returns a 3xx response, `curl --fail` treats the redirect as success, so the workflow passes without receiving the required 200 response from the Swagger UI.
Make the smoke test fail unless the probe endpoint returns HTTP 200.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and compose now uses a new named volume instead of ../data/cloud-registry/db, so existing users can start with an empty database while their old database files remain on disk. Reverting restores the old mount, but writes made to the named volume will need to be copied or mounted separately to appear there.
Blocking findings: .github/workflows/checks.yaml:127
| done | ||
| echo "App did not respond with 200 at ${PROBE_ENDPOINT} (last status: ${status})" | ||
| exit 1 | ||
| curl --fail --silent --show-error --output /dev/null \ |
There was a problem hiding this comment.
🟡 Medium · Redirects pass the smoke test
When the probe endpoint returns a 3xx response, curl --fail treats the redirect as success, so the workflow passes without receiving the required 200 response from the Swagger UI.
Make the smoke test fail unless the probe endpoint returns HTTP 200.
Prompt for AI agents
In `.github/workflows/checks.yaml` at line 127:
**Redirects pass the smoke test**
When the probe endpoint returns a 3xx response, `curl --fail` treats the redirect as success, so the workflow passes without receiving the required 200 response from the Swagger UI.
Make the smoke test fail unless the probe endpoint returns HTTP 200.
Summary
Speeds up and hardens the Docker image and the Compose setup (#77).
requirements.txtin their own layer before the app is copied, so code changes no longer reinstall them. The app is copied to/appand run from there (PYTHONPATH=/app) instead of an editable install. Adds aHEALTHCHECKagainst the Swagger UI..dockerignore: allow-list. Onlycloud_registry/,requirements.txtandupdate-config-map.share sent to the build context, so tests, chart, docs and local files stay out of the image.versionkey and the legacylinks;127.0.0.1is documented);../data/cloud-registry/db;mongoshping);cloud-registry:localwithpull_policy: buildinstead of using the stale public nameelixircloud/cloud-registry:0.1.0.docker compose up --waitwaits for the health checks, then a single request checks the app.Closes #77
Deviations from the issue
/app/cloud_registry/config.yaml, and the config Job runs/app/update-config-map.sh, so the package has to stay at/app. An installed copy would read its own bundled config instead./ga4gh/registry/v1/ui/, not/service-info: every API endpoint requires authentication. The check assumes the default port, base path and Swagger UI setting (noted in the Dockerfile).mongo:7.0(as on dev); aligning the Helm chart's version is Deployment: pin MongoDB, add DB auth, probes #68.Upgrade notes
Compose users who have data in
../data/cloud-registry/dbneed to bind-mount it in adocker-compose.override.yaml(see the README); otherwise MongoDB starts with an empty volume.Verification
docker compose config -qpasses;gitleaks dir .finds no leaks.docker compose up --waitreported both containers healthy, and the Swagger UI responded.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Harden and streamline the Docker and Compose setup for faster builds, reliable startup, and clearer local deployment guidance.
New Features:
Bug Fixes:
Enhancements:
CI:
Documentation: