version: '3.3'
volumes:
  db-data:
  s3-data:
services:
  minio:
    image: minio/minio
    command: server /data --address ":9001" --console-address ":9000"
    ports:
      - '9000:9000'
      - '9001:9001'
    environment:
      MINIO_ROOT_USER: tazoner
      MINIO_ROOT_PASSWORD: tazoner104030
    volumes:
      - s3-data:/data
  # This service just makes sure a bucket with the right policies is created
  createbuckets:
    image: minio/mc
    depends_on:
      - minio
    entrypoint: >
      /bin/sh -c " sleep 10; /usr/bin/mc config host add minio http://minio:9001 tazoner tazoner104030; /usr/bin/mc mb minio/typebot; /usr/bin/mc anonymous set public minio/typebot/public; exit 0; "
  typebot-db:
    image: postgres:16
    restart: always
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=typebot
      - POSTGRES_PASSWORD=typebot
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 5s
      timeout: 5s
      retries: 5
  typebot-builder:
    image: baptistearno/typebot-builder:latest
    # build: 
    #   context: ./
    #   dockerfile: Dockerfile
    #   args:
    #     SCOPE: builder
    restart: always
    depends_on:
      typebot-db:
        condition: service_healthy
    ports:
      - '8080:3000'
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    env_file: .env
    volumes:
      - s3-data:/data
  typebot-viewer:
    image: baptistearno/typebot-viewer:latest
    # build: 
    #   context: ./
    #   dockerfile: Dockerfile
    #   args:
    #     SCOPE: viewer
    depends_on:
      typebot-db:
        condition: service_healthy
    restart: always
    ports:
      - '8081:3000'
    env_file: .env
