version: "3.8"
services:
  cap-web:
    image: ghcr.io/capsoftware/cap-web:latest
    restart: unless-stopped
    environment:
      DATABASE_URL: 'mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@ps-mysql:3306/${MYSQL_DATABASE}?ssl={"rejectUnauthorized":false}'
      WEB_URL: "http://${DOMAIN}:3000"
      NEXTAUTH_URL: "http://${DOMAIN}:3000"
      DATABASE_ENCRYPTION_KEY: ${DATABASE_ENCRYPTION_KEY}
      NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
      CAP_AWS_ACCESS_KEY: ${CAP_AWS_ACCESS_KEY}
      CAP_AWS_SECRET_KEY: ${CAP_AWS_SECRET_KEY}
      CAP_AWS_BUCKET: ${CAP_AWS_BUCKET}
      CAP_AWS_REGION: ${CAP_AWS_REGION}
      S3_PUBLIC_ENDPOINT: "http://${DOMAIN}:3902"
      S3_INTERNAL_ENDPOINT: "http://minio:3902"
    expose:
      - 3000
    depends_on:
      - ps-mysql
      - minio

  ps-mysql:
    image: mysql:8.0
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_ROOT_HOST: "%"
    command:
      - --max_connections=1000
      - --default-authentication-plugin=mysql_native_password
    expose:
      - 3306
    volumes:
      - ps-mysql:/var/lib/mysql

  minio:
    image: quay.io/minio/minio:RELEASE.2025-05-24T17-08-30Z
    restart: unless-stopped
    command: server /bitnami/minio/data --address ":3902" --console-address ":3903"
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
    expose:
      - 3902
      - 3903
    volumes:
      - minio-data:/bitnami/minio/data
      - minio-certs:/certs
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3902/minio/health/ready"]
      interval: 30s
      timeout: 20s
      retries: 3

volumes:
  ps-mysql:
    driver: local
  minio-data:
    driver: local
  minio-certs:
    driver: local
