# IMPORTANT: Plunk requires HTTPS to work properly
# go to the "Domains" tab and enable HTTPS for your domain

services:
  plunk:
    image: driaug/plunk
    expose:
      - "3000"
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    environment:
      REDIS_URL: ${REDIS_URL}
      DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
      JWT_SECRET: ${JWT_SECRET}
      AWS_REGION: ${AWS_REGION}
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
      AWS_SES_CONFIGURATION_SET: ${AWS_SES_CONFIGURATION_SET}
      APP_URI: ${APP_URI}
      NEXT_PUBLIC_API_URI: ${APP_URI}/api
      API_URI: ${APP_URI}/api
      DISABLE_SIGNUPS: ${DISABLE_SIGNUPS}
    entrypoint: ["/app/entry.sh"]
    restart: unless-stopped

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

  redis:
    image: redis:alpine
    restart: unless-stopped
    expose:
      - 6379
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
    driver: local
  redis_data:
    driver: local