version: '3.7'
services:
  main:
    image: registry.verdnatura.es/hedera-web:${BRANCH_NAME:?}
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - VERSION=${VERSION:?}
    ports:
      - 80
    configs:
      - source: config
        target: /etc/hedera-web/config.my.php
    volumes:
      - /mnt/appdata:/mnt/storage
      - /mnt/appdata/image:/var/lib/hedera-web/image-db
      - /mnt/appdata/vn-access:/var/lib/hedera-web/vn-access
    deploy:
      replicas: ${MAIN_REPLICAS:?}
      placement:
        constraints:
          - node.role == worker
  cron:
    image: registry.verdnatura.es/hedera-web:${BRANCH_NAME:?}
    command: 'cron -f'
    configs:
      - source: config
        target: /etc/hedera-web/config.my.php
    volumes:
      - /mnt/appdata:/mnt/storage
      - /mnt/appdata/image:/var/lib/hedera-web/image-db
    deploy:
      replicas: ${CRON_REPLICAS:?}
      placement:
        constraints:
          - node.role == worker
configs:
  config:
    external: true
    name: ${PROJECT_NAME:?}-${BRANCH_NAME:?}