version: "3.8"
services:
  # TODO: Remove NGINX service in production
  nginx:
    image: nginx:1.19
    ports:
      - "18080:80"
      - "80:80"
    volumes:
      - nginx:/etc/nginx/conf.d:ro
      - sites:/etc/nginx/sites:ro
      - assets:/etc/nginx/sites/assets:ro
    depends_on:
      - web
  web:
    image: backbone:latest
    command:
      [
        "/home/jingrow/jingrow-bench/env/bin/gunicorn",
        "--bind",
        "0.0.0.0:8000",
        "--timeout",
        "120",
        "--workers",
        "4",
        "--worker-tmp-dir",
        "/dev/shm",
        "--preload",
        "jingrow.app:application",
        "--log-level",
        "DEBUG",
      ]
    working_dir: /home/jingrow/jingrow-bench/sites
    # ports:
    #   - "18000:8000"
    volumes:
      # - nginx:/home/jingrow/jingrow-bench/nginx:rw
      - logs:/home/jingrow/jingrow-bench/logs:rw
      - sites:/home/jingrow/jingrow-bench/sites:rw
      - assets:/home/jingrow/jingrow-bench/sites/assets:ro
    depends_on:
      - redis-cache
      - redis-queue
      - redis-socketio
  socketio:
    image: backbone:latest
    command: ["node", "/home/jingrow/jingrow-bench/apps/jingrow/socketio.js"]
    working_dir: /home/jingrow/jingrow-bench
    # ports:
    #   - "19000:9000"
    volumes:
      - logs:/home/jingrow/jingrow-bench/logs:rw
      - sites:/home/jingrow/jingrow-bench/sites:ro
    depends_on:
      - redis-socketio
      - web
  worker_default:
    image: backbone:latest
    command: ["bench", "worker", "--queue", "default"]
    volumes:
      - sites:/home/jingrow/jingrow-bench/sites:rw
      - logs:/home/jingrow/jingrow-bench/logs:rw
    depends_on:
      - redis-cache
      - redis-queue
      - redis-socketio
  worker_long:
    image: backbone:latest
    command: ["bench", "worker", "--queue", "long"]
    volumes:
      - sites:/home/jingrow/jingrow-bench/sites:rw
      - logs:/home/jingrow/jingrow-bench/logs:rw
    depends_on:
      - redis-cache
      - redis-queue
      - redis-socketio
  worker_short:
    image: backbone:latest
    command: ["bench", "worker", "--queue", "short"]
    volumes:
      - sites:/home/jingrow/jingrow-bench/sites:rw
      - logs:/home/jingrow/jingrow-bench/logs:rw
    depends_on:
      - redis-cache
      - redis-queue
      - redis-socketio
  redis-cache:
    image: redis:6.0
  redis-queue:
    image: redis:6.0
  redis-socketio:
    image: redis:6.0

volumes:
  nginx:
    driver_opts:
      type: none
      o: bind
      device: /home/aditya/Jingrow/benches/jcloude/apps/jcloude/mason/run/nginx
  logs:
    driver_opts:
      type: none
      o: bind
      device: /home/aditya/Jingrow/benches/jcloude/apps/jcloude/mason/run/logs
  sites:
    driver_opts:
      type: none
      o: bind
      device: /home/aditya/Jingrow/benches/jcloude/apps/jcloude/mason/run/sites
  assets:
    driver_opts:
      type: none
      o: bind
      device: /home/aditya/Jingrow/benches/jcloude/apps/jcloude/mason/run/assets
