From 3b2f81ab307ef214e105f5242087ddbbd671026c Mon Sep 17 00:00:00 2001 From: Drouin Amaury Date: Wed, 11 Apr 2018 11:15:45 +0200 Subject: [PATCH] Add cron to Dockerfile install. Change glpi-start.sh to add cron file to the right directory and start cron at start before apache2ctl --- Dockerfile | 3 +- docker-compose-test.yml | 21 ++++++++++++++ docker-compose.yml | 62 ++++++++++++++++++++++------------------- glpi-start.sh | 4 +-- 4 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 docker-compose-test.yml diff --git a/Dockerfile b/Dockerfile index 425755f..448f373 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,8 @@ php-gd \ php-mbstring \ php-xml \ php-apcu-bc \ -wget +wget \ +cron #Copie et execution du script pour l'installation et l'initialisation de GLPI COPY glpi-start.sh /opt/ diff --git a/docker-compose-test.yml b/docker-compose-test.yml new file mode 100644 index 0000000..311cdba --- /dev/null +++ b/docker-compose-test.yml @@ -0,0 +1,21 @@ +version: "2" + +services: + #GLPI Container + glpi: + build: ./ + image: myglpi + container_name : myglpi + ports: + - "9080:80" + links: + - mysql:mysql + restart: always + + #Mysql Container + mysql: + image: mysql + container_name: mysql + hostname: mysql + env_file: + - ./mysql.env \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 65aeeef..03d50e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,36 +1,40 @@ +version: "2" + +services: #Mysql Persitance Data -mysql-data: - image: busybox - container_name: mysql-data - volumes: - - /var/lib/mysql:/var/lib/mysql + mysql-data: + image: busybox + container_name: mysql-data + volumes: + - /var/lib/mysql:/var/lib/mysql #Mysql Container -mysql: - image: mysql - container_name: mysql - hostname: mysql - volumes_from: - - mysql-data - env_file: - - ./mysql.env + mysql: + image: mysql + container_name: mysql + hostname: mysql + volumes_from: + - mysql-data + env_file: + - ./mysql.env #GLPI Pesitance Data -glpi-data: - image: busybox - container_name: glpi-data - volumes: - - /var/www/html/glpi:/var/www/html/glpi + glpi-data: + image: busybox + container_name: glpi-data + volumes: + - /var/www/html/glpi:/var/www/html/glpi #GLPI Container -glpi: - image: diouxx/glpi - container_name : glpi - hostname: glpi - ports: - - "80:80" - links: - - mysql:mysql - volumes_from: - - glpi-data - restart: always + glpi: + build: ./ + image: myglpi + container_name : myglpi + hostname: glpi + ports: + - "80:80" + links: + - mysql:mysql + volumes_from: + - glpi-data + restart: always diff --git a/glpi-start.sh b/glpi-start.sh index fea3a22..e293c49 100644 --- a/glpi-start.sh +++ b/glpi-start.sh @@ -31,10 +31,10 @@ fi echo -e "\n\tDocumentRoot /var/www/html/glpi\n\n\t\n\t\tAllowOverride All\n\t\tOrder Allow,Deny\n\t\tAllow from all\n\t\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n" > /etc/apache2/sites-available/000-default.conf #Add scheduled task by cron -echo "*/5 * * * * /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron +echo "*/5 * * * * root /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpicron #Activation du module rewrite d'apache a2enmod rewrite && service apache2 restart && service apache2 stop #Lancement du service apache au premier plan -/usr/sbin/apache2ctl -D FOREGROUND +cron -f & /usr/sbin/apache2ctl -D FOREGROUND