# koopa-bonfire — ground zero (host Caddy → :9021)
services:
  web:
    image: docker.io/bonfirenetworks/bonfire:1.0.5-social-amd64
    container_name: koopa-bonfire
    restart: unless-stopped
    env_file: [.env]
    environment:
      POSTGRES_HOST: db
      HOSTNAME: bonfire.hacktivism.ch
      PUBLIC_PORT: "443"
      SERVER_PORT: "4000"
      DB_MIGRATE_INDEXES_CONCURRENTLY: "false"
      MIX_ENV: prod
    ports:
      - "9021:4000"
    volumes:
      - ./data/uploads:/opt/app/data/uploads
      # Bind-mount into priv/static/images (Bonfire serves /images/* from there).
      - ./data/branding/logo.svg:/opt/app/lib/bonfire-1.0.5-social/priv/static/images/hacktivism-logo.svg:ro
      - ./data/branding/favicon.svg:/opt/app/lib/bonfire-1.0.5-social/priv/static/images/hacktivism-favicon.svg:ro
    depends_on:
      db:
        condition: service_healthy
    labels:
      org.hacktivism.service: bonfire
      org.hacktivism.host_port: "9021"
      org.hacktivism.site: bonfire.hacktivism.ch
      org.hacktivism.managed_by: koopa-admin
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:4000/ || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 15
      start_period: 180s

  db:
    image: docker.io/library/postgres:15-alpine
    container_name: koopa-bonfire-db
    restart: unless-stopped
    env_file: [.env]
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: bonfire_db
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d bonfire_db"]
      interval: 5s
      timeout: 5s
      retries: 20
      start_period: 10s

volumes:
  db-data:
