version: '3'

services:

  #Serveur WEB Administration
  administration:
    image: ad-system-administration:0.0.1
    restart: always
    env_file:
      - stack.env
    volumes:
      - /root/ad-system-0.0.2:/var/www/html
      - /root/data/${CONTAINER_NAME}:/var/www/data/${CONTAINER_NAME}
      - /root/data/plugin:/var/www/data/plugin
      - /root/data/conf/php.ini:/usr/local/etc/php/php.ini
      - /var/log/openvpn/status.log:/var/log/openvpn/status.log
      - /root/data/conf/serveur-web-administration/000-default.conf:/etc/apache2/sites-available/000-default.conf
      - /root/data/conf/serveur-web-administration/ports.conf:/etc/apache2/ports.conf
    network_mode: "service:openvpn"

  server_tv:
    image: ad-system-server-tv:0.0.1
    restart: always
    env_file:
      - stack.env
    volumes:
      - /root/ad-system-0.0.2:/var/www/html
      - /root/data/${CONTAINER_NAME}:/var/www/data/${CONTAINER_NAME}
      - /root/data/plugin:/var/www/data/plugin
      - /root/data/${CONTAINER_NAME}/vpn/log/openvpn-status.log:/var/log/openvpn/status.log
      - /root/data/${CONTAINER_NAME}/temp:/var/www/html/tv/temp
    command: ["sh", "-c", "sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/tv|g' /etc/apache2/sites-available/000-default.conf && apache2-foreground"]
    network_mode: "service:openvpn"

  openvpn:
    cap_add:
     - NET_ADMIN
    image: kylemanna/openvpn
    ports:
     - "1001:1194/tcp" #Serveur VPN
     - "1000:8081/tcp" #Serveur Administration
    restart: always
    volumes:
     - /root/data/${CONTAINER_NAME}/vpn:/etc/openvpn
     - /root/data/${CONTAINER_NAME}/vpn/log:/tmp
    networks:
      - sql_database
  
networks:
  sql_database:
    external: true