version: '3.2'

services:
  db:
    image: gitlab.biig.fr:4567/french-american-foundation/frenchamerican-fr/mariadb:latest
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=frenchamericanfr
      - MYSQL_USER=frenchamericanfr
      - MYSQL_PASSWORD=frenchamericanfr
    networks:
      - default
    deploy:
      placement:
        constraints: [node.role == manager]

  front:
    image: gitlab.biig.fr:4567/french-american-foundation/frenchamerican-fr/front:latest
    env_file: .env.staging
    expose:
        - "8080"
    working_dir: /var/www/vhost/
    volumes:
        - ./:/var/www/vhost
        - ./docker/nginx/vhost.conf:/etc/nginx/sites-enabled/default:ro
    depends_on:
        - php-fpm
    networks:
        - exposed_world2
        - default
    deploy:
      mode: replicated
      replicas: 1
      labels:
          - "traefik.backend=backend_host_front_name"
          - "traefik.frontend.rule=Host:host_front"
          - "traefik.enable=true"
          - "traefik.port=8080"
          - "traefik.docker.network=exposed_world2"
      placement:
        constraints: [node.role == manager]

  php-fpm:
    image: gitlab.biig.fr:4567/french-american-foundation/frenchamerican-fr/php-fpm:latest
    entrypoint: /docker-entrypoint.sh
    env_file: .env.staging
    working_dir: /var/www/vhost/
    volumes:
      - ./:/var/www/vhost
    networks:
      - default
    depends_on:
      - db
    deploy:
      placement:
        constraints: [node.role == manager]

networks:
  default:
    driver: overlay
    attachable: true
    driver_opts:
      encrypted: "true"
  exposed_world2:
    external: true
