version: "3.8"

services:

  redis:
    image: redis:alpine
    command: --save 900 1
    volumes:
      - ./data/redis:/data
    restart: unless-stopped

  postgres:
    image: postgres:13-alpine
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=ohmyform
      - POSTGRES_PASSWORD=ohmyform
      - POSTGRES_DB=ohmyform
    restart: unless-stopped

  mailhog:
    image: mailhog/mailhog
    ports:
      - "5051:8025"
    restart: unless-stopped

  api:
    image: ohmyform/api
    ports:
      - "8090:5000"
    environment:
      - CREATE_ADMIN=TRUE
      - ADMIN_EMAIL=admin@local.host
      - ADMIN_USERNAME=admin
      - ADMIN_PASSWORD=admin
      - DATABASE_DRIVER=postgres
      - DATABASE_URL=postgresql://ohmyform:ohmyform@postgres:5432/ohmyform
      - MAILER_URI=smtp://mailhog:1025
      - REDIS_URL=redis://redis
      - PORT=5000
    depends_on:
      - mailhog
      - postgres
      - redis
    restart: unless-stopped

  ui:
    image: ohmyform/ui
    ports:
      - "8080:5000"
    environment:
      - ENDPOINT=http://localhost:8090/graphql
      - SERVER_ENDPOINT=http://api:5000/graphql
      - PORT=5000
    depends_on:
      - api
    restart: unless-stopped
