# Stacks Overview

This directory contains Docker Swarm stack files for the new architecture.

## Prerequisites

- Overlay networks (create once on the manager):
  - `traefik-public`
  - `database-network`
  - `monitoring-network`

```bash
docker network create --driver overlay --attachable traefik-public
docker network create --driver overlay --attachable database-network
docker network create --driver overlay --attachable monitoring-network
```

- Docker secrets (examples):

```bash
printf 'StrongPostgresRoot' | docker secret create pg_root_password -
printf 'StrongMariaRoot'   | docker secret create mariadb_root_password -
printf 'gitea-db-pass'     | docker secret create gitea_db_password -
printf 'nextcloud-pass'    | docker secret create nextcloud_db_password -
printf 'smtp-user'         | docker secret create smtp_user -
printf 'smtp-pass'         | docker secret create smtp_pass -
printf 'postgres://user:pass@postgresql_primary:5432/db' | docker secret create appflowy_db_url -
printf 'minioadmin'        | docker secret create minio_access_key -
printf 'minioadminsecret'  | docker secret create minio_secret_key -
```

- NFS exports on `omv800.local` matching the `driver_opts` in stack volumes.

## Deploy examples

```bash
docker stack deploy -c stacks/core/traefik.yml traefik
docker stack deploy -c stacks/databases/postgresql-primary.yml postgresql
docker stack deploy -c stacks/databases/mariadb-primary.yml mariadb
docker stack deploy -c stacks/databases/redis-cluster.yml redis

docker stack deploy -c stacks/apps/homeassistant.yml homeassistant
docker stack deploy -c stacks/apps/immich.yml immich
docker stack deploy -c stacks/apps/nextcloud.yml nextcloud
docker stack deploy -c stacks/apps/paperless.yml paperless
docker stack deploy -c stacks/apps/jellyfin.yml jellyfin

docker stack deploy -c stacks/apps/gitea.yml gitea
docker stack deploy -c stacks/apps/appflowy.yml appflowy
docker stack deploy -c stacks/apps/vaultwarden.yml vaultwarden
docker stack deploy -c stacks/apps/adguard.yml adguard

docker stack deploy -c stacks/web/caddy.yml caddy
docker stack deploy -c stacks/ai/ollama.yml ollama

docker stack deploy -c stacks/monitoring/netdata.yml netdata
```

## Notes

- Pin image versions and avoid `:latest` in production.
- Use DNS or host pinning for stateful services.
- Consider placement constraints (`node.labels.role`).
