version: "3.8"

# In this Docker Compose example, we only fire up the services required for local development.
# This is not advised for production use as it exposes ports to the database insecurely.
# If you're looking for a production-ready Docker Compose file, check out the `traefik.yml` file.

services:
  # Database (Postgres)
  # postgres:
  #   image: postgres:alpine
  #   restart: unless-stopped
  #   ports:
  #     - ${POSTGRES_PORT:-5432}:5432
  #   volumes:
  #     - postgres_data:/var/lib/postgresql/data
  #   environment:
  #     POSTGRES_DB: ${POSTGRES_DB:-postgres}
  #     POSTGRES_USER: ${POSTGRES_USER:-postgres}
  #     POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-postgres}"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5

  # Storage (for image uploads)
  minio:
    image: minio/minio
    restart: unless-stopped
    command: server /data
    ports:
      - ${STORAGE_PORT:-9000}:9000
      - 9001:9001 # Minio Console (Optional)
    volumes:
      - minio_data:/data
    environment:
      MINIO_ADDRESS: :9000
      MINIO_CONSOLE_ADDRESS: :9001
      MINIO_ROOT_USER: ${STORAGE_ACCESS_KEY:-minioadmin}
      MINIO_ROOT_PASSWORD: ${STORAGE_SECRET_KEY:-minioadmin}

  # Chrome Browser (for printing and previews)
  chrome:
    image: browserless/chrome:1.61.0-puppeteer-21.4.1
    restart: unless-stopped
    ports:
      - ${CHROME_PORT:-8080}:3000
    environment:
      KEEP_ALIVE: true
      CONNECTION_TIMEOUT: 10000
      EXIT_ON_HEALTH_FAILURE: true
      PRE_REQUEST_HEALTH_CHECK: true
      TOKEN: ${CHROME_TOKEN:-chrome_token}

  # Redis (for cache & server session management)
  redis:
    image: redis:alpine
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD:-password}
    ports:
      - ${REDIS_PORT:-6379}:6379
    volumes:
      - redis_data:/data

volumes:
  minio_data:
  redis_data:
  postgres_data:
