version: '3.9'
services:
  db:
    image: postgres:13
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=typebot
      - POSTGRES_PASSWORD=typebot
  builder:
    depends_on:
      - db
    build:
      context: .
      args:
        - SCOPE=builder
    ports:
      - '8080:3000'
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    env_file:
      - './apps/builder/.env.production'
    entrypoint: >
      /bin/sh -c "
      ./node_modules/bin/prisma generate;
      echo 'Waiting 5s for db to be ready...';
      sleep 5;
      ./node_modules/.bin/prisma migrate deploy;
      node server.js;"
  viewer:
    depends_on:
      - db
    restart: always
    build:
      context: .
      args:
        - SCOPE=viewer
    ports:
      - '8081:3000'
    env_file:
      - './apps/viewer/.env.production'
    entrypoint: >
      /bin/sh -c "
      ./node_modules/bin/prisma generate;
      node server.js;"
volumes:
  db_data:
  s3_data:
