version: '3.8'
services:

  workflow:
    image: ${BASE_REGISTRY_URL}/workflow:${TAG}
    build:
      context: .
      dockerfile: ./services/workflow/Dockerfile
      target: prod
      args:
        - BASE_REGISTRY_URL=${BASE_REGISTRY_URL}
        - CACHE_IMAGE_TAG=${CACHE_IMAGE_TAG}
        - WS_VERSION=${WS_VERSION}
        - LOCAL_OR_SERVER_PEX="server-pex"
    ports:
      - "3458:3458"
    networks:
      - host
    deploy:
      placement:
        constraints:
          - "node.labels.node_env==${ENV}"
      restart_policy:
        condition: on-failure
        max_attempts: 3
        window: 5s
      update_config:
        parallelism: 2
        delay: 5s
        order: stop-first
        failure_action: rollback
      rollback_config:
        parallelism: 0
        order: stop-first
    volumes:
      - /lustre/aoc/cluster/pipeline/dsoc-${ENV}/downloads/nrao:/lustre/aoc/cluster/pipeline/dsoc-${ENV}/downloads/nrao
      - /lustre/aoc/cluster/pipeline/dsoc-${ENV}/workspaces:/lustre/aoc/cluster/pipeline/dsoc-${ENV}/workspaces
      - /lustre/aoc/cluster/pipeline/vlass_${ENV}:/lustre/aoc/cluster/pipeline/vlass_${ENV}
      - /home/ssa/bin/python3.10:/home/ssa/bin/python3.10
      - /home/casa/capo:/home/casa/capo
      - /users/vlapipe/.ssh:/home/vlapipe/.ssh
      - /root/ws-condor/tokens.d:/etc/condor/tokens.d
      - condor:/var/spool/condor

  capability:
    image: ${BASE_REGISTRY_URL}/capability:${TAG}
    build:
      context: .
      dockerfile: ./services/capability/Dockerfile
      target: prod
      args:
        - BASE_REGISTRY_URL=${BASE_REGISTRY_URL}
        - CACHE_IMAGE_TAG=${CACHE_IMAGE_TAG}
        - WS_VERSION=${WS_VERSION}
    ports:
      - target: 3457
        published: 3457
        protocol: tcp
        mode: host
    volumes:
      - /home/casa/capo:/home/casa/capo
    deploy:
      placement:
        constraints:
          - "node.labels.node_env==${ENV}"
      restart_policy:
        condition: on-failure
        delay: 5s
        window: 5s
      update_config:
        parallelism: 2
        delay: 5s
        order: stop-first
        failure_action: rollback
      rollback_config:
        parallelism: 0
        order: stop-first

  notification:
    image: ${BASE_REGISTRY_URL}/notification:${TAG}
    build:
      context: .
      dockerfile: ./services/notification/Dockerfile
      target: prod
      args:
        - BASE_REGISTRY_URL=${BASE_REGISTRY_URL}
        - CACHE_IMAGE_TAG=${CACHE_IMAGE_TAG}
        - WS_VERSION=${WS_VERSION}
    ports:
      - "3458:3458"
    networks:
      - host
    volumes:
      - /home/casa/capo:/home/casa/capo
    deploy:
      placement:
        constraints:
          - "node.labels.node_env==${ENV}"
      restart_policy:
        condition: on-failure
        max_attempts: 3
        window: 5s
      update_config:
        parallelism: 2
        delay: 5s
        order: stop-first
        failure_action: rollback
      rollback_config:
        parallelism: 0
        order: stop-first

  web:
    image: ${BASE_REGISTRY_URL}/web:${TAG}
    build:
      context: .
      dockerfile: ./apps/web/Dockerfile
      target: prod
      args:
        - BASE_REGISTRY_URL=${BASE_REGISTRY_URL}
        - WS_VERSION=${WS_VERSION}
    ports:
      - target: 80
        published: 4444
        protocol: tcp
        mode: host
    deploy:
      placement:
        constraints:
          - "node.labels.node_env==${ENV}"
      restart_policy:
        condition: on-failure
        max_attempts: 3
        window: 5s
      update_config:
        parallelism: 2
        delay: 5s
        order: stop-first
        failure_action: rollback
      rollback_config:
        parallelism: 0
        order: stop-first

networks:
  host:
    external: true
    name: host

volumes:
  condor:
