version: '3.9'
services:
  main:
    build:
      context: ../images/wait-for-postgres
      network: host
    ports:
      - '3000:3000'
    depends_on:
      - postgres
      - redis
    environment:
      - HOST=localhost
      - PROTOCOL=http
      - PORT=3000
      - APP_ENV=production
      - REDIS_HOST=redis
      - POSTGRES_HOST=postgres
      - POSTGRES_DATABASE=automatisch
      - POSTGRES_USERNAME=automatisch_user
    volumes:
      - automatisch_storage:/automatisch/storage
  worker:
    build:
      context: ../images/plain
      network: host
    depends_on:
      - main
    environment:
      - APP_ENV=production
      - REDIS_HOST=redis
      - POSTGRES_HOST=postgres
      - POSTGRES_DATABASE=automatisch
      - POSTGRES_USERNAME=automatisch_user
    command: automatisch start-worker --env-file /automatisch/storage/.env
    volumes:
      - automatisch_storage:/automatisch/storage
  postgres:
    image: 'postgres:14.5'
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust
      POSTGRES_DB: automatisch
      POSTGRES_USER: automatisch_user
  redis:
    image: 'redis:7.0.4'
volumes:
  automatisch_storage:
