version: '3'
services:
  zookernel:
    build: .
    ports:
      - "80:80"
    volumes:
      - ./docker/main.cfg:/usr/lib/cgi-bin/main.cfg
      - ./docker/oas.cfg:/usr/lib/cgi-bin/oas.cfg
      - ./docker/default.conf:/etc/apache2/sites-available/000-default.conf
      - ./zoo-project/zoo-services/utils/open-api/server/publish.py:/usr/lib/cgi-bin/publish.py
      - ./zoo-project/zoo-services/utils/open-api/server/subscriber.py:/usr/lib/cgi-bin/subscriber.py
      - ./docker/.htaccess:/var/www/html/.htaccess
      - ./zoo-project/zoo-services/utils/open-api/templates/index.html:/var/www/index.html
      - ./zoo-project/zoo-services/utils/open-api/static:/var/www/html/static
      - ../zoo-demos/zoo-demos-202102/examples:/var/www/html/examples
      - ../zoo-demos/zoo-demos-202102/data/topofr.tif:/usr/com/zoo-project/topofr.tif
    depends_on:
      - pgbouncer
    environment:
      - ZOO_REDIS_HOST=redis
  websocketd:
    build: ./docker/websocketd
    ports:
      - 8888:8888
    environment:
      - ZOO_REDIS_HOST=redis
    volumes:
      - ./zoo-project/zoo-services/utils/open-api/server/subscriber.py:/shell.py
    command: ["--port=8888", "/shell.py"]
  pg:
    image: postgres:9.6.18-alpine
    restart: always
    environment:
      POSTGRES_USER: zoo
      POSTGRES_PASSWORD: zoo
      POSTGRES_DB: zoo
    volumes:
      # Load the zoo kernel schema
      - ./zoo-project/zoo-kernel/sql/schema.sql:/docker-entrypoint-initdb.d/1-schema.sql
  pgbouncer:
    image: edoburu/pgbouncer:1.8.1
    environment:
      DATABASE_URL: "postgres://zoo:zoo@pg/zoo"
      MAX_CLIENT_CONN: 1000
      MAX_DB_CONNECTIONS: 100
      DEFAULT_POOL_SIZE: 100
      POOL_MODE: transaction
    ports:
      - "5432:5432"
    depends_on:
      - pg
  redis:
    image: redis:6.0.9
