Skip to content

Docker: faster image builds, safer Compose setup #77

Closed

Description

@uniqueg

Why?

The Docker image and the Compose setup work, but are slow to build, larger and less safe than necessary:

  • Dockerfile copies the whole repository (COPY ./ /app) before pip install -e ., so every code change reinstalls all dependencies; the editable install is not needed in an image. There is no HEALTHCHECK.
  • .dockerignore only excludes Git files, Markdown and egg-info; tests, deployment/, docs/, virtual environments, caches and local data end up in the build context and the image.
  • docker-compose.yaml:
    • publishes MongoDB's port ("27017:27017") on all host interfaces, without authentication;
    • uses mongo:3.6 (end of life since 2021; production uses a different version, see Deployment: pin MongoDB, add DB auth, probes #68);
    • bind-mounts ../data/cloud-registry/db, a directory outside the repository;
    • uses the legacy links instead of depends_on with a health check, so the app can start before MongoDB is ready;
    • tags the local build as elixircloud/cloud-registry:0.1.0, a stale public image name, so docker compose up without --build may pull an old image;
    • has the obsolete top-level version key.

How?

  1. Dockerfile: copy requirements.txt and pyproject.toml first and install dependencies in their own layer, then copy the package and install it non-editably; add a HEALTHCHECK against /ga4gh/registry/v1/service-info (using Python or a tool available in the FOCA base image).
  2. .dockerignore: exclude everything not needed at runtime (tests/, deployment/, docs/, .venv, caches, coverage files, local data).
  3. Compose: don't publish 27017 (or bind it to 127.0.0.1 in an optional override); use a named volume; depends_on with condition: service_healthy and a mongosh health check; pin the same MongoDB version as the Helm chart (Deployment: pin MongoDB, add DB auth, probes #68); use a local image name (e.g. cloud-registry:local); drop version.
  4. Update the README (Docs: update README and Read the Docs build #80) and the CI smoke test (CI: pass on fork and Dependabot PRs, modernize workflow #69) if commands change.

Acceptance criteria

  • Changing a Python file in cloud_registry/ rebuilds the image without reinstalling dependencies.
  • docker compose up --build starts reliably on a clean machine; MongoDB is not reachable from outside the host.
  • The image contains no tests, chart or docs; docker inspect shows a health check.

Dependencies: after #65; MongoDB version aligned with #68.

Activity

  1. added
    priority: medium
    type: delivery
    type: security
    workload: hours
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: deliverytype: securityworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions