Build the web UI into the .deb

- Package discover/dist to /usr/share/playlistd/discover, and serve it
  from there in the default config. cargo deb refuses to package if the
  UI hasn't been built, rather than shipping without it.
- Install a pinned Node.js (22.23.4, checksum-verified) in the
  Containerfile; Ubuntu 22.04's is too old for Vite. The README's build
  command now builds the UI first.
- Recommend yt-dlp, for playing suggested songs from YouTube.
- If discover.ui points to a missing directory, warn instead of letting
  Rocket panic at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018opPJMJjLWr4RqdG6vuK6p
This commit is contained in:
Claude committed 2026-11-14 10:02:25 +00:00
1 parent 4031ec7c08
commit 77f9f29cc6
5 files changed
+40 -9

No files matched your search

+5
View File
@@ -26,8 +26,13 @@ tokio-util = { version = "0.7", features = ["io"] }
[package.metadata.deb] [package.metadata.deb]
depends = "$auto" depends = "$auto"
# plays suggested songs from YouTube. Distribution packages may be too old to work with YouTube,
# so it's only recommended: a current yt-dlp from elsewhere (e.g. pip) works too
recommends = "yt-dlp"
assets = [ assets = [
["target/release/playlistd", "usr/bin/playlistd", "755"], ["target/release/playlistd", "usr/bin/playlistd", "755"],
# the web UI; build it first with `npm --prefix discover ci && npm --prefix discover run build`
["discover/dist/**/*", "usr/share/playlistd/discover/", "644"],
["etc/playlistd/playlistd.toml", "etc/playlistd/playlistd.toml", "600"], ["etc/playlistd/playlistd.toml", "etc/playlistd/playlistd.toml", "600"],
["etc/playlistd/Rocket.toml", "etc/playlistd/Rocket.toml", "600"], ["etc/playlistd/Rocket.toml", "etc/playlistd/Rocket.toml", "600"],
] ]
+12 -1
View File
@@ -4,6 +4,17 @@ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \ CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH PATH=/usr/local/cargo/bin:$PATH
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl dpkg-dev RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt install -y gcc gcc-multilib cmake pkg-config libssl-dev curl dpkg-dev xz-utils
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain nightly RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain nightly
RUN cargo install cargo-deb RUN cargo install cargo-deb
# Node.js, to build the web UI (Ubuntu 22.04's is too old for Vite)
ARG NODE_VERSION=22.23.4
RUN arch="$(dpkg --print-architecture | sed 's/amd64/x64/')" \
&& file="node-v${NODE_VERSION}-linux-${arch}.tar.xz" \
&& cd /tmp \
&& curl -fsSLO "https://nodejs.org/dist/v${NODE_VERSION}/${file}" \
&& curl -fsSL "https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" | grep " ${file}\$" | sha256sum -c - \
&& tar -xJf "${file}" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "${file}" \
&& node --version
+14 -7
View File
@@ -26,19 +26,25 @@ Build the image:
podman build -t playlistd-22 -f Containerfile . podman build -t playlistd-22 -f Containerfile .
``` ```
Then build the `.deb`. The `sqlx` query macros check queries against a live, migrated database at Then build the web UI and the `.deb`. The `sqlx` query macros check queries against a live,
compile time, so the host's Postgres socket is mounted into the container. With rootless podman, the migrated database at compile time, so the host's Postgres socket is mounted into the container. With
container's root maps to your host user, so local peer authentication works without a password: rootless podman, the container's root maps to your host user, so local peer authentication works
without a password:
```sh ```sh
podman run --rm \ podman run --rm \
-v "$PWD":/mnt -w /mnt \ -v "$PWD":/mnt -w /mnt \
-v /var/run/postgresql:/var/run/postgresql \ -v /var/run/postgresql:/var/run/postgresql \
-e DATABASE_URL='postgres://jude@%2Fvar%2Frun%2Fpostgresql/playlistd' \ -e DATABASE_URL='postgres://jude@%2Fvar%2Frun%2Fpostgresql/playlistd' \
playlistd-22 cargo deb playlistd-22 sh -c 'npm --prefix discover ci && npm --prefix discover run build && cargo deb'
``` ```
The package is written to `target/debian/`. The package is written to `target/debian/`. It installs the web UI to `/usr/share/playlistd/discover`,
which the default config serves at `/`. `cargo deb` refuses to build the package if the UI hasn't been
built.
The package recommends `yt-dlp`, for playing suggested songs from YouTube. Distribution packages of
yt-dlp are often too old to work with YouTube, so you may want a current one instead, e.g. from pip.
### Logging ### Logging
@@ -149,11 +155,12 @@ like a new song to keep it in "Liked new songs", or hide it so it isn't suggeste
mix you've played recently) mixed in evenly, so that `familiar_ratio` of what you hear is familiar. mix you've played recently) mixed in evenly, so that `familiar_ratio` of what you hear is familiar.
If a mix has too few known songs to keep that ratio, all of them are used. If a mix has too few known songs to keep that ratio, all of them are used.
Build it with: The `.deb` includes it (see [Container build](#container-build-ubuntu-2204)). To run it from a
checkout, build it with:
```sh ```sh
cd discover cd discover
npm install npm ci
npm run build npm run build
``` ```
+1 -1
View File
@@ -26,7 +26,7 @@ url = "postgres:///navidrome-playlists"
[discover] [discover]
# Directory with the built discover UI (discover/dist) to serve at / # Directory with the built discover UI (discover/dist) to serve at /
# ui = "/usr/share/playlistd/discover" ui = "/usr/share/playlistd/discover"
# yt-dlp binary used to play suggested songs that aren't in your library # yt-dlp binary used to play suggested songs that aren't in your library
# ytdlp = "yt-dlp" # ytdlp = "yt-dlp"
# Format to ask Subsonic to stream in ("raw" = no transcoding), e.g. "mp3" if your # Format to ask Subsonic to stream in ("raw" = no transcoding), e.g. "mp3" if your
+8
View File
@@ -111,7 +111,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// the discover UI's built files (discover/dist) // the discover UI's built files (discover/dist)
if let Ok(ui) = CONFIG.get().unwrap().get::<String>("discover.ui") { if let Ok(ui) = CONFIG.get().unwrap().get::<String>("discover.ui") {
// Rocket panics if the directory doesn't exist
if std::path::Path::new(&ui).is_dir() {
server = server.mount("/", rocket::fs::FileServer::from(ui)); server = server.mount("/", rocket::fs::FileServer::from(ui));
} else {
log::warn!(
"Not serving the web UI: {} doesn't exist. Build it with `npm run build` in discover/",
ui
);
}
} }
server.launch().await?; server.launch().await?;