# koopa-castopod — Castopod behind host Caddy on :9020
# Docs: https://docs.castopod.org/main/en/getting-started/docker/
services:
  castopod:
    image: docker.io/castopod/castopod:1
    container_name: koopa-castopod
    volumes:
      - castopod-media:/app/public/media
      # optional branding host dir (logo + CSS overlay); safe if empty
      - ./branding:/branding:ro
    environment:
      MYSQL_DATABASE: castopod
      MYSQL_USER: castopod
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      CP_BASEURL: ${CP_BASEURL}
      CP_ANALYTICS_SALT: ${CP_ANALYTICS_SALT}
      CP_CACHE_HANDLER: redis
      CP_REDIS_HOST: redis
      CP_REDIS_PASSWORD: ${MYSQL_PASSWORD}
    networks:
      - castopod-app
      - castopod-db
    ports:
      - "9020:8080"
    labels:
      org.hacktivism.service: castopod
      org.hacktivism.host_port: "9020"
      org.hacktivism.site: castopod.hacktivism.ch
      org.hacktivism.managed_by: koopa-admin
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_started

  mariadb:
    image: docker.io/library/mariadb:11
    container_name: koopa-castopod-mariadb
    networks:
      - castopod-db
    volumes:
      - castopod-db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: castopod
      MYSQL_USER: castopod
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      start_period: 20s
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: docker.io/library/redis:7-alpine
    container_name: koopa-castopod-redis
    command: --requirepass ${MYSQL_PASSWORD}
    volumes:
      - castopod-cache:/data
    networks:
      - castopod-app
    restart: unless-stopped

volumes:
  castopod-media:
  castopod-db:
  castopod-cache:

networks:
  castopod-app:
  castopod-db:
    internal: true
