From 3b2f81ab307ef214e105f5242087ddbbd671026c Mon Sep 17 00:00:00 2001 From: Drouin Amaury Date: Wed, 11 Apr 2018 11:15:45 +0200 Subject: [PATCH 1/4] 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 From c59a35788d1a3ac4837ff1e51dfd5abfc1569e3e Mon Sep 17 00:00:00 2001 From: Drouin Amaury Date: Wed, 11 Apr 2018 11:28:49 +0200 Subject: [PATCH 2/4] Try to fix timezone in apache2 / php --- docker-compose-test.yml | 5 +++++ timezone.ini | 1 + 2 files changed, 6 insertions(+) create mode 100644 timezone.ini diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 311cdba..a031812 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -11,6 +11,11 @@ services: links: - mysql:mysql restart: always + volumes: + - "./timezone.ini:/etc/php/7.0/cli/php.ini" + - "./timezone.ini:/etc/php/7.0/apache2/php.ini" + - "/etc/timezone:/etc/timezone" + - "/etc/localtime:/etc/localtime" #Mysql Container mysql: diff --git a/timezone.ini b/timezone.ini new file mode 100644 index 0000000..36e4ffc --- /dev/null +++ b/timezone.ini @@ -0,0 +1 @@ +Europe/Paris \ No newline at end of file From d88216d49833b51eb4d8c938a071299b5cae83fb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Apr 2018 14:09:54 +0200 Subject: [PATCH 3/4] Fix timezone where somtimes apache / php timezone differ from container timezone --- docker-compose-test.yml | 6 +++--- glpi-start.sh | 4 ++++ timezone.ini | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docker-compose-test.yml b/docker-compose-test.yml index a031812..2d7d474 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -12,10 +12,10 @@ services: - mysql:mysql restart: always volumes: - - "./timezone.ini:/etc/php/7.0/cli/php.ini" - - "./timezone.ini:/etc/php/7.0/apache2/php.ini" - "/etc/timezone:/etc/timezone" - "/etc/localtime:/etc/localtime" + environment: + TIMEZONE: Europe/Paris #Mysql Container mysql: @@ -23,4 +23,4 @@ services: container_name: mysql hostname: mysql env_file: - - ./mysql.env \ No newline at end of file + - ./mysql.env diff --git a/glpi-start.sh b/glpi-start.sh index e293c49..7b9150e 100644 --- a/glpi-start.sh +++ b/glpi-start.sh @@ -4,6 +4,10 @@ [[ ! "$VERSION_GLPI" ]] \ && VERSION_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) +if [[ -z "${TIMEZONE}" ]]; then echo "TIMEZONE is unset"; +else echo "date.timezone = \"$TIMEZONE\"" > /etc/php/7.0/apache2/conf.d/timezone.ini; +fi + SRC_GLPI="https://github.com/glpi-project/glpi/releases/download/${VERSION_GLPI}/glpi-${VERSION_GLPI}.tgz" TAR_GLPI=glpi-${VERSION_GLPI}.tgz FOLDER_GLPI=glpi/ diff --git a/timezone.ini b/timezone.ini index 36e4ffc..abe8f0b 100644 --- a/timezone.ini +++ b/timezone.ini @@ -1 +1 @@ -Europe/Paris \ No newline at end of file +date.timezone = "Europe/Paris" From c5a337fe5620606c27648cc459dc26dbb8735be7 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Apr 2018 14:20:29 +0200 Subject: [PATCH 4/4] Remove leftover timezone.ini file --- timezone.ini | 1 - 1 file changed, 1 deletion(-) delete mode 100644 timezone.ini diff --git a/timezone.ini b/timezone.ini deleted file mode 100644 index abe8f0b..0000000 --- a/timezone.ini +++ /dev/null @@ -1 +0,0 @@ -date.timezone = "Europe/Paris"