version: "3"

services:
  tooljet:
    tty: true
    stdin_open: true
    container_name: Tooljet-app
    image: tooljet/tooljet:ee-lts-latest
    restart: always
    env_file: .env
    ports:
      - 80:80
    deploy: # Please adjust the resource according to your usecase
      resources:
        limits:
          cpus: '1'
          memory: 2G
    depends_on:
      - postgres
      - redis
    environment:
      SERVE_CLIENT: "true"
      PORT: "80"
    command: npm run start:prod

  postgres:
    container_name: ${PG_HOST}
    image: postgres:13
    restart: always
    deploy: # Please adjust the resource according to your usecase
      resources:
        limits:
          cpus: '2'
          memory: 3G
    volumes:
      - postgres:/var/lib/postgresql/data
    env_file: .env
    environment:
      - POSTGRES_USER=${PG_USER}
      - POSTGRES_PASSWORD=${PG_PASS}

  postgrest:
    container_name: postgrest
    image: postgrest/postgrest:v12.2.0
    restart: always
    deploy: # Please adjust the resource according to your usecase
      resources:
        limits:
          cpus: '1'
          memory: 1G
    depends_on:
      - postgres
    env_file: .env
    environment:
      - PGRST_SERVER_PORT=80
      - PGRST_DB_PRE_CONFIG=postgrest.pre_config

  redis:
    container_name: ${REDIS_HOST}
    image: redis:6.2
    restart: always
    deploy: # Please adjust the resource according to your usecase
      resources:
        limits:
          cpus: '1'
          memory: 1G
    env_file:
      - .env
    environment:
      - MASTER=${REDIS_HOST}
      - REDIS_USER=${REDIS_USER}
      - REDIS_PASSWORD=${REDIS_PASSWORD}

volumes:
  postgres:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: ${PWD}/postgres_data
  certs:
  logs:
  fallbackcerts:
