version: '3.8'
services:

  workflow:
    image: ssa-containers.aoc.nrao.edu/workspaces/workflow:${TAG}
    networks:
      - host
    secrets:
      - source: dsoc_${ENV}_secrets
        target: dsoc-${ENV}.properties
      - source: naasc_${ENV}_secrets
        target: naasc-${ENV}.properties
    environment:
      CAPO_PATH: /run/secrets
      CAPO_PROFILE: dsoc-${ENV}
    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.8:/home/ssa/bin/python3.8
      - /home/casa/capo:/home/casa/capo

  capability:
    image: ssa-containers.aoc.nrao.edu/workspaces/capability:${TAG}
    ports:
      - target: 3457
        published: 3457
        protocol: tcp
        mode: host
    secrets:
      - source: dsoc_${ENV}_secrets
        target: dsoc-${ENV}.properties
    environment:
      CAPO_PATH: /run/secrets
      CAPO_PROFILE: dsoc-${ENV}
    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

  notification:
    image: ssa-containers.aoc.nrao.edu/workspaces/notification:${TAG}
    networks:
      - host
    secrets:
      - source: dsoc_${ENV}_secrets
        target: dsoc-${ENV}.properties
    environment:
      CAPO_PATH: /run/secrets
      CAPO_PROFILE: dsoc-${ENV}
    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: ssa-containers.aoc.nrao.edu/workspaces/web:${TAG}
    ports:
      - target: 80
        published: 4444
        protocol: tcp
        mode: host
    environment:
      DL_HOST: ${DL_HOST}
      ENV_HOST: ${ENV_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


secrets:
  dsoc_ENV_secrets:
    external: true
  naasc_ENV_secrets:
    external: true

networks:
  host:
    external: true
    name: host
