gabriel / musehub public
Dockerfile
103 lines 4.4 KB Hotspot
Raw
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 RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels /tmp/muse
26
27 COPY musehub/requirements.txt .
28
29 # Build cryptography from source with a generic aarch64 CPU target so the Rust
30 # backend avoids optional instructions (sha512, sm3, etc.) that Docker Desktop's
31 # ARM VM doesn't expose. --no-binary forces a source build; the flag has no effect
32 # on x86_64 where the pre-built wheel works fine.
33 RUN RUSTFLAGS="-C target-cpu=generic" \
34 pip wheel --no-cache-dir --no-deps --no-binary cryptography \
35 --wheel-dir /app/wheels cryptography==48.0.0
36
37 # The exact versions to install (see constraints.txt). Copied after the source
38 # builds above so changing it does not rebuild the muse or cryptography wheels.
39 COPY musehub/constraints.txt .
40
41 # Build all remaining dependencies from pre-built wheels where available.
42 # Exclude cryptography — already built from source above.
43 RUN grep -v '^cryptography' requirements.txt \
44 | pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -c constraints.txt -r /dev/stdin
45
46
47 FROM python:3.14-slim AS runtime
48
49 # Provenance. push.sh passes the Muse revisions the context was exported from and refuses to deploy an image
50 # whose labels do not carry them. Empty for local compose builds, which are never deployed.
51 ARG MUSEHUB_REVISION=""
52 ARG MUSE_REVISION=""
53 LABEL org.opencontainers.image.revision="${MUSEHUB_REVISION}" \
54 org.opencontainers.image.source="muse:musehub" \
55 ai.musehub.muse-engine-revision="${MUSE_REVISION}"
56
57 WORKDIR /app
58
59 RUN groupadd -r musehub && useradd -r -g musehub musehub
60
61 RUN apt-get update && apt-get install -y --no-install-recommends \
62 libpq5 \
63 libcairo2 \
64 libpango-1.0-0 \
65 libpangocairo-1.0-0 \
66 libgdk-pixbuf-2.0-0 \
67 && rm -rf /var/lib/apt/lists/*
68
69 # Playwright Chromium for OG card rendering (musehub#129).
70 ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
71
72 COPY --from=builder /app/wheels /wheels
73 # pip fetches the transitive dependencies here, so the same constraints apply. The
74 # file is bind-mounted from the builder stage and leaves nothing in the image.
75 RUN --mount=type=bind,from=builder,source=/app/constraints.txt,target=/tmp/constraints.txt \
76 pip install --no-cache-dir -c /tmp/constraints.txt /wheels/* \
77 && playwright install --with-deps chromium \
78 && mkdir -p /ms-playwright \
79 && chown -R musehub:musehub /ms-playwright
80
81 COPY --chown=musehub:musehub musehub/musehub/ ./musehub/
82 COPY --chown=musehub:musehub musehub/alembic/ ./alembic/
83 COPY --chown=musehub:musehub musehub/alembic.ini musehub/pyproject.toml ./
84 COPY --chown=musehub:musehub musehub/docs/ ./docs/
85 COPY --chown=musehub:musehub musehub/deploy/ ./deploy/
86
87 COPY --chown=musehub:musehub musehub/entrypoint.sh ./entrypoint.sh
88 RUN chmod +x ./entrypoint.sh
89
90 RUN mkdir -p /data && chown -R musehub:musehub /data && chmod 755 /data
91
92 USER musehub
93
94 ENV PYTHONPATH=/app
95 ENV PYTHONDONTWRITEBYTECODE=1
96 ENV PYTHONUNBUFFERED=1
97
98 EXPOSE 1337
99
100 HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
101 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
102
103 ENTRYPOINT ["./entrypoint.sh"]
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