version: "2.4"

networks:
  customer:

volumes:
  mongo-data:
  minio-data:

services:
  nginx-proxy:
    image: "registry.smashdocs.net/smashdocs/nginx:2.20.2"
    mem_limit: 256m
    user: root
    restart: always
    volumes:
      - "/opt/docker/ssl/certs:/etc/nginx/certs:ro"
    environment:
      - "SSL_CERT=wildcard.crt"
      - "SSL_KEY=wildcard.key"
    networks:
      - customer
    ports:
      - 80
      - 443
      - 4434

  frontend:
    image: "registry.smashdocs.net/smashdocs/frontend:2.20.2"
    mem_limit: 256m
    user: root
    restart: always
    networks:
      - customer
    environment:
      - "API_URL=https://customer.smashdocs.net/api"
      - "MODE=normal"

  adminui:
    image: "registry.smashdocs.net/smashdocs/admin-ui:2.20.2"
    mem_limit: 256m
    user: root
    restart: always
    networks:
      - demo
    environment:
      - "API_URL=https://customer.smashdocs.net/api"

  backend:
    image: "registry.smashdocs.net/smashdocs/backend:2.20.2"
    mem_limit: 5g
    user: root
    restart: always
    networks:
      - customer
    environment:
      - "DATABASE_DATABASE=customer"
      - "DATABASE_ADDRESS=mongodb://mongodb/customer"
      - "DATABASE_PORT=27017"
      - "API_URL_API_URL=https://customer.smashdocs.net/api"
      - "HTTP_SERVER_ADDRESS=http://customer.smashdocs.net"
      - "HTTP_SERVER_SSL_ADDRESS=https://customer.smashdocs.net"
      - "CELERY_ENABLED=true"
      - "CELERY_BROKER=redis://redis:6379/0"
      - "CELERY_BACKEND=redis://redis:6379/0"
      - "MINIO_ACCESS_KEY=<MINIO_ACCESS_KEY>"
      - "MINIO_SECRET_KEY=<MINIO_SECRET_KEY>"
      - "REDIS_ADDRESS=redis"
      - "REDIS_PORT=6379"
      - "PROVISIONING_ENABLED=true"
      - "PROVISIONING_KEY=<PROVISIONING_KEY>"
      - "SYSTEM_ROLE=production"
      - "TRANSFORM_SERVICE_ADDRESS=transform-service:50051"
    depends_on:
      - minio
      - nginx-proxy
      - mongodb
      - redis

  socketserver:
    image: "registry.smashdocs.net/smashdocs/socketserver:2.20.2"
    mem_limit: 1g
    user: nobody
    restart: always
    networks:
      - customer
    environment:
      - "SM_SPC_SIO_REDIS_BUS=redis://redis:6379/0"
      - "SM_SIO_BE_AUTH_URL=http://backend:8080/users/document-authenticate"
    depends_on:
      - redis
      - backend

  beat:
    image: "registry.smashdocs.net/smashdocs/backend:2.20.2"
    mem_limit: 512m
    user: nobody
    restart: always
    networks:
      - customer
    command: "beat"
    environment:
      - "CELERY_ENABLED=true"
      - "CELERY_BROKER=redis://redis:6379/0"
      - "CELERY_BACKEND=redis://redis:6379/0"
      - "CELERY_BEAT_SCHEDULE_PATH=/usr/local/data/celery/smashdocs_beat_schedule"
    depends_on:
      - redis

  worker:
    image: "registry.smashdocs.net/smashdocs/backend:2.20.2"
    mem_limit: 512m
    user: nobody
    restart: always
    networks:
      - customer
    command: "worker"
    environment:
      - "DATABASE_DATABASE=customer"
      - "DATABASE_ADDRESS=mongodb://mongodb/customer"
      - "DATABASE_PORT=27017"
      - "API_URL_API_URL=https://customer.smashdocs.net/api"
      - "HTTP_SERVER_ADDRESS=http://customer.smashdocs.net"
      - "HTTP_SERVER_SSL_ADDRESS=https://customer.smashdocs.net"
      - "CELERY_ENABLED=true"
      - "CELERY_BROKER=redis://redis:6379/0"
      - "CELERY_BACKEND=redis://redis:6379/0"
      - "CELERY_BEAT_SCHEDULE_PATH=/usr/local/data/celery/smashdocs_beat_schedule"
      - "MINIO_ACCESS_KEY=<MINIO_ACCESS_KEY>"
      - "MINIO_SECRET_KEY=<MINIO_SECRET_KEY>"
      - "EMAIL_SMTP_SERVER_ADDRESS=<EMAIL_SMTP_SERVER_ADDRESS>"
      - "EMAIL_SMTP_SERVER_PORT=<EMAIL_SMTP_SERVER_PORT>"
      - "EMAIL_SMTP_USERNAME=<EMAIL_SMTP_USERNAME>"
      - "EMAIL_SMTP_PASSWORD=<EMAIL_SMTP_PASSWORD>"
    depends_on:
      - mongodb
      - redis

  redis:
    image: "redis:3.2"
    mem_limit: 512m
    user: redis
    restart: always
    networks:
      - customer

  mongodb:
    image: "mongo:3.6"
    mem_limit: 5g
    user: root
    restart: always
    networks:
      - customer
    ports:
      - 27017
    volumes:
      - "mongo-data:/data/db:rw"
    command: "--storageEngine wiredTiger"

  minio:
    image: minio/minio
    command: server /export
    restart: always
    volumes:
      - "minio-data:/export:rw"
    networks:
      - customer
    environment:
      - "MINIO_ACCESS_KEY=<MINIO_ACCESS_KEY>"
      - "MINIO_SECRET_KEY=<MINIO_SECRET_KEY>"

  transform-service:
    image: "registry.smashdocs.net/smashdocs/transform-service:2.20.2"
    mem_limit: 4g
    networks:
      - customer
    environment:
      - "JAVA_OPTS=-Xms256m -Xmx2048m"

  sdox2html-transform-service:
    image: "registry.smashdocs.net/smashdocs/sdox2html-transform-service:2.20.2"
    user: root
    restart: always
    networks:
      - customer
