From f837156fcc64bbc7863b1572c2bd7d3dfb96cac4 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Thu, 19 Mar 2026 12:12:50 -0400 Subject: [PATCH] Added docker/compose stuff and hopefully fixed CI --- .dockerignore | 4 ++++ .gitea/workflows/ci.yml | 3 +++ Dockerfile | 44 +++++++++++++++++++++++++++++++++++++++++ compose.yml | 15 ++++++++++++++ readme.md | 41 ++++++++++++++++++++++++++++++++++++++ rust-toolchain.toml | 1 + 6 files changed, 108 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a9f717 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target/ +shanty-web/static/ +shanty-web/frontend/dist/ +.git/ diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 5f7b86b..d9b4fe3 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -6,9 +6,12 @@ jobs: check: runs-on: ubuntu-latest steps: + - run: git config --global url."https://git.rcjohnstone.com/".insteadOf "ssh://connor@git.rcjohnstone.com:2222/" + - uses: actions/checkout@v4 with: submodules: true + token: ${{ secrets.GITEA }} - uses: dtolnay/rust-toolchain@stable diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f7ce4f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +# Stage 1: Build frontend (Yew/WASM) +FROM rust:1-bookworm AS frontend +RUN rustup target add wasm32-unknown-unknown \ + && cargo install trunk +WORKDIR /build +COPY . . +RUN rustup target list --installed && cd shanty-web/frontend && trunk build --release + +# Stage 2: Build backend +FROM rust:1-bookworm AS backend +WORKDIR /build +COPY . . +COPY --from=frontend /build/shanty-web/static ./shanty-web/static +RUN cargo build --release --bin shanty + +# Stage 3: Runtime +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates ffmpeg python3 python3-pip python3-venv \ + && rm -rf /var/lib/apt/lists/* + +RUN python3 -m venv /opt/venv \ + && /opt/venv/bin/pip install --no-cache-dir ytmusicapi yt-dlp +ENV PATH="/opt/venv/bin:$PATH" + +WORKDIR /app + +COPY --from=backend /build/target/release/shanty . +COPY --from=backend /build/shanty-web/static ./static +COPY --from=backend /build/shanty-dl/scripts/ytmusic_search.py /usr/share/shanty/ + +RUN mkdir -p /config /data /music + +ENV SHANTY_CONFIG=/config/config.yaml +ENV SHANTY_DATABASE_URL=sqlite:///data/shanty.db?mode=rwc +ENV SHANTY_LIBRARY_PATH=/music +ENV SHANTY_DOWNLOAD_PATH=/data/downloads + +EXPOSE 8085 + +VOLUME ["/config", "/data", "/music"] + +CMD ["./shanty"] diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..ad006ba --- /dev/null +++ b/compose.yml @@ -0,0 +1,15 @@ +services: + shanty: + build: . + ports: + - "8085:8085" + volumes: + - ./config:/config + - shanty-data:/data + - /path/to/music:/music # Change this to your music library path + environment: + - SHANTY_WEB_BIND=0.0.0.0 + restart: unless-stopped + +volumes: + shanty-data: diff --git a/readme.md b/readme.md index 75419e7..02214bd 100644 --- a/readme.md +++ b/readme.md @@ -121,6 +121,47 @@ download: # cookies_path: ~/.config/shanty/cookies.txt # for higher YT rate limits ``` +## Docker + +### Quick start + +```sh +# Edit compose.yml to set your music library path, then: +docker compose up -d +# Open http://localhost:8085 +``` + +### Build from source + +```sh +docker build -t shanty . +docker run -d \ + -p 8085:8085 \ + -v ./config:/config \ + -v shanty-data:/data \ + -v /path/to/music:/music \ + shanty +``` + +### Volumes + +| Mount | Purpose | +|-------|---------| +| `/config` | Config file (`config.yaml`) | +| `/data` | Database (`shanty.db`) and downloads | +| `/music` | Your music library | + +### Environment variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `SHANTY_CONFIG` | `/config/config.yaml` | Config file path | +| `SHANTY_DATABASE_URL` | `sqlite:///data/shanty.db?mode=rwc` | Database URL | +| `SHANTY_LIBRARY_PATH` | `/music` | Music library path | +| `SHANTY_DOWNLOAD_PATH` | `/data/downloads` | Download directory | +| `SHANTY_WEB_PORT` | `8085` | HTTP port | +| `SHANTY_WEB_BIND` | `0.0.0.0` | Bind address | + ## Testing ```sh diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 292fe49..e918eb3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,3 @@ [toolchain] channel = "stable" +targets = ["wasm32-unknown-unknown"]