version: '3.9'
services:
  nginx:
    image: {{ pvgnginx.imageName }}:{{ ansTagVer }}
    ports:
      - 80:80
    environment:
      NGINX_HOST: php-fpm
    volumes:
      - type: volume
        source: nfs_html
        target: /usr/share/nginx/html
        volume:
          nocopy: true
      - type: volume
        source: nfs_conf
        target: /etc/nginx
        volume:
          nocopy: true
    deploy:
      mode: global
      placement:
        constraints:
          - node.labels.appdemo != false
      update_config:
        parallelism: 1
        delay: 10s
      resources:
        limits:
          cpus: '0.4'
          memory: 100M
        reservations:
          cpus: '0.2'
          memory: 50M
    depends_on:
      - php-fpm
    networks:
      - lnmp-demo

  php-fpm:
    image: {{ pvgphpfpm.imageName }}:{{ ansTagVer }}
    ports:
      - 9000:9000
    volumes:
#      - type: volume
#        source: php_html
#        target: /var/www/html
#        volume:
#          nocopy: true
      - type: volume
        source: php_conf
        target: /usr/local/etc
        volume:
          nocopy: true
    networks:
       - lnmp-demo
    deploy:
      mode: global
      placement:
        constraints:
          - node.labels.appdemo != false
      resources:
        limits:
          cpus: '0.8'
          memory: 100M
        reservations:
          cpus: '0.5'
          memory: 50M

volumes:
  nfs_html:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=192.168.11.121,vers=4,soft,timeo=180,bg,tcp,rw"
      device: "192.168.11.121:/nginxhtml"
  nfs_conf:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=192.168.11.121,vers=4,soft,timeo=180,bg,tcp,rw"
      device: "192.168.11.121:/nginxconf"
#  php_html:
#    driver: local
#    driver_opts:
#      type: "nfs"
#      o: "addr=192.168.11.121,vers=4,soft,timeo=180,bg,tcp,rw"
#      device: "192.168.11.121:/phphtml"
  php_conf:
    driver: local
    driver_opts:
      type: "nfs"
      o: "addr=192.168.11.121,vers=4,soft,timeo=180,bg,tcp,rw"
      device: "192.168.11.121:/phpconf"

networks:
  lnmp-demo:
    driver: overlay

