services:

  rap-reports-nginx:
    container_name: rap-reports-nginx
    image: nginx:1.18-alpine
    depends_on:
      - rap-reports-nextjs
    ports:
      - 8189
      - 81
    environment:
      - SERVER_PORT=8189
      - VIRTUAL_HOST=rap-reports.centralproductsystem.com
      - VIRTUAL_PORT=8189
    volumes:
      - ../../:/var/www
      - ./config/status.conf:/etc/nginx/conf.d/status.conf
      - ./config/production.nginx.conf:/etc/nginx/conf.d/production.conf
      - /mnt/production/media:/var/www/media
      - /mnt/production/pub/sitemap:/var/www/sitemap
      - /mnt/nginx/certs/cloudflare.crt:/etc/nginx/ssl/dev.runautoparts.com.au.crt:ro
      - /mnt/nginx/certs/cloudflare.key:/etc/nginx/ssl/dev.runautoparts.com.au.key:ro
    networks:
      - runautoparts_production_network
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: '1g'
    labels:
      com.datadoghq.ad.check_names: '["nginx"]'
      com.datadoghq.ad.init_configs: '[{}]'
      com.datadoghq.ad.instances: |
        [
          {
            "nginx_status_url": "http://%%host%%:81/nginx_status"
          }
        ]

  rap-reports-nextjs:
    container_name: rap-reports-nextjs
    build: ../common/nextjs/.
    working_dir: "/var/www/src"
    volumes:
      - ../../:/var/www/src
    ports:
      - 3000
    networks:
      - runautoparts_production_network
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: '2g'

networks:
  runautoparts_production_network:
    external: true
