services:
  frontend:
    image: ghcr.io/shuffle/shuffle-frontend:latest
    container_name: shuffle-frontend
    hostname: shuffle-frontend
    ports:
      - "${FRONTEND_PORT}:80"
      - "${FRONTEND_PORT_HTTPS}:443"
    networks:
      - shuffle
    environment:
      - BACKEND_HOSTNAME=${BACKEND_HOSTNAME}
    restart: unless-stopped
    depends_on:
      - backend
  backend:
    image: ghcr.io/shuffle/shuffle-backend:latest
    container_name: shuffle-backend
    hostname: ${BACKEND_HOSTNAME}
    # Here for debugging:
    ports:
      - "${BACKEND_PORT}:5001"
    networks:
      - shuffle
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${SHUFFLE_APP_HOTLOAD_LOCATION}:/shuffle-apps:z
      - ${SHUFFLE_FILE_LOCATION}:/shuffle-files:z
    env_file: .env
    environment:
      #- DOCKER_HOST=tcp://docker-socket-proxy:2375
      - SHUFFLE_APP_HOTLOAD_FOLDER=/shuffle-apps
      - SHUFFLE_FILE_LOCATION=/shuffle-files
    restart: unless-stopped
  orborus:
    image: ghcr.io/shuffle/shuffle-orborus:latest
    container_name: shuffle-orborus
    hostname: shuffle-orborus
    networks:
      - shuffle
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - SHUFFLE_APP_SDK_TIMEOUT=300
      - ENVIRONMENT_NAME=Shuffle
      - ORG_ID=Shuffle
      - BASE_URL=http://${OUTER_HOSTNAME}:5001
      - DOCKER_API_VERSION=${DOCKER_API_VERSION:-1.44}
      - HTTP_PROXY=${HTTP_PROXY}
      - HTTPS_PROXY=${HTTPS_PROXY}
      - SHUFFLE_PASS_WORKER_PROXY=${SHUFFLE_PASS_WORKER_PROXY}
      - SHUFFLE_PASS_APP_PROXY=${SHUFFLE_PASS_APP_PROXY}
      - SHUFFLE_SKIP_PIPELINES=${SHUFFLE_SKIP_PIPELINES:-true}
      - SHUFFLE_PIPELINE_ENABLED=${SHUFFLE_PIPELINE_ENABLED:-false}
      # - SHUFFLE_APP_REPLICAS=${SHUFFLE_APP_REPLICAS}
      - SHUFFLE_STATS_DISABLED=true
      - SHUFFLE_LOGS_DISABLED=true
      - SHUFFLE_SWARM_CONFIG=run
      - CLEANUP=false
      - SHUFFLE_WORKER_IMAGE=ghcr.io/shuffle/shuffle-worker:latest
    env_file: .env
    restart: unless-stopped
    security_opt:
      - seccomp:unconfined
  opensearch:
    image: opensearchproject/opensearch:3.2.0
    hostname: shuffle-opensearch
    container_name: shuffle-opensearch
    environment:
      - "OPENSEARCH_JAVA_OPTS=${SHUFFLE_OPENSEARCH_JAVA_OPTS:--Xms1024m -Xmx1024m}" # override in .env for larger hosts
      - bootstrap.memory_lock=true
      - DISABLE_PERFORMANCE_ANALYZER_AGENT_CLI=true
      - cluster.initial_master_nodes=shuffle-opensearch
      - cluster.routing.allocation.disk.threshold_enabled=false
      - cluster.name=shuffle-cluster
      - node.name=shuffle-opensearch
      - node.store.allow_mmap=false
      - discovery.seed_hosts=shuffle-opensearch
      - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${SHUFFLE_OPENSEARCH_PASSWORD}
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - shuffle-database:/usr/share/opensearch/data:z
    ports:
      - "${SHUFFLE_OPENSEARCH_PORT:-9200}:9200"
    networks:
      - shuffle
    restart: unless-stopped

  # OPTIONAL: advanced monitoring with cAdvisor
  # If you have a seperate orborus config YAML on another server,
  # Please add it there as well if you want to monitor that server too.
  # FYI: both servers will show up on different dashboards.
  # cadvisor:
  #   image: gcr.io/cadvisor/cadvisor:latest
  #   volumes:
  #     - /:/rootfs:ro
  #     - /var/run:/var/run:ro
  #     - /sys:/sys:ro
  #     - /var/lib/docker/:/var/lib/docker:ro
  #     - /dev/disk/:/dev/disk:ro
  #     - /var/run/docker.sock:/var/run/docker.sock:ro
  #   ports:
  #     - "8080:8080"
  #   privileged: true
  #   devices:
  #     - /dev/kmsg:/dev/kmsg
  #   networks:
  #     - shuffle

  #memcached:
  #  image: memcached:latest
  #  container_name: shuffle-cache
  #  hostname: shuffle-cache
  #  command: memcached -m 2048 -c 2500
  #  environment:
  #    - MEMCACHED_MEMORY=2048
  #    - MEMCACHED_MAX_CONNECTIONS=2500
  #  ports:
  #    - 11211:11211
  #  networks:
  #  -  shuffle
  #  -  swarm_executions

  #docker-socket-proxy:
  #  image: tecnativa/docker-socket-proxy
  #  container_name: docker-socket-proxy
  #  hostname: docker-socket-proxy
  #  privileged: true
  #  environment:
  #    - SERVICES=1
  #    - TASKS=1
  #    - NETWORKS=1
  #    - NODES=1
  #    - BUILD=1
  #    - IMAGES=1
  #    - GRPC=1
  #    - CONTAINERS=1
  #    - PLUGINS=1
  #    - SYSTEM=1
  #    - VOLUMES=1
  #    - INFO=1
  #    - DISTRIBUTION=1
  #    - POST=1
  #    - AUTH=1
  #    - SECRETS=1
  #    - SWARM=1
  #  volumes:
  #    - /var/run/docker.sock:/var/run/docker.sock
  #  networks:
  #    - shuffle
  #

volumes:
  shuffle-database:
    driver: local
    driver_opts:
      type: none
      device: ${DB_LOCATION}
      o: bind

networks:
  shuffle:
    driver: bridge
    # driver_opts:
    #   com.docker.network.driver.mtu: 1460
    # uncomment to set MTU for swarm mode. MTU should be whatever is your host's preferred MTU is: https://shuffler.io/docs/troubleshooting#TLS_timeout_error/Timeout_Errors/EOF_Errors
