version: "3.8"

services:
  guppe:
    image: datatitian/guppe
    deploy:
      mode: replicated
      replicas: 8
      placement:
        constraints:
          - "node.labels.type==web"
    restart: always
    ports:
      - 443:443
      - 80:80
    env_file: '.env'
    environment:
      DB_URL: 'mongodb://mongodb:27017'
      PORT_HTTPS: 443
    depends_on:
      - mongodb
    volumes:
      - certs:/root/.small-tech.org/auto-encrypt
      # localdev certs
      - ./certs:/usr/src/guppe/certs
    logging:
      driver: local
      options:
        max-size: '10m'
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 30s



  worker1:
    image: datatitian/guppe
    command: [ "node", "deliveryWorker.js" ]
    deploy:
      mode: replicated
      replicas: 50
      placement:
        constraints:
          - "node.labels.type==web"
    restart: always
    env_file: '.env'
    environment:
      DB_URL: 'mongodb://mongodb:27017'
    depends_on:
      - mongodb
    logging:
      driver: local
      options:
        max-size: '10m'

  mongodb:
    image: mongo:4.2
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - "node.labels.type==database"
    restart: always
    volumes:
      - mongo-data:/data/db
    logging:
      driver: local
      options:
        max-size: '10m'

volumes:
  mongo-data:
  certs:
