From 577715bb4063077d883d45276b38bad4b66fb874 Mon Sep 17 00:00:00 2001 From: IxianPixel Date: Fri, 6 Nov 2026 12:10:53 +0000 Subject: [PATCH] Prepared things for Docker --- .github/workflows/ci.yml | 7 ++++- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 15 +++++++++++ Cargo.lock | 12 ++++----- Cargo.toml | 2 +- README.md | 30 +++++++++++++++++++--- deploy/docker-compose.yml | 11 ++++---- 7 files changed, 108 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8879deb..cf6b087 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,10 @@ name: CI -on: [push, pull_request] +# Branch pushes only: a version tag points at a commit CI has already checked +# on its branch, and release.yml runs the tests again for tags. +on: + push: + branches: ["**"] + pull_request: jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d258d3..7e6b867 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,12 @@ env: ZIG_VERSION: 0.17.0 CARGO_TERM_COLOR: always CARGO_PROFILE_RELEASE_STRIP: symbols + # The Docker image is the release binary on top of this base. Alpine rather + # than distroless so there's a shell for `docker exec` and post-move hooks. + BASE_IMAGE: alpine:3.24 + # crane builds and pushes the image without a Docker daemon. Pinned by hash. + CRANE_VERSION: v0.22.1 + CRANE_SHA256: 0ab7a1d6932a213aed964ce97666c3077fe691c8606413674a8b3e0b9ec4cda0 jobs: release: @@ -86,3 +92,45 @@ jobs: run: >- node .github/scripts/gitea-release.mjs "$GITHUB_REF_NAME" dist/release-notes.md "$ASSET" "$ASSET.sha256" + + - name: Install crane + run: | + curl -fsSLo crane.tar.gz "https://github.com/google/go-containerregistry/releases/download/$CRANE_VERSION/go-containerregistry_Linux_x86_64.tar.gz" + echo "$CRANE_SHA256 crane.tar.gz" | sha256sum -c - + mkdir -p "$HOME/.local/bin" + tar -xzf crane.tar.gz -C "$HOME/.local/bin" crane + rm crane.tar.gz + echo "$HOME/.local/bin" >> "$GITHUB_PATH" + + # Pushes //jellymove:, plus :latest unless the + # tag is a pre-release. The workflow's own token is tried first; if Gitea + # refuses it, add REGISTRY_USER and REGISTRY_TOKEN (write:package) secrets. + - name: Publish the Docker image + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER || github.actor }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN || secrets.GITHUB_TOKEN }} + run: | + registry="${GITHUB_SERVER_URL#*://}" + registry="${registry%%/*}" + image="$registry/$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')" + version="${GITHUB_REF_NAME#v}" + echo "$REGISTRY_TOKEN" | crane auth login "$registry" -u "$REGISTRY_USER" --password-stdin + + mkdir -p dist/image/usr/local/bin + install -m 755 "target/$TARGET/release/jellymove" dist/image/usr/local/bin/jellymove + tar -C dist/image --owner=0 --group=0 --numeric-owner -cf dist/image.tar usr + + crane append --platform linux/amd64 -b "$BASE_IMAGE" -f dist/image.tar -t "$image:$version" + crane mutate "$image:$version" -t "$image:$version" \ + --entrypoint /usr/local/bin/jellymove --cmd run \ + --env JELLYMOVE_CONFIG=/config/jellymove.toml \ + --exposed-ports 8097/tcp --workdir / \ + --label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ + --label "org.opencontainers.image.version=$version" \ + --label "org.opencontainers.image.revision=$GITHUB_SHA" + case "$GITHUB_REF_NAME" in + *-*) echo "Pre-release: not moving :latest" ;; + *) crane tag "$image:$version" latest ;; + esac + crane config "$image:$version" + echo "Pushed $image:$version" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b86286..d777d76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## v0.1.1 + +### Added + +- **Docker image.** Each release now publishes + `git.malgra.com/ixianpixel/jellymove:` (and `:latest`), the same + static binary as the tarball on Alpine. + +### Updated + +- **Docker Compose example** pulls the published image instead of building from + source. +- **Post-move hook docs** explain that the hook runs on the receiving agent, + and warn against mounting the Docker socket. + ## v0.1.0 ### Added diff --git a/Cargo.lock b/Cargo.lock index 48a6d5f..41d23a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,7 +1010,7 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jellymove" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "clap", @@ -1026,7 +1026,7 @@ dependencies = [ [[package]] name = "jm-core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "serde", "serde_json", @@ -1037,7 +1037,7 @@ dependencies = [ [[package]] name = "jm-jellyfin" -version = "0.1.0" +version = "0.1.1" dependencies = [ "axum", "jm-core", @@ -1051,7 +1051,7 @@ dependencies = [ [[package]] name = "jm-server" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "axum", @@ -1080,7 +1080,7 @@ dependencies = [ [[package]] name = "jm-store" -version = "0.1.0" +version = "0.1.1" dependencies = [ "jm-core", "rusqlite", @@ -1093,7 +1093,7 @@ dependencies = [ [[package]] name = "jm-transfer" -version = "0.1.0" +version = "0.1.1" dependencies = [ "axum", "blake3", diff --git a/Cargo.toml b/Cargo.toml index 37a0a38..f9182e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/*"] [workspace.package] -version = "0.1.0" +version = "0.1.1" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.85" diff --git a/README.md b/README.md index 1aa33cd..2c08410 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,18 @@ cp config.example.toml jellymove.toml # edit: node_name, jellyfin.api_key, pee docker compose -f deploy/docker-compose.yml up -d ``` +Each release publishes an image (x86_64) to the Gitea container registry: +`git.malgra.com/ixianpixel/jellymove:`, and `:latest` for anything +that isn't a pre-release. It's the same static binary as the systemd tarball, +on Alpine. If the package isn't public, log in once with a Gitea token that +only has `read:package`: + +```sh +docker login git.malgra.com +``` + +To upgrade, run `docker compose pull && docker compose up -d`. + - Create an admin API key in Jellyfin (Dashboard → API Keys). jellymove reads every user's watch state. - Use the same `peer.token` on both agents (`openssl rand -hex 32`). @@ -102,8 +114,11 @@ Interrupted transfers resume after a restart. git tag v0.1.1 && git push origin v0.1.1 ``` -The workflow runs the tests, builds the UI and binary, and attaches the -tarball and its `.sha256` to a Gitea release for that tag. The release notes +The workflow runs the tests, builds the UI and binary, attaches the tarball +and its `.sha256` to a Gitea release for that tag, then pushes the Docker +image. It builds the image with `crane`, so the runner needs no Docker +socket. It pushes with the workflow's own token; if Gitea refuses that, add +`REGISTRY_USER` and `REGISTRY_TOKEN` (`write:package`) secrets. The release notes are that version's section of `CHANGELOG.md`; the workflow stops straight away if there isn't one. Re-running it replaces the files and refreshes the notes. Tags with a `-` (`v0.2.0-rc1`) are marked pre-release. @@ -123,13 +138,19 @@ server. To file things elsewhere, configure this on the **receiving** agent: While a move is running the item exists on both servers, and Jellyswarrm v0.3.1+ shows it once with two versions. Jellyswarrm's merge cache can go stale when files move ([#216](https://github.com/LLukas22/Jellyswarrm/issues/216)). -Until that is fixed upstream, a post-move hook can restart it: +Until that is fixed upstream, restart Jellyswarrm after a move if the merged +view looks wrong. A post-move hook can do it for you: ```toml [hooks] post_move = "docker restart jellyswarrm" ``` +The hook runs with `sh -c` on the **receiving** agent, so it only helps if +Jellyswarrm runs on that machine. The Docker image has a shell but no Docker +CLI, and mounting `/var/run/docker.sock` gives the container root on the +host. Prefer a socket proxy that only allows restarts, or restart by hand. + ## Safety rules - Nothing leaves the source until the destination has indexed every file. @@ -146,7 +167,8 @@ post_move = "docker restart jellyswarrm" (`POST /UserItems/{id}/UserData`), `/Library/Media/Updated` timing on large libraries, and multi-version movies. - Against real Jellyswarrm. -- The Docker image build (the Dockerfile is written but untested here). +- Running the published Docker image, and building from the `Dockerfile`. + The image's contents and config are checked, but it hasn't been started yet. - Windows and macOS. The code is cross-platform, but only Linux has been run. ## Roadmap diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index ff36744..e23542d 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -2,17 +2,20 @@ # container so the paths Jellyfin reports are the paths jellymove sees. services: jellymove: - image: jellymove:latest - build: .. + # Published by the release workflow. Pin a version (e.g. :0.1.1) to + # upgrade on your own schedule, or use :latest and `docker compose pull`. + image: git.malgra.com/ixianpixel/jellymove:latest + # To build from source instead, replace `image:` with `build: ..`. container_name: jellymove restart: unless-stopped # Same UID:GID as Jellyfin so moved files keep the right ownership. + # On Unraid that's usually "99:100". user: "1000:1000" ports: - "8097:8097" volumes: - ./jellymove.toml:/config/jellymove.toml:ro - - ./jellymove-data:/data + - ./jellymove-data:/data # must be writable by `user:` above - /srv/media/movies:/media/movies # ← match your jellyfin service - /srv/media/tv:/media/tv environment: @@ -20,5 +23,3 @@ services: # JELLYMOVE_JELLYFIN__API_KEY: ... # JELLYMOVE_PEER__TOKEN: ... JELLYMOVE_LOG: info - # Only needed for a post_move hook like `docker restart jellyswarrm`: - # - /var/run/docker.sock:/var/run/docker.sock