version: "3"
services:
  vserver:
    image: visionect/visionect-server-v3:latest
    shm_size: 1GB
    depends_on:
      - vserver_postgres
      - redis
      - pgbouncer
    volumes:
      - /dev/shm:/dev/shm
    restart: always
    ports:
      - 8081:8081
      - 11113:11113
    links:
       - vserver_postgres:db2_1
    environment:
      - DB2_1_PORT_5432_TCP_ADDR=db2_1
      - CONFIG_Engine_Backend_HTML_DefaultFields_url=https://master.joan.vnct.xyz/uuid/{uuid}/
      - CONFIG_Engine_Backend_HTML_DefaultFields_ReloadTimeout=120
      - CONFIG_Engine_Backend_HTML_PageLayout=1
      - CONFIG_Engine_Backend_HTML_WebkitSessionMemoryLimit=200
      - CONFIG_Engine_RectangleFlags=2
      - CONFIG_Global_AutoUpdater=1
      - CONFIG_Global_AutoBootUpdater=1
      - REDIS_ADDRESS=redis:6379
      #Libsoup ENV
      - VSS_COOKIE_DB_ADDR=pgbouncer
      - VSS_COOKIE_DB_PORT=6432
      - VSS_COOKIE_DB_USER=visionect
      - VSS_COOKIE_DB_PASS=visionect
      - VSS_COOKIE_DB_NAME=koala
  vserver_postgres:
    image: postgres:12
    restart: always
    environment:
      - POSTGRES_USER=visionect
      - POSTGRES_PASSWORD=visionect
      - POSTGRES_DB=koala
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: "pg_isready -h localhost -p 5432 -q -U visionect -d koala"
      interval: 3s
      timeout: 5s
      retries: 5
  redis:
    image: redis:6.2
    restart: always
  pgbouncer:
    image: bitnami/pgbouncer:1.16.1
    restart: always
    environment:
      - POSTGRESQL_USERNAME=visionect
      - POSTGRESQL_PASSWORD=visionect
      - POSTGRESQL_DATABASE=koala
      - POSTGRESQL_HOST=vserver_postgres
      - PGBOUNCER_POOL_MODE=transaction
      - PGBOUNCER_DEFAULT_POOL_SIZE=5
      - PGBOUNCER_MAX_CLIENT_CONN=200
      - PGBOUNCER_DATABASE=koala
volumes:
  pgdata:
