Docker
The procedure above, in which Moonfire runs directly on the host, is strongly
recommended.
* The single binary installed in `/usr/local/bin` has zero dependencies.
It is statically linked and bundles the UI. It just works. There's no
complex distribution-specific install procedures or danger of conflicting
version requirements between Moonfire and other software. These are the same
problems most people use Docker to solve.
* Moonfire's recommended install method used to involve Docker. In our
experience, complexity around Docker commands, filesystem/process namespace
mappings, broken seccomp defaults that do not allow standard system calls
like `clock_gettime`, etc. has been a major frustration for folks installing
Moonfire. Now that we have the zero-dependencies binary, we recommend
sidestepping all of this and have rewritten the docs accordingly.
…but, you may still prefer Docker for familiarity or other reasons. If so, you
can install the [`ghcr.io/scottlamb/moonfire-nvr`](https://github.com/scottlamb/moonfire-nvr/pkgs/container/moonfire-nvr) Docker images instead. We'll
assume you know your way around your preferred tools and can adapt the
instructions to the workflow you use with Docker. You may find the following
Docker compose snippet useful:
```yaml
version: 3
services:
moonfire-nvr:
# The `vX.Y.Z` images will work on any architecture (x86-64, arm, or
# aarch64); just pick the correct version.
image: ghcr.io/scottlamb/moonfire-nvr:v0.7.11
command: run
volumes:
# Pass through `/var/lib/moonfire-nvr` from the host.
- "/var/lib/moonfire-nvr:/var/lib/moonfire-nvr"
# Pass through `/etc/moonfire-nvr.toml` from the host.
# Be sure to create `/etc/moonfire-nvr.toml` first (see below).
# Docker will "helpfully" create a directory by this name otherwise.
- "/etc/moonfire-nvr.toml:/etc/moonfire-nvr.toml:ro"
# Pass through `/var/tmp` from the host.
# SQLite expects to be able to create temporary files in this dir, which
# is not created in Moonfire's minimal Docker image.
# See:
- "/var/tmp:/var/tmp"
# 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.
# Note that Docker will not honor names from the host here, even if
# `/etc/passwd` is passed through.
# - Be sure to run the `useradd` command below first.
# - Then run `echo $(id -u moonfire-nvr):$(id -g moonfire-nvr)` to see
# what should be filled in here.
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:
Initialize the database |
Non-Docker | sudo -u moonfire-nvr moonfire-nvr init |
Docker | sudo docker compose run --rm moonfire-nvr init |
Run interactive configuration |
Non-Docker | sudo -u moonfire-nvr moonfire-nvr config 2>debug-log |
Docker | sudo docker compose run --rm moonfire-nvr config 2>debug-log |
Enable and start the server |
Non-Docker | sudo systemctl enable --now moonfire-nvr |
Docker | sudo docker compose up --detach moonfire-nvr |
|