# Docker

## Docker

```sh
make docker
docker run -d -p 8080:8080 -v fuzzy-data:/data -e FUZZY_ADMIN_KEY=your-generated-key fuzzyshare
```

The image is `FROM scratch` and runs as a non-root user (`65532`). It sets `FUZZY_ADDR=:8080` and `FUZZY_DIR=/data`; pass other settings with `-e` or `--env-file`. Keep `/data` on a volume.

The build downloads one Go module (the Markdown renderer for these docs) and compiles a static binary.

> [!NOTE]
> The image has not been exercised in CI. Run `curl localhost:8080/health` after starting it.

### Docker Compose

```yaml
services:
  fuzzy:
    image: fuzzyshare
    restart: unless-stopped
    ports: ["127.0.0.1:8080:8080"]
    volumes: ["fuzzy-data:/data"]
    environment:
      FUZZY_PUBLIC_URL: https://fuzzyshare.example.com
      FUZZY_TRUST_PROXY: "true"
volumes:
  fuzzy-data:
```

Publish only to `127.0.0.1` and put a [reverse proxy](self-hosting-https.md) in front.

## systemd

```sh
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o fuzzy ./cmd/fuzzy
sudo useradd --system --home /var/lib/fuzzyshare --shell /usr/sbin/nologin fuzzyshare
sudo install -d -o fuzzyshare -g fuzzyshare -m 700 /var/lib/fuzzyshare
sudo install -d /opt/fuzzyshare /etc/fuzzyshare
sudo install -m 755 fuzzy /opt/fuzzyshare/fuzzy
sudo install -m 600 deploy/env.example /etc/fuzzyshare/env   # edit: FUZZY_DIR=/var/lib/fuzzyshare, FUZZY_ADMIN_KEY=...
sudo install -m 644 deploy/fuzzyshare.service /etc/systemd/system/fuzzyshare.service
sudo systemctl enable --now fuzzyshare
```

`deploy/fuzzyshare.service` runs as the unprivileged `fuzzyshare` user, may bind port 80 or 443 through `CAP_NET_BIND_SERVICE`, and writes only to `/var/lib/fuzzyshare`.

Check it:

```sh
systemctl status fuzzyshare
journalctl -u fuzzyshare -f
```
