Dockerfile
sha256:b4b999434d042d74edc7032f1f2cfd20fda5b3580fe85966351db5b8eef0abb3
feat(intel): every grammar on the hub, and every intel job …
Opus 5.5
minor
⚠ breaking
1 day ago
| 1 | # MuseHub — Production Dockerfile |
| 2 | # Build context: a directory holding musehub/ and muse/. Deployments (deploy/push.sh) assemble it with |
| 3 | # deploy/build_context.py from COMMITTED files only; Dockerfile.dockerignore (next to this file) is an |
| 4 | # allowlist, so a plain `docker build` of the ~/ecosystem working tree cannot pick up stray local files either. |
| 5 | # Multi-stage build: builder installs deps into wheels; runtime copies only the wheels. |
| 6 | # |
| 7 | # Layer invalidation guide (when to rebuild): |
| 8 | # requirements.txt changed → docker compose build musehub |
| 9 | # muse/ source changed → rebuild (muse is bundled as a wheel) |
| 10 | # Python code changed → no rebuild (override.yml bind-mounts musehub/ tests/ etc.) |
| 11 | |
| 12 | FROM python:3.14-slim AS builder |
| 13 | |
| 14 | WORKDIR /app |
| 15 | |
| 16 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 17 | build-essential \ |
| 18 | cargo \ |
| 19 | libssl-dev \ |
| 20 | pkg-config \ |
| 21 | && rm -rf /var/lib/apt/lists/* |
| 22 | |
| 23 | # Build the muse package wheel from source (it lives alongside musehub in the ecosystem). |
| 24 | COPY muse/ /tmp/muse/ |
| 25 | # Its own directory: the runtime installs it in a separate, small layer AFTER the dependency + Chromium layer, so an engine bump never |
| 26 | # rebuilds (or re-uploads) the ~600 MB dependency layer. |
| 27 | RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/musewheel /tmp/muse |
| 28 | |
| 29 | COPY musehub/requirements.txt . |
| 30 | |
| 31 | # Build cryptography from source with a generic aarch64 CPU target so the Rust |
| 32 | # backend avoids optional instructions (sha512, sm3, etc.) that Docker Desktop's |
| 33 | # ARM VM doesn't expose. --no-binary forces a source build; the flag has no effect |
| 34 | # on x86_64 where the pre-built wheel works fine. |
| 35 | RUN RUSTFLAGS="-C target-cpu=generic" \ |
| 36 | pip wheel --no-cache-dir --no-deps --no-binary cryptography \ |
| 37 | --wheel-dir /app/wheels cryptography==48.0.0 |
| 38 | |
| 39 | # The exact versions to install (see constraints.txt). Copied after the source |
| 40 | # builds above so changing it does not rebuild the muse or cryptography wheels. |
| 41 | COPY musehub/constraints.txt . |
| 42 | |
| 43 | # Build all remaining dependencies from pre-built wheels where available. |
| 44 | # Exclude cryptography — already built from source above. |
| 45 | RUN grep -v '^cryptography' requirements.txt \ |
| 46 | | pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -c constraints.txt -r /dev/stdin |
| 47 | |
| 48 | |
| 49 | FROM python:3.14-slim AS runtime |
| 50 | |
| 51 | WORKDIR /app |
| 52 | |
| 53 | RUN groupadd -r musehub && useradd -r -g musehub musehub |
| 54 | |
| 55 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 56 | libpq5 \ |
| 57 | libcairo2 \ |
| 58 | libpango-1.0-0 \ |
| 59 | libpangocairo-1.0-0 \ |
| 60 | libgdk-pixbuf-2.0-0 \ |
| 61 | && rm -rf /var/lib/apt/lists/* |
| 62 | |
| 63 | # Playwright Chromium for OG card rendering (musehub#129). |
| 64 | ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright |
| 65 | |
| 66 | COPY --from=builder /app/wheels /wheels |
| 67 | # pip fetches the transitive dependencies here, so the same constraints apply. The |
| 68 | # file is bind-mounted from the builder stage and leaves nothing in the image. |
| 69 | # This is the large, stable layer (dependencies + Chromium): nothing above it changes per release. |
| 70 | RUN --mount=type=bind,from=builder,source=/app/constraints.txt,target=/tmp/constraints.txt \ |
| 71 | pip install --no-cache-dir -c /tmp/constraints.txt /wheels/* \ |
| 72 | && playwright install --with-deps chromium \ |
| 73 | && mkdir -p /ms-playwright \ |
| 74 | && chown -R musehub:musehub /ms-playwright |
| 75 | |
| 76 | # The Muse engine: a small layer of its own. Same constraints; its dependencies are normally already present from the layer above, |
| 77 | # so this installs just the engine (and fetches a dependency only if a new Muse release adds one). |
| 78 | COPY --from=builder /app/musewheel /musewheel |
| 79 | RUN --mount=type=bind,from=builder,source=/app/constraints.txt,target=/tmp/constraints.txt \ |
| 80 | pip install --no-cache-dir -c /tmp/constraints.txt /musewheel/* |
| 81 | |
| 82 | # Every language grammar Muse parses (muse#251): the intel jobs, blob outlines and release analysis parse stored |
| 83 | # objects in-process, so without these every non-Python file would be file-level only on the hub. Hash-pinned |
| 84 | # wheels approved by the third-party software security gate; their own dependency (tree-sitter) is already installed. |
| 85 | COPY musehub/grammar-requirements.txt /tmp/grammar-requirements.txt |
| 86 | RUN pip install --no-cache-dir --require-hashes --no-deps -r /tmp/grammar-requirements.txt && rm /tmp/grammar-requirements.txt |
| 87 | |
| 88 | COPY --chown=musehub:musehub musehub/musehub/ ./musehub/ |
| 89 | COPY --chown=musehub:musehub musehub/alembic/ ./alembic/ |
| 90 | COPY --chown=musehub:musehub musehub/alembic.ini musehub/pyproject.toml ./ |
| 91 | COPY --chown=musehub:musehub musehub/docs/ ./docs/ |
| 92 | COPY --chown=musehub:musehub musehub/deploy/ ./deploy/ |
| 93 | |
| 94 | COPY --chown=musehub:musehub musehub/entrypoint.sh ./entrypoint.sh |
| 95 | RUN chmod +x ./entrypoint.sh |
| 96 | |
| 97 | RUN mkdir -p /data && chown -R musehub:musehub /data && chmod 755 /data |
| 98 | |
| 99 | USER musehub |
| 100 | |
| 101 | ENV PYTHONPATH=/app |
| 102 | ENV PYTHONDONTWRITEBYTECODE=1 |
| 103 | ENV PYTHONUNBUFFERED=1 |
| 104 | # The source revision the running service reports in GET /protocol (release.revision). Set after the expensive |
| 105 | # layers so it never invalidates their cache; empty for local builds that pass no revision. |
| 106 | |
| 107 | EXPOSE 1337 |
| 108 | |
| 109 | HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \ |
| 110 | CMD python3 -c "import urllib.request, ssl, os; url='https://localhost:1337/healthz' if os.path.exists('/tls/localhost.crt') else 'http://localhost:1337/healthz'; ctx=(lambda c: (setattr(c,'check_hostname',False), setattr(c,'verify_mode',ssl.CERT_NONE), c)[-1])(ssl.create_default_context()) if url.startswith('https') else None; r=urllib.request.urlopen(url, context=ctx); exit(0 if r.status==200 else 1)" || exit 1 |
| 111 | |
| 112 | ENTRYPOINT ["./entrypoint.sh"] |
| 113 | |
| 114 | # Provenance (last, so a version or revision change only touches image metadata, never a cached layer). push.sh passes the Muse revisions the context was exported from and refuses to deploy an image |
| 115 | # whose labels do not carry them. Empty for local compose builds, which are never deployed. |
| 116 | ARG MUSEHUB_REVISION="" |
| 117 | ARG MUSE_REVISION="" |
| 118 | # Declared PEP 440 version (pyproject.toml), derived and checked by push.sh via deploy/release_identity.py. |
| 119 | ARG MUSEHUB_VERSION="" |
| 120 | LABEL org.opencontainers.image.revision="${MUSEHUB_REVISION}" \ |
| 121 | org.opencontainers.image.source="muse:musehub" \ |
| 122 | org.opencontainers.image.version="${MUSEHUB_VERSION}" \ |
| 123 | ai.musehub.muse-engine-revision="${MUSE_REVISION}" |
| 124 | # The app reports this revision at /healthz; deploy.sh refuses to switch traffic to a slot whose revision is not its image's. |
| 125 | ENV MUSEHUB_REVISION=${MUSEHUB_REVISION} |
File History
12 commits
sha256:b4b999434d042d74edc7032f1f2cfd20fda5b3580fe85966351db5b8eef0abb3
feat(intel): every grammar on the hub, and every intel job …
Opus 5.5
minor
⚠
1 day ago
sha256:dd9ed4f632e214728b1d308eb12388955ada29f9586ef130666fdecbe9702c62
fix(build): set MUSEHUB_REVISION after its ARG (rc25 stagin…
Opus 5.5
minor
⚠
1 day ago
sha256:f288f5be1f5f635934fabed2c9e6ebbb4ad72c56f23d29700afa0d4a11128f54
build: a version bump or engine bump no longer rebuilds the…
Opus 5.5
minor
⚠
2 days ago
sha256:c8e165f9c0e0c8c2f888cea908ff5b6b51548acd1b6dbdf7ed11a06211cbe0eb
feat(release): MuseHub builds carry a SemVer release identi…
Opus 5.5
minor
⚠
5 days ago
sha256:70e2deebbf676f002c5122f381222eb21fe65b51c04380538ea9acb3fe62dfc5
build: install the verified dependency versions instead of …
Opus 5.5
minor
⚠
11 days ago
sha256:3c6d2e2751e9222a0872ba699f16baa457d9990c1998c20956badb9186ee69ee
fix(deploy): image built from committed files only, with re…
Opus 5.5
minor
⚠
12 days ago
sha256:8bebf3df8dc7463460c66da612a74d0beaf76cf266e94c540a90c8aa6d04801e
fix: Docker cryptography source build + schema migrations f…
Sonnet 4.6
minor
⚠
194 days ago
sha256:213dc584a24a0fbf4901441218e96d26f1f7beb28ea3dfdf0780cf9a55c1dccf
fix(deploy): prune old images after deploy (keep 3), fix he…
Sonnet 4.6
minor
⚠
200 days ago
sha256:8827f994a73276fc0fbc5be883894247364c00ae076ee253fbdf07dfaff89594
chore: remove git from runtime Docker image
Sonnet 4.6
minor
⚠
206 days ago
sha256:49ee25902ca5b9266752d7dab1fe83d14c50beed94de1b7555c9f0f11d197389
fix: Dockerfile EXPOSE and HEALTHCHECK port 10003 → 1337
Sonnet 4.6
minor
⚠
208 days ago
sha256:0d72b21399b308cc808bc337907eae581da93aa764ab6848069e0e3421b5b8a0
build: bundle muse package into production Docker image
Sonnet 4.6
minor
⚠
208 days ago
sha256:70fd807bda25cfacab9b301bc7be6ab01b27844b080454ac0eba25ea3657c7eb
fix: clone URL shows muse clone https:// and nginx fetch ti…
Sonnet 4.6
major
⚠
221 days ago