printhive/docker-compose.yml
dlawler489 9e92be8407 Pin the data paths in compose, and find the files via the container
A stack manager that deploys from its own directory resolved ./data to an
empty folder, so Postgres initialised a blank database and the install
looked wiped. The compose defaults are absolute now, and survive a sync
that deletes an untracked .env.

The backup script asks the running container where /app/uploads comes from
rather than trusting a setting, refuses to mirror an empty folder, and
won't write a dump of an empty library over backups that have one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 16:59:13 +10:00

69 lines
3.1 KiB
YAML

services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: printhive
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-printhive}
POSTGRES_DB: printhive
volumes:
# Set separately from DATA_DIR: Postgres needs a filesystem with real
# ownership and permissions (ext4, xfs, APFS...), which exFAT, FAT and
# most network shares don't provide. Keep it on local disk if the files
# live somewhere like that.
- ${PGDATA_DIR:-/Volumes/Data/printhive/pgdata}:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U printhive -d printhive"]
interval: 5s
timeout: 5s
retries: 10
restart: unless-stopped
app:
# Pulled from the Forgejo registry (built by CI). To build locally instead:
# docker build -t git.plexultra.com/dlawler489/printhive:latest .
image: git.plexultra.com/dlawler489/printhive:latest
pull_policy: always
container_name: printhive-app # stable name for the Traefik file-provider to target
depends_on:
db:
condition: service_healthy
environment:
DATABASE_URL: postgres://printhive:${POSTGRES_PASSWORD:-printhive}@db:5432/printhive
PORT: 3000
COOKIE_SECURE: "true" # served over HTTPS via Traefik
# Optional — these can also be set in the app's Settings menu (stored in the DB).
THINGIVERSE_TOKEN: ${THINGIVERSE_TOKEN:-}
FLARESOLVERR_URL: ${FLARESOLVERR_URL:-}
MAKERWORLD_TOKEN: ${MAKERWORLD_TOKEN:-}
PRINTABLES_TOKEN: ${PRINTABLES_TOKEN:-}
volumes:
# Absolute on purpose: a relative path resolves against whatever folder
# runs compose, which isn't this one when a stack manager deploys it —
# and an empty folder makes a working install look wiped.
# uploads and pgdata hold everything that matters; the other two rebuild.
- ${DATA_DIR:-/Volumes/Data/printhive}/uploads:/app/uploads
- ${DATA_DIR:-/Volumes/Data/printhive}/thumbnails:/app/thumbnails
- ${DATA_DIR:-/Volumes/Data/printhive}/glb:/app/glb
- ${DATA_DIR:-/Volumes/Data/printhive}/extracted:/app/extracted # cache of files unpacked from archives
# No host port published — Traefik auto-discovers the app on the shared network.
networks:
- default # talk to the db
- traefik # reachable by Traefik
restart: unless-stopped
labels:
- "traefik.enable=true"
# App is on two networks; tell Traefik which one to reach it on.
- "traefik.docker.network=${TRAEFIK_NETWORK:-proxy}"
- "traefik.http.routers.printhive.rule=Host(`${PRINTHIVE_HOST:-printhive.plexultra.com}`)"
- "traefik.http.routers.printhive.entrypoints=${TRAEFIK_ENTRYPOINT:-websecure}"
- "traefik.http.routers.printhive.tls=true"
- "traefik.http.routers.printhive.tls.certresolver=${TRAEFIK_CERTRESOLVER:-le}"
- "traefik.http.services.printhive.loadbalancer.server.port=3000"
networks:
default:
# The existing Traefik network (the `proxy` network Traefik runs on).
# Override with TRAEFIK_NETWORK if it ever changes.
traefik:
external: true
name: ${TRAEFIK_NETWORK:-proxy}