version: '3.9'

services:
  db:
    image: postgres:latest
    restart: always
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
    volumes:
      - db_data:/var/lib/postgresql/data

  redis:
    image: redis:latest
    restart: always
    volumes:
      - redis_data:/data

  api:
    build:
      context: ./api
      dockerfile: Dockerfile.dev
    restart: always
    volumes:
      - ./api:/app
    ports:
      - 3000:3000
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres?schema=public&connect_timeout=300
      - REDIS_URL=redis://redis:6379
      - CORS_ORIGIN=http://localhost:5000

      - SESSION_SECRET=
      - USE_MAIL=true
      - MAIL_HOST=
      - MAIL_PORT=
      - MAIL_USER=
      - MAIL_PASS=
      - MAIL_FROM=Bliss <noreply@amog-us.club>
      # s3 or local
      - UPLOADER=local
      # if you use s3 set these
      - S3_ENDPOINT=
      - S3_ACCESS_KEY_ID=
      - S3_SECRET_ACCESS_KEY=
      - S3_BUCKET_NAME=
      - S3_REGION=

      # optional
      - COOKIE_NAME=
      - UPLOAD_DIR=

    depends_on:
      - db
      - redis

  web:
    build:
      context: ./web
      dockerfile: Dockerfile.dev
    restart: always
    volumes:
      - ./web:/app
    ports:
      - 5000:5000
    depends_on:
      - api
    environment:
      - NEXT_PUBLIC_API_URL=http://localhost:3000

volumes:
  db_data:
  redis_data:
