forked from muscriptor/muscriptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (41 loc) · 1.79 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (41 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# syntax=docker/dockerfile:1
FROM node:22-bookworm-slim AS web-builder
WORKDIR /web
# pnpm is the project's package manager (pinned via package.json#packageManager).
RUN corepack enable
COPY web/package.json web/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY web/ ./
# vite outDir is ../muscriptor/web_dist, i.e. /muscriptor/web_dist in this stage.
RUN pnpm run build
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS runtime
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_FROZEN=1
WORKDIR /app
# fluidsynth is required at runtime for MIDI auralization (the /auralize endpoint).
RUN apt-get update \
&& apt-get install -y --no-install-recommends fluidsynth \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
uv sync --no-install-project
# Pre-fetch the soundfonts (253 MB: .sf2 for /auralize, .sf3 for the web UI)
# into the HF hub cache so a fresh container doesn't download them on first
# use. Runs off just the two files it needs, before the full source COPY,
# so day-to-day code changes don't re-trigger the download.
COPY muscriptor/soundfonts.py muscriptor/utils/download.py /tmp/prewarm/
RUN /app/.venv/bin/python -c "\
import sys; sys.path.insert(0, '/tmp/prewarm'); \
import soundfonts, download; \
download.download_if_necessary(soundfonts.SF2_URL); \
download.download_if_necessary(soundfonts.SF3_URL)" \
&& rm -rf /tmp/prewarm
COPY pyproject.toml uv.lock README.md ./
COPY muscriptor/ ./muscriptor/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync
COPY --from=web-builder /muscriptor/web_dist ./muscriptor/web_dist
EXPOSE 8000
ENTRYPOINT ["uv", "run", "muscriptor", "serve", "--host", "0.0.0.0"]