diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59b43c0..d7e2181 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,9 @@ defaults: run: shell: bash +env: + DOCKER_TAG: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}" + on: push: tags: @@ -42,12 +45,22 @@ jobs: cross: needs: base # for bundled ui + permissions: + contents: read + packages: write strategy: matrix: include: - - target: x86_64-unknown-linux-musl - - target: aarch64-unknown-linux-musl - - target: armv7-unknown-linux-musleabihf + # Note: keep these arches in sync with `Upload Docker Manifest` list. + - arch: x86_64 # as in `uname -m` on Linux. + rust_target: x86_64-unknown-linux-musl # as in + docker_platform: linux/amd64 # as in + - arch: aarch64 + rust_target: aarch64-unknown-linux-musl + docker_platform: linux/arm64 + - arch: armv7l + rust_target: armv7-unknown-linux-musleabihf + docker_platform: linux/arm/v7 runs-on: ubuntu-latest steps: - name: Checkout @@ -62,7 +75,7 @@ jobs: # Install the needed musl-tools in the host. - name: Install musl-tools run: sudo apt-get --option=APT::Acquire::Retries=3 update && sudo apt-get --option=APT::Acquire::Retries=3 install musl-tools - if: matrix.target == 'x86_64-unknown-linux-musl' + if: matrix.rust_target == 'x86_64-unknown-linux-musl' - name: Build uses: houseabsolute/actions-rust-cross@v0 env: @@ -73,15 +86,30 @@ jobs: VERSION: ${{ github.ref_name }} with: working-directory: server - target: ${{ matrix.target }} + target: ${{ matrix.rust_target }} command: build args: --release --features bundled + - name: Upload Docker Artifact + run: | + tag="${DOCKER_TAG}-${{ matrix.arch }}" + mkdir output + ln ./server/target/${{ matrix.rust_target }}/release/moonfire-nvr output/ + echo ${{secrets.GITHUB_TOKEN}} | docker login --username ${{github.actor}} --password-stdin ghcr.io + docker build --platform ${{ matrix.docker_platform }} --push --tag "${tag}" --file - output < +Docker + +If you are a Docker fan, you can install the `ghcr.io/scottlamb/moonfire-nvr` +Docker images instead. You'll have to adapt the instructions below to a Docker +workflow. You may find the following Docker compose snippet useful: + +```yaml +version: 3 +services: + moonfire-nvr: + image: ghcr.io/scottlamb/moonfire-nvr:v0.7.8 + command: run + + volumes: + # Mount a Docker volume called `moonfire-db` to Moonfire's default + # database path. + - "/var/lib/moonfire-nvr:/var/lib/moonfire-nvr" + + # Pass through `/etc/moonfire-nvr.toml` from the host. + - "/etc/moonfire-nvr.toml:/etc/moonfire-nvr.toml:ro" + + # Add additional mount lines here for each sample file directory + # outside of /var/lib/moonfire-nvr, e.g.: + # - "/media/nvr:/media/nvr" + + # The Docker image doesn't include the time zone database; you must mount + # it from the host for Moonfire to support local time. + - "/usr/share/zoneinfo:/usr/share/zoneinfo:ro" + + # Edit this to match your `moonfire-nvr` user (see `useradd` command in + # install instructions). + user: UID:GID + + # Uncomment this if Moonfire fails with `clock_gettime failed` (likely on + # older 32-bit hosts). + # security_opt: + # - seccomp:unconfined + + environment: + # Edit zone below to taste. The `:` is functional. + TZ: ":America/Los_Angeles" + RUST_BACKTRACE: 1 + + # docker's default log driver won't rotate logs properly, and will throw + # away logs when you destroy and recreate the container. Using journald + # solves these problems. + # + logging: + driver: journald + options: + tag: moonfire-nvr + + restart: unless-stopped + + ports: + - "8080:8080/tcp" +``` + +Command reference: + +| | Moonfire directly installed on the host | Moonfire with docker compose | +|-------------------------------|--------------------------------------------------------|------------------------------| +| Initialize the database | `sudo -u moonfire-nvr moonfire-nvr init` | `sudo docker compose run --rm moonfire-nvr init` | +| Run interactive configuration | `sudo -u moonfire-nvr moonfire-nvr config 2>debug-log` | `sudo docker compose run --rm moonfire-nvr config 2>debug-log` | +| Enable and start the server | `sudo systemctl enable --now moonfire-nvr` | `sudo docker compose up --detach moonfire-nvr` | + + + Next, you'll need to set up your filesystem and the Moonfire NVR user. Moonfire NVR keeps two kinds of state: