services:
  discourse-db:
    image: pgvector/pgvector:pg16
    volumes:
      - discourse-postgresql-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: discourse
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: discourse
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U discourse -d discourse"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  discourse-redis:
    image: redis:7-alpine
    volumes:
      - discourse-redis-data:/data
    command: redis-server --requirepass ${REDIS_PASSWORD}
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  discourse-app:
    image: discourse/discourse:2026.1.4
    volumes:
      - discourse-data:/shared
    depends_on:
      discourse-db:
        condition: service_healthy
      discourse-redis:
        condition: service_healthy
    environment:
      DISCOURSE_HOSTNAME: ${DISCOURSE_HOST}
      DISCOURSE_DB_HOST: discourse-db
      DISCOURSE_DB_PORT: 5432
      DISCOURSE_DB_USERNAME: discourse
      DISCOURSE_DB_PASSWORD: ${POSTGRES_PASSWORD}
      DISCOURSE_DB_NAME: discourse
      DISCOURSE_REDIS_HOST: discourse-redis
      DISCOURSE_REDIS_PORT: 6379
      DISCOURSE_REDIS_PASSWORD: ${REDIS_PASSWORD}
      DISCOURSE_DEVELOPER_EMAILS: ${DISCOURSE_ADMIN_EMAIL}
      # Required for email delivery - Discourse will not function correctly without SMTP
      # DISCOURSE_SMTP_ADDRESS: ${SMTP_HOST}
      # DISCOURSE_SMTP_PORT: ${SMTP_PORT}
      # DISCOURSE_SMTP_USER_NAME: ${SMTP_USER}
      # DISCOURSE_SMTP_PASSWORD: ${SMTP_PASSWORD}
      # DISCOURSE_SMTP_ENABLE_START_TLS: "true"
      # DISCOURSE_NOTIFICATION_EMAIL: [email protected]
      # DISCOURSE_DEVELOPER_EMAILS: [email protected]
    ports:
      - 80
    restart: unless-stopped

volumes:
  discourse-postgresql-data:
  discourse-redis-data:
  discourse-data:
