compose.yaml runs playlistd with a Postgres database. Settings come from .env (see .env.example), and Postgres must be healthy before playlistd starts. The Dockerfile builds the web UI with Node and the server with Rust, then copies both into a Debian slim image that runs as an unprivileged user. It also installs the latest yt-dlp (with its YouTube scripts) and Deno, the JavaScript runtime yt-dlp needs for YouTube. playlistd's port is only published on 127.0.0.1 by default, since it has no login. The image can't reach a database during the build, so the SQL query data from `cargo sqlx prepare` is now committed in .sqlx/. Builds with DATABASE_URL set still check queries against that database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
49 lines
1.7 KiB
Docker
49 lines
1.7 KiB
Docker
# Image for running playlistd, used by compose.yaml. (Containerfile is for building the .deb.)
|
|
|
|
# ---- web UI ----
|
|
FROM node:22.23.4-bookworm-slim AS ui
|
|
WORKDIR /src
|
|
COPY discover/package.json discover/package-lock.json ./
|
|
RUN npm ci
|
|
COPY discover/ ./
|
|
RUN npm run build
|
|
|
|
# ---- server ----
|
|
FROM rust:1.97-bookworm AS server
|
|
WORKDIR /src
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY .sqlx .sqlx
|
|
COPY migrations migrations
|
|
COPY src src
|
|
# check SQL queries against .sqlx (made by `cargo sqlx prepare`) rather than a live database
|
|
ENV SQLX_OFFLINE=true
|
|
RUN cargo build --release --locked
|
|
|
|
# ---- runtime ----
|
|
FROM debian:bookworm-slim
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates libssl3 python3 python3-venv \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# yt-dlp plays suggested songs from YouTube. It has to be recent to keep working with YouTube, so
|
|
# the latest version is installed: rebuild the image to update it, or set YTDLP_VERSION to pin one.
|
|
ARG YTDLP_VERSION=
|
|
RUN python3 -m venv /opt/yt-dlp \
|
|
&& /opt/yt-dlp/bin/pip install --no-cache-dir "yt-dlp[default]${YTDLP_VERSION:+==${YTDLP_VERSION}}" \
|
|
&& ln -s /opt/yt-dlp/bin/yt-dlp /usr/local/bin/yt-dlp
|
|
# yt-dlp needs a JavaScript runtime for YouTube; Deno is the one it uses by default
|
|
COPY --from=denoland/deno:bin-2.9.8 /deno /usr/local/bin/deno
|
|
|
|
COPY --from=server /src/target/release/playlistd /usr/local/bin/playlistd
|
|
COPY --from=ui /src/dist /usr/share/playlistd/discover
|
|
|
|
RUN useradd --system --create-home --home-dir /var/lib/playlistd playlistd
|
|
USER playlistd
|
|
WORKDIR /var/lib/playlistd
|
|
|
|
ENV ROCKET_ADDRESS=0.0.0.0 \
|
|
ROCKET_PORT=8000 \
|
|
DISCOVER_UI=/usr/share/playlistd/discover
|
|
EXPOSE 8000
|
|
CMD ["playlistd"]
|