---
version: '3.8'

services:
  api:
    privileged: true
    build:
      context: .
      dockerfile: ./Dockerfile
      network: host
    image: docaposte/ubuntu20-apache2-php8:1.0.0
    environment:
      - TZ=Europe/Paris
    ports:
      - '8800:80'
      - '8880:443'
    container_name: API-AES
    hostname: api-aes-local.demat.lan
    restart: unless-stopped
    expose:
      - 80
      - 443
    volumes:
      - apidata:/data:rw
      #- nfs-upload:/mnt/nfs-upload
      - ./:/data/sites/api
      - ./config/apache/api.conf:/etc/apache2/sites-available/api.conf
      - ./config/apache/apache2.conf:/etc/apache2/apache2.conf
      - ./config/apache/php.ini:/etc/php.ini
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
      - .:/app:cached
    tty: true
    tmpfs:
      - /run
      - /run/lock
      - /tmp
    extra_hosts:
      - "upload-bundle-local.demat.lan:172.22.0.1"
    networks:
      nginx-proxy:
        ipv4_address: 172.22.0.23
    command: ["sh", "-c", "
        /usr/sbin/init;
        /usr/bin/redis-server /etc/redis/redis.conf --daemonize yes;
        /usr/bin/supervisord -c /etc/supervisor/supervisord.conf;
        /usr/sbin/usermod -s /bin/bash www-data;
        /usr/bin/mv -f /etc/php/8.2/apache2/conf.d/20-xdebug.ini /etc/php/8.2/apache2/conf.d/20-xdebug.ini.disable;
        /usr/bin/chown -R www-data:www-data /data/sites;
        /usr/bin/chmod -R 777 /data/sites/api/var;
        /usr/bin/chmod -R 777 /data/logs;
        export APACHE_LOG_DIR=/data/logs;
        /usr/sbin/a2enmod rewrite;
        /usr/sbin/a2ensite api;
        /usr/sbin/a2dissite 000-default;
        /usr/sbin/service apache2 reload;
        /usr/bin/mongod -f /etc/mongod.conf --bind_ip 127.0.0.1 --fork;
        /etc/init.d/clamav-daemon restart;
        /usr/sbin/service apache2 restart;
        /bin/bash;
      "]

volumes:
  apidata:
    driver: local
  #nfs-upload: ## Le nom de mon volume en montage NFS
  #  driver: local
  #  driver_opts: ## Définition des options du montage
  #    type: nfs ## Choix du type de montage
  #    o: addr=172.22.0.20,nolock,soft,rw ## Indication de l'adresse IP du stockage et des options d'accès
  #    device: :/data/upload/   ## Indication du chemin du montage sur le stockage
networks:
  nginx-proxy:
    name: nginx-proxy
    external: true
