From facd74bc7b7dd8dccd78ab9dce8feb127f3679b3 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 10:27:16 +0100 Subject: [PATCH 01/43] Create main.yml --- .github/workflows/main.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..1c7b139a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,21 @@ +name: Docker GLPI Build + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: docker login + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + docker login -u $DOCKER_USER -p $DOCKER_PASSWORD + - name: docker build glpi + run: | + docker build . -t aguyonnet/glpi-test:1.0.0 + - name: docker push + run: | + docker push aguyonnet/glpi-test:1.0.0 From f8f3ddb39db5ae1ce5afe68ff54eaf30ffcbf1fe Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 10:38:05 +0100 Subject: [PATCH 02/43] Update docker-compose.yml --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d620157d..0de5d304 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ -version: "3.2" +version: "3.5" services: #Mysql Container mysql: - image: mysql:5.7.23 - container_name: mysql + image: mariadb + container_name: glpi-mariadb hostname: mysql volumes: - /var/lib/mysql:/var/lib/mysql @@ -14,7 +14,7 @@ services: #GLPI Container glpi: - image: diouxx/glpi + image: aguyonnet/glpi container_name : glpi hostname: glpi ports: @@ -24,5 +24,5 @@ services: - /etc/localtime:/etc/localtime:ro - /var/www/html/glpi/:/var/www/html/glpi environment: - - TIMEZONE=Europe/Brussels - restart: always \ No newline at end of file + - TIMEZONE=Europe/Paris + restart: always From a13a33662032b12bb81692d5b16872ec2610ef96 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 10:38:36 +0100 Subject: [PATCH 03/43] Update mysql.env --- mysql.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql.env b/mysql.env index 88629824..150572bf 100644 --- a/mysql.env +++ b/mysql.env @@ -1,4 +1,4 @@ -MYSQL_ROOT_PASSWORD=diouxx +MYSQL_ROOT_PASSWORD=CHANGEME MYSQL_DATABASE=glpidb MYSQL_USER=glpi_user -MYSQL_PASSWORD=glpi +MYSQL_PASSWORD=CHANGEME From 4031010d7cff4ba8147b480d78ccad1b94611b34 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 10:41:29 +0100 Subject: [PATCH 04/43] Update main.yml --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c7b139a..44abfd73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,7 @@ name: Docker GLPI Build -on: [push] +#on: [push] +on: [workflow_dispatch] jobs: build: From e80746e8f352c8c25f5a4bafc5f21491c1e50cb8 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 10:52:27 +0100 Subject: [PATCH 05/43] Update README.md --- README.md | 166 +----------------------------------------------------- 1 file changed, 1 insertion(+), 165 deletions(-) diff --git a/README.md b/README.md index b9894ac6..489d8401 100644 --- a/README.md +++ b/README.md @@ -1,165 +1 @@ -# Project to deploy GLPI with docker - -![Docker Pulls](https://img.shields.io/docker/pulls/diouxx/glpi) ![Docker Stars](https://img.shields.io/docker/stars/diouxx/glpi) [![](https://images.microbadger.com/badges/image/diouxx/glpi.svg)](http://microbadger.com/images/diouxx/glpi "Get your own image badge on microbadger.com") ![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/diouxx/glpi) - -# Table of Contents -- [Project to deploy GLPI with docker](#project-to-deploy-glpi-with-docker) -- [Table of Contents](#table-of-contents) -- [Introduction](#introduction) -- [Deploy with CLI](#deploy-with-cli) - - [Deploy GLPI](#deploy-glpi) - - [Deploy GLPI with existing database](#deploy-glpi-with-existing-database) - - [Deploy GLPI with database and persistence container data](#deploy-glpi-with-database-and-persistence-container-data) - - [Deploy a specific release of GLPI](#deploy-a-specific-release-of-glpi) -- [Deploy with docker-compose](#deploy-with-docker-compose) - - [Deploy without persistence data ( for quickly test )](#deploy-without-persistence-data--for-quickly-test) - - [Deploy with persistence data](#deploy-with-persistence-data) - - [mysql.env](#mysqlenv) - - [docker-compose .yml](#docker-compose-yml) -- [Environnment variables](#environnment-variables) - - [TIMEZONE](#timezone) - -# Introduction - -Install and run an GLPI instance with docker. - -# Deploy with CLI - -## Deploy GLPI -```sh -docker run --name mysql -e MYSQL_ROOT_PASSWORD=diouxx -e MYSQL_DATABASE=glpidb -e MYSQL_USER=glpi_user -e MYSQL_PASSWORD=glpi -d mysql:5.7.23 -docker run --name glpi --link mysql:mysql -p 80:80 -d diouxx/glpi -``` - -## Deploy GLPI with existing database -```sh -docker run --name glpi --link yourdatabase:mysql -p 80:80 -d diouxx/glpi -``` - -## Deploy GLPI with database and persistence data - -For an usage on production environnement or daily usage, it's recommanded to use container with volumes to persistent data. - -* First, create MySQL container with volume - -```sh -docker run --name mysql -e MYSQL_ROOT_PASSWORD=diouxx -e MYSQL_DATABASE=glpidb -e MYSQL_USER=glpi_user -e MYSQL_PASSWORD=glpi --volume /var/lib/mysql:/var/lib/mysql -d mysql:5.7.23 -``` - -* Then, create GLPI container with volume and link MySQL container - -```sh -docker run --name glpi --link mysql:mysql --volume /var/www/html/glpi:/var/www/html/glpi -p 80:80 -d diouxx/glpi -``` - -Enjoy :) - -## Deploy a specific release of GLPI -Default, docker run will use the latest release of GLPI. -For an usage on production environnement, it's recommanded to set specific release. -Here an example for release 9.1.6 : -```sh -docker run --name glpi --hostname glpi --link mysql:mysql --volume /var/www/html/glpi:/var/www/html/glpi -p 80:80 --env "VERSION_GLPI=9.1.6" -d diouxx/glpi -``` - -# Deploy with docker-compose - -## Deploy without persistence data ( for quickly test ) -```yaml -version: "3.2" - -services: -#Mysql Container - mysql: - image: mysql:5.7.23 - container_name: mysql - hostname: mysql - environment: - - MYSQL_ROOT_PASSWORD=password - - MYSQL_DATABASE=glpidb - - MYSQL_USER=glpi_user - - MYSQL_PASSWORD=glpi - -#GLPI Container - glpi: - image: diouxx/glpi - container_name : glpi - hostname: glpi - ports: - - "80:80" -``` - -## Deploy with persistence data - -To deploy with docker compose, you use *docker-compose.yml* and *mysql.env* file. -You can modify **_mysql.env_** to personalize settings like : - -* MySQL root password -* GLPI database -* GLPI user database -* GLPI user password - - -### mysql.env -``` -MYSQL_ROOT_PASSWORD=diouxx -MYSQL_DATABASE=glpidb -MYSQL_USER=glpi_user -MYSQL_PASSWORD=glpi -``` - -### docker-compose .yml -```yaml -version: "3.2" - -services: -#Mysql Container - mysql: - image: mysql:5.7.23 - container_name: mysql - hostname: mysql - volumes: - - /var/lib/mysql:/var/lib/mysql - env_file: - - ./mysql.env - restart: always - -#GLPI Container - glpi: - image: diouxx/glpi - container_name : glpi - hostname: glpi - ports: - - "80:80" - volumes: - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - - /var/www/html/glpi/:/var/www/html/glpi - environment: - - TIMEZONE=Europe/Brussels - restart: always -``` - -To deploy, just run the following command on the same directory as files - -```sh -docker-compose up -d -``` - -# Environnment variables - -## TIMEZONE -If you need to set timezone for Apache and PHP - -From commande line -```sh -docker run --name glpi --hostname glpi --link mysql:mysql --volumes-from glpi-data -p 80:80 --env "TIMEZONE=Europe/Brussels" -d diouxx/glpi -``` - -From docker-compose - -Modify this settings -```yaml -environment: - TIMEZONE=Europe/Brussels -``` +GLPI From 2d59669275e682f0d351ef23e4299a7aeed8e6da Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:10:05 +0100 Subject: [PATCH 06/43] Update README.md --- README.md | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 489d8401..818c4e4d 100644 --- a/README.md +++ b/README.md @@ -1 +1,116 @@ -GLPI +# Project to deploy GLPI with docker + +![Docker Pulls](https://img.shields.io/docker/pulls/aguyonnet/glpi) ![Docker Stars](https://img.shields.io/docker/stars/aguyonnet/glpi) +# Introduction + +Install and run an GLPI instance with docker. + +## Deploy a specific release of GLPI +Default, docker run will use the latest release of GLPI. +For an usage on production environnement, it's recommanded to set specific release. +Here an example for release 9.1.6 : +```sh +docker run --name glpi -p 80:80 --env "VERSION_GLPI=9.1.6" -d aguyonnet/glpi +``` + +# Deploy with docker-compose + +## Deploy without persistence data ( for quickly test ) +```yaml +version: "3.2" + +services: +#mariadb Container + mariadb: + image: mariadb:latest + container_name: mariadb + hostname: mariadb + environment: + - mariadb_ROOT_PASSWORD=password + - mariadb_DATABASE=glpidb + - mariadb_USER=glpi_user + - mariadb_PASSWORD=glpi + +#GLPI Container + glpi: + image: aguyonnet/glpi + container_name : glpi + hostname: glpi + ports: + - "80:80" +``` + +## Deploy with persistence data + +To deploy with docker compose, you use *docker-compose.yml* and *mariadb.env* file. +You can modify **_mariadb.env_** to personalize settings like : + +* mariadb root password +* GLPI database +* GLPI user database +* GLPI user password + + +### mariadb.env +``` +mariadb_ROOT_PASSWORD=aguyonnet +mariadb_DATABASE=glpidb +mariadb_USER=glpi_user +mariadb_PASSWORD=glpi +``` + +### docker-compose .yml +```yaml +version: "3.2" + +services: +#mariadb Container + mariadb: + image: mariadb:latest + container_name: mariadb-glpi + hostname: mariadb + volumes: + - /var/lib/mysql:/var/lib/mysql + env_file: + - ./mariadb.env + restart: always + +#GLPI Container + glpi: + image: aguyonnet/glpi + container_name : glpi + hostname: glpi + ports: + - "80:80" + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + - /var/www/html/glpi/:/var/www/html/glpi + environment: + - TIMEZONE=Europe/Paris + restart: always +``` + +To deploy, just run the following command on the same directory as files + +```sh +docker-compose up -d +``` + +# Environnment variables + +## TIMEZONE +If you need to set timezone for Apache and PHP + +From commande line +```sh +docker run --name glpi -p 80:80 --env "TIMEZONE=Europe/Paris" -d aguyonnet/glpi +``` + +From docker-compose + +Modify this settings +```yaml +environment: + TIMEZONE=Europe/Paris +``` From 373f2d913e260429260ee282b009e13f346d4d30 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:10:40 +0100 Subject: [PATCH 07/43] Rename mysql.env to mariadb.env --- mysql.env => mariadb.env | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename mysql.env => mariadb.env (100%) diff --git a/mysql.env b/mariadb.env similarity index 100% rename from mysql.env rename to mariadb.env From 298f475989c514f8cd5ad0577c703609044547a1 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:12:22 +0100 Subject: [PATCH 08/43] Rename main.yml to docker.yml --- .github/workflows/{main.yml => docker.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{main.yml => docker.yml} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/docker.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/docker.yml From 64e91f087f705cdd8efdc5af53f79e48a320544e Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:13:17 +0100 Subject: [PATCH 09/43] Update docker-compose.yml --- docker-compose.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0de5d304..d2c7a0d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,15 @@ -version: "3.5" +version: "3.2" services: -#Mysql Container - mysql: - image: mariadb - container_name: glpi-mariadb - hostname: mysql +#mariadb Container + mariadb: + image: mariadb:latest + container_name: mariadb-glpi + hostname: mariadb volumes: - /var/lib/mysql:/var/lib/mysql env_file: - - ./mysql.env + - ./mariadb.env restart: always #GLPI Container From f11f4853b4d545734cf9ac975198b7bbf8ce5e60 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:14:57 +0100 Subject: [PATCH 10/43] Update docker.yml --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 44abfd73..1113401f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: docker build glpi run: | - docker build . -t aguyonnet/glpi-test:1.0.0 + docker build . -t aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) - name: docker push run: | - docker push aguyonnet/glpi-test:1.0.0 + docker push aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) From 2198e8d8ff26297e19a7ca9bd8f141629ac24faf Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:23:00 +0100 Subject: [PATCH 11/43] Update docker.yml --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1113401f..f77389ea 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: docker build glpi run: | - docker build . -t aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) + docker build . -t aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi:latest - name: docker push run: | - docker push aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) + docker push aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) aguyonnet/glpi:latest From cd4d9a0ced693a41ee38ba8f3afd05ee26d4bdbf Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:24:09 +0100 Subject: [PATCH 12/43] Update docker.yml --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f77389ea..39ff72d3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,4 +19,4 @@ jobs: docker build . -t aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi:latest - name: docker push run: | - docker push aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) aguyonnet/glpi:latest + docker push aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) From 28d16da29c71d31230079ed6510a9589affd0bff Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:29:43 +0100 Subject: [PATCH 13/43] Create glpi-install.sh --- glpi-install.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 glpi-install.sh diff --git a/glpi-install.sh b/glpi-install.sh new file mode 100644 index 00000000..2fe74f20 --- /dev/null +++ b/glpi-install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +#Prise de la latest +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.3/apache2/conf.d/timezone.ini; +fi + +SRC_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/tags/${VERSION_GLPI} | jq .assets[0].browser_download_url | tr -d \") +TAR_GLPI=$(basename ${SRC_GLPI}) +FOLDER_GLPI=glpi/ +FOLDER_WEB=/var/www/html/ + +#check if TLS_REQCERT is present +if !(grep -q "TLS_REQCERT" /etc/ldap/ldap.conf) +then + echo "TLS_REQCERT isn't present" + echo -e "TLS_REQCERT\tnever" >> /etc/ldap/ldap.conf +fi + +#Téléchargement et extraction des sources de GLPI +if [ "$(ls ${FOLDER_WEB}${FOLDER_GLPI})" ]; +then + echo "GLPI is already installed" +else + wget -P ${FOLDER_WEB} ${SRC_GLPI} + tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB} + rm -Rf ${FOLDER_WEB}${TAR_GLPI} + chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} +fi + +#Modification du vhost par défaut +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 and enable +echo "*/2 * * * * www-data /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpi From 8498ed6777b32c0c55128cbfe34254786e1976a0 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:30:05 +0100 Subject: [PATCH 14/43] Update glpi-start.sh --- glpi-start.sh | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/glpi-start.sh b/glpi-start.sh index dd044cc5..7feb7fef 100644 --- a/glpi-start.sh +++ b/glpi-start.sh @@ -1,41 +1,5 @@ #!/bin/bash -#Controle du choix de version ou prise de la latest -[[ ! "$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.3/apache2/conf.d/timezone.ini; -fi - -SRC_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/tags/${VERSION_GLPI} | jq .assets[0].browser_download_url | tr -d \") -TAR_GLPI=$(basename ${SRC_GLPI}) -FOLDER_GLPI=glpi/ -FOLDER_WEB=/var/www/html/ - -#check if TLS_REQCERT is present -if !(grep -q "TLS_REQCERT" /etc/ldap/ldap.conf) -then - echo "TLS_REQCERT isn't present" - echo -e "TLS_REQCERT\tnever" >> /etc/ldap/ldap.conf -fi - -#Téléchargement et extraction des sources de GLPI -if [ "$(ls ${FOLDER_WEB}${FOLDER_GLPI})" ]; -then - echo "GLPI is already installed" -else - wget -P ${FOLDER_WEB} ${SRC_GLPI} - tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB} - rm -Rf ${FOLDER_WEB}${TAR_GLPI} - chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} -fi - -#Modification du vhost par défaut -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 and enable -echo "*/2 * * * * www-data /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpi #Start cron service service cron start From b15a758d90d2b4d1e9288eda31446bedb106f41d Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:33:21 +0100 Subject: [PATCH 15/43] Update Dockerfile --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0c37521e..5043077d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ #On choisit une debian -FROM debian:10.4 +FROM debian:latest -MAINTAINER DiouxX "github@diouxx.be" +MAINTAINER Aguyonnet "f.guyonantoine@gmail.com" #Ne pas poser de question à l'installation ENV DEBIAN_FRONTEND noninteractive @@ -32,9 +32,10 @@ jq \ && rm -rf /var/lib/apt/lists/* #Copie et execution du script pour l'installation et l'initialisation de GLPI -COPY glpi-start.sh /opt/ -RUN chmod +x /opt/glpi-start.sh +COPY glpi-start.sh glpi-install.sh /opt/ +RUN chmod +x /opt/glpi-start.sh /opt/glpi-install.sh +RUN sh /opt/glpi-install.sh ENTRYPOINT ["/opt/glpi-start.sh"] #Exposition des ports -EXPOSE 80 443 +EXPOSE 80 From bd8d9d6544b5a10babf44961b1f757342996e6ab Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:33:57 +0100 Subject: [PATCH 16/43] Update docker.yml --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 39ff72d3..64129f41 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: docker build glpi run: | - docker build . -t aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi:latest + docker build . -t aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi-test:latest - name: docker push run: | - docker push aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) + docker push aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) From 9e08de97144a7ee03b8d182baf6842b2289b4c19 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:40:07 +0100 Subject: [PATCH 17/43] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5043077d..7575be7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ jq \ #Copie et execution du script pour l'installation et l'initialisation de GLPI COPY glpi-start.sh glpi-install.sh /opt/ RUN chmod +x /opt/glpi-start.sh /opt/glpi-install.sh -RUN sh /opt/glpi-install.sh +RUN bash /opt/glpi-install.sh ENTRYPOINT ["/opt/glpi-start.sh"] #Exposition des ports From c9bb6012990225155adab5f627f79f9185f62ade Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:40:27 +0100 Subject: [PATCH 18/43] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 7575be7f..defcd2ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ ENV DEBIAN_FRONTEND noninteractive #Installation d'apache et de php7.3 avec extension RUN apt update \ && apt install --yes --no-install-recommends \ +apt-utils \ apache2 \ php7.3 \ php7.3-mysql \ From 01aecb0528608052bc34907b0790df9b4f42da43 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:41:25 +0100 Subject: [PATCH 19/43] Update docker.yml --- .github/workflows/docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 64129f41..4706f929 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -20,3 +20,4 @@ jobs: - name: docker push run: | docker push aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) + docker push aguyonnet/glpi-test:latest From a97cce8b3c9d1a0c437ba2bf79456a588ec4764a Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:46:38 +0100 Subject: [PATCH 20/43] Update glpi-install.sh --- glpi-install.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/glpi-install.sh b/glpi-install.sh index 2fe74f20..0ed36525 100644 --- a/glpi-install.sh +++ b/glpi-install.sh @@ -20,15 +20,10 @@ then fi #Téléchargement et extraction des sources de GLPI -if [ "$(ls ${FOLDER_WEB}${FOLDER_GLPI})" ]; -then - echo "GLPI is already installed" -else - wget -P ${FOLDER_WEB} ${SRC_GLPI} - tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB} - rm -Rf ${FOLDER_WEB}${TAR_GLPI} - chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} -fi +wget -P ${FOLDER_WEB} ${SRC_GLPI} +tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB} +rm -Rf ${FOLDER_WEB}${TAR_GLPI} +chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} #Modification du vhost par défaut 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 From f9e55cc4d2711a9c112e1525267a67e9599194f3 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:53:55 +0100 Subject: [PATCH 21/43] Update glpi-install.sh --- glpi-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glpi-install.sh b/glpi-install.sh index 0ed36525..48cb64b3 100644 --- a/glpi-install.sh +++ b/glpi-install.sh @@ -2,6 +2,8 @@ #Prise de la latest VERSION_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) +#Pour utiliser une version specifique: +#VERSION_GLPI=9.5.4 if [[ -z "${TIMEZONE}" ]]; then echo "TIMEZONE is unset"; else echo "date.timezone = \"$TIMEZONE\"" > /etc/php/7.3/apache2/conf.d/timezone.ini; From 1305513f8c977203ee6b1bb56f6ba2d8bda001a8 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:55:59 +0100 Subject: [PATCH 22/43] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 818c4e4d..b2c91c5e 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,7 @@ Install and run an GLPI instance with docker. ## Deploy a specific release of GLPI -Default, docker run will use the latest release of GLPI. -For an usage on production environnement, it's recommanded to set specific release. -Here an example for release 9.1.6 : -```sh -docker run --name glpi -p 80:80 --env "VERSION_GLPI=9.1.6" -d aguyonnet/glpi -``` +Edit the glpi-install.sh specify a version in the VERSION_GLPI var # Deploy with docker-compose From c88f835ac7a49c9d6fb8281a466c3ba189fff4c6 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:56:43 +0100 Subject: [PATCH 23/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2c91c5e..15030d2f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Install and run an GLPI instance with docker. ## Deploy a specific release of GLPI -Edit the glpi-install.sh specify a version in the VERSION_GLPI var +Edit the glpi-install.sh specify a version in the VERSION_GLPI var, then launch a build # Deploy with docker-compose From 5cef3db800984a722c98a547306752d1c4f78f27 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 11:56:53 +0100 Subject: [PATCH 24/43] Create README.md From c1ec3454a62f57e6923316179a838050205d5e2b Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 9 Mar 2021 14:08:03 +0100 Subject: [PATCH 25/43] Update docker.yml --- .github/workflows/docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4706f929..bd035f8f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,8 +16,8 @@ jobs: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD - name: docker build glpi run: | - docker build . -t aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi-test:latest + docker build . -t aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) -t aguyonnet/glpi:latest - name: docker push run: | - docker push aguyonnet/glpi-test:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) - docker push aguyonnet/glpi-test:latest + docker push aguyonnet/glpi:$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) + docker push aguyonnet/glpi:latest From 90f4083cb290d501bb5af2c066f0d1a8833c24fe Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Thu, 11 Mar 2021 17:32:29 +0100 Subject: [PATCH 26/43] Add package apache2-utils --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index defcd2ec..6d6d4419 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN apt update \ && apt install --yes --no-install-recommends \ apt-utils \ apache2 \ +apache2-utils \ php7.3 \ php7.3-mysql \ php7.3-ldap \ From 065f01301cf3542af397c225927b90915edc2a26 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 15 Mar 2021 10:59:41 +0100 Subject: [PATCH 27/43] Update mariadb.env variable --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 15030d2f..64663d1a 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ You can modify **_mariadb.env_** to personalize settings like : ### mariadb.env ``` -mariadb_ROOT_PASSWORD=aguyonnet -mariadb_DATABASE=glpidb -mariadb_USER=glpi_user -mariadb_PASSWORD=glpi +MYSQL_ROOT_PASSWORD=aguyonnet +MYSQL_DATABASE=glpidb +MYSQL_USER=glpi_user +MYSQL_PASSWORD=glpi ``` ### docker-compose .yml From 3ec82c6f0a6c71579ac88090bd1109d4faf42715 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 16 Mar 2021 15:20:02 +0100 Subject: [PATCH 28/43] update volumes in docker-compose example --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64663d1a..1153131c 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ services: container_name: mariadb-glpi hostname: mariadb volumes: - - /var/lib/mysql:/var/lib/mysql + - glpi-db:/var/lib/mysql env_file: - ./mariadb.env restart: always @@ -80,10 +80,13 @@ services: volumes: - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro - - /var/www/html/glpi/:/var/www/html/glpi + - glpi-data:/var/www/html/glpi environment: - TIMEZONE=Europe/Paris restart: always +volumes: + glpi-db: + glpi-data: ``` To deploy, just run the following command on the same directory as files From 425249face3dbcc2626dfaf64e7c8f2d0873beb8 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 16 Mar 2021 15:21:20 +0100 Subject: [PATCH 29/43] update volumes in docker-compose and version --- docker-compose.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d2c7a0d8..18ae5903 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.2" +version: "3.5" services: #mariadb Container @@ -7,7 +7,7 @@ services: container_name: mariadb-glpi hostname: mariadb volumes: - - /var/lib/mysql:/var/lib/mysql + - glpi-db:/var/lib/mysql env_file: - ./mariadb.env restart: always @@ -22,7 +22,11 @@ services: volumes: - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro - - /var/www/html/glpi/:/var/www/html/glpi + - glpi-data:/var/www/html/glpi environment: - TIMEZONE=Europe/Paris restart: always + +volumes: + glpi-db: + glpi-data: From ccc7dcbafd288d88903e30d37bdb3e9581f1c8fd Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Tue, 16 Mar 2021 15:22:02 +0100 Subject: [PATCH 30/43] update docker-compose version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1153131c..70ff4006 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Edit the glpi-install.sh specify a version in the VERSION_GLPI var, then launch ## Deploy without persistence data ( for quickly test ) ```yaml -version: "3.2" +version: "3.5" services: #mariadb Container @@ -56,7 +56,7 @@ MYSQL_PASSWORD=glpi ### docker-compose .yml ```yaml -version: "3.2" +version: "3.5" services: #mariadb Container From 77c1cc42a812dff73cd8a09c6e68db9f6d47df14 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Sep 2021 14:53:32 +0200 Subject: [PATCH 31/43] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6d6d4419..b69df318 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ #On choisit une debian -FROM debian:latest +FROM debian:10 MAINTAINER Aguyonnet "f.guyonantoine@gmail.com" From 0f01a6cf986a535e8ebe3beeb40ec96dabb97e29 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 10:47:01 +0200 Subject: [PATCH 32/43] Create testing.yml --- .github/workflows/testing.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..c8d0e9cd --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,22 @@ +name: Mise à jour automatique du programme +on: + schedule: + - cron: '0 * * * *' # Exécute la pipeline toutes les heures +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Extraire la valeur HTML spécifique + run: | + wget -O - https://glpi-project.org/fr/telecharger-glpi/ | grep "

GLPI VERSION" | sed -n 's/.*GLPI VERSION \([0-9.]*\).*/\1/p' > current_version.txt + - name: Comparer les versions + run: | + if ! diff current_version.txt <(echo ${{ secrets.PROGRAM_VERSION }}); then + echo "Une nouvelle version du programme est disponible." + export NEW_VERSION=$(cat current_version.txt) + echo "::set-secrets name=PROGRAM_VERSION::${NEW_VERSION}" + # Continuer le processus de mise à jour ici + else + echo "Le programme est à jour." + exit 1 # Arrête la pipeline avec un code d'erreur + fi From 6b293ba33f2dadbcacb88071dfd3429f95bdaadb Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 10:48:44 +0200 Subject: [PATCH 33/43] Update testing.yml --- .github/workflows/testing.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c8d0e9cd..6a4dbce1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,7 +1,8 @@ name: Mise à jour automatique du programme -on: - schedule: - - cron: '0 * * * *' # Exécute la pipeline toutes les heures +# on: +# schedule: +# - cron: '0 * * * *' # Exécute la pipeline toutes les heures +on: [workflow_dispatch] jobs: build: runs-on: ubuntu-latest From ebcd9490a72bd3f1803756201c4c5a7b1487d5c6 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 13:58:25 +0200 Subject: [PATCH 34/43] Update testing.yml --- .github/workflows/testing.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 6a4dbce1..3f8270a9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -14,10 +14,19 @@ jobs: run: | if ! diff current_version.txt <(echo ${{ secrets.PROGRAM_VERSION }}); then echo "Une nouvelle version du programme est disponible." - export NEW_VERSION=$(cat current_version.txt) - echo "::set-secrets name=PROGRAM_VERSION::${NEW_VERSION}" + export PROGRAM_VERSION=$(cat current_version.txt) # Continuer le processus de mise à jour ici else echo "Le programme est à jour." exit 1 # Arrête la pipeline avec un code d'erreur fi + + - name: Mettre à jour la variable secrète + run: | + echo ${{ secrets.PERSONAL_ACCESS_TOKEN }} > access_token.txt + curl -X PATCH -H "Authorization: Bearer $(cat access_token.txt)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value": "'"$(echo -n "${PROGRAM_VERSION}" | base64)"'"}' + env: + PROGRAM_VERSION: ${{ env.PROGRAM_VERSION }} + + - name: Supprimer le jeton d'accès personnel + run: rm access_token.txt From 5405480300884547d5f533f59d7438bfe7faee9a Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 15:31:51 +0200 Subject: [PATCH 35/43] Update testing.yml --- .github/workflows/testing.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 3f8270a9..a31d4f30 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -16,17 +16,11 @@ jobs: echo "Une nouvelle version du programme est disponible." export PROGRAM_VERSION=$(cat current_version.txt) # Continuer le processus de mise à jour ici + + # Envoyer une demande PATCH à l'API GitHub pour mettre à jour la variable secrète + echo -n $PROGRAM_VERSION | base64 --wrap=0 > program_version_base64.txt + curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos///actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' else echo "Le programme est à jour." exit 1 # Arrête la pipeline avec un code d'erreur fi - - - name: Mettre à jour la variable secrète - run: | - echo ${{ secrets.PERSONAL_ACCESS_TOKEN }} > access_token.txt - curl -X PATCH -H "Authorization: Bearer $(cat access_token.txt)" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value": "'"$(echo -n "${PROGRAM_VERSION}" | base64)"'"}' - env: - PROGRAM_VERSION: ${{ env.PROGRAM_VERSION }} - - - name: Supprimer le jeton d'accès personnel - run: rm access_token.txt From 6dcca3d0c07dad1a5c7c5b96a173d7d7651d0285 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 15:33:48 +0200 Subject: [PATCH 36/43] Update testing.yml --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a31d4f30..a0c23416 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,7 @@ jobs: # Envoyer une demande PATCH à l'API GitHub pour mettre à jour la variable secrète echo -n $PROGRAM_VERSION | base64 --wrap=0 > program_version_base64.txt - curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos///actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' + curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' else echo "Le programme est à jour." exit 1 # Arrête la pipeline avec un code d'erreur From 51e563a20b293668b5fd42088bf175fade0e8b00 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 15:43:39 +0200 Subject: [PATCH 37/43] Update testing.yml --- .github/workflows/testing.yml | 50 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a0c23416..16bc1817 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,26 +1,34 @@ name: Mise à jour automatique du programme -# on: -# schedule: -# - cron: '0 * * * *' # Exécute la pipeline toutes les heures -on: [workflow_dispatch] +on: + workflow_dispatch: + schedule: + - cron: '0 * * * *' # Exécute la pipeline toutes les heures jobs: build: runs-on: ubuntu-latest steps: - - name: Extraire la valeur HTML spécifique - run: | - wget -O - https://glpi-project.org/fr/telecharger-glpi/ | grep "

GLPI VERSION" | sed -n 's/.*GLPI VERSION \([0-9.]*\).*/\1/p' > current_version.txt - - name: Comparer les versions - run: | - if ! diff current_version.txt <(echo ${{ secrets.PROGRAM_VERSION }}); then - echo "Une nouvelle version du programme est disponible." - export PROGRAM_VERSION=$(cat current_version.txt) - # Continuer le processus de mise à jour ici - - # Envoyer une demande PATCH à l'API GitHub pour mettre à jour la variable secrète - echo -n $PROGRAM_VERSION | base64 --wrap=0 > program_version_base64.txt - curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' - else - echo "Le programme est à jour." - exit 1 # Arrête la pipeline avec un code d'erreur - fi + - name: Extraire la valeur HTML spécifique + run: | + wget -O - https://glpi-project.org/fr/telecharger-glpi/ | grep "

GLPI VERSION" | sed -n 's/.*GLPI VERSION \([0-9.]*\).*/\1/p' > current_version.txt + - name: Comparer les versions + continue-on-error: true + run: | + if ! diff current_version.txt <(echo ${{ secrets.PROGRAM_VERSION }}); then + echo "Une nouvelle version du programme est disponible." + export PROGRAM_VERSION=$(cat current_version.txt) + # Continuer le processus de mise à jour ici + + # Créer un fichier temporaire pour stocker la valeur encodée en base64 de la nouvelle version + echo -n $PROGRAM_VERSION | base64 --wrap=0 > program_version_base64.txt + + # Mettre à jour la variable secrète à l'aide de l'API GitHub + if [ -s program_version_base64.txt ]; then + curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' + echo "La variable secrète PROGRAM_VERSION a été mise à jour." + else + echo "La valeur encodée en base64 de la nouvelle version est vide ou le fichier program_version_base64.txt n'existe pas." + fi + else + echo "Le programme est à jour." + exit 1 # Arrête la pipeline avec un code d'erreur + fi From 75985fbc6b7456371e484d96380fcb91a4e96927 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 16:04:08 +0200 Subject: [PATCH 38/43] Update testing.yml --- .github/workflows/testing.yml | 43 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 16bc1817..8dae3fec 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,8 +1,10 @@ name: Mise à jour automatique du programme + on: - workflow_dispatch: schedule: - cron: '0 * * * *' # Exécute la pipeline toutes les heures + workflow_dispatch: + jobs: build: runs-on: ubuntu-latest @@ -10,25 +12,28 @@ jobs: - name: Extraire la valeur HTML spécifique run: | wget -O - https://glpi-project.org/fr/telecharger-glpi/ | grep "

GLPI VERSION" | sed -n 's/.*GLPI VERSION \([0-9.]*\).*/\1/p' > current_version.txt - - name: Comparer les versions - continue-on-error: true - run: | - if ! diff current_version.txt <(echo ${{ secrets.PROGRAM_VERSION }}); then - echo "Une nouvelle version du programme est disponible." - export PROGRAM_VERSION=$(cat current_version.txt) - # Continuer le processus de mise à jour ici + export PROGRAM_VERSION_LATEST=$(cat current_version.txt) + + - name: Checkout repository + uses: actions/checkout@v2 - # Créer un fichier temporaire pour stocker la valeur encodée en base64 de la nouvelle version - echo -n $PROGRAM_VERSION | base64 --wrap=0 > program_version_base64.txt + - name: Configurer Git + run: | + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" - # Mettre à jour la variable secrète à l'aide de l'API GitHub - if [ -s program_version_base64.txt ]; then - curl -X PATCH -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/aguyonp/docker-glpi-automated/actions/secrets/PROGRAM_VERSION -d '{"encrypted_value":"'"$(cat program_version_base64.txt)"'"}' - echo "La variable secrète PROGRAM_VERSION a été mise à jour." - else - echo "La valeur encodée en base64 de la nouvelle version est vide ou le fichier program_version_base64.txt n'existe pas." - fi + - name: Comparer et mettre à jour la version + run: | + export PROGRAM_VERSION=$(grep "PROGRAM_VERSION" .github/variables/repository-variables.env | sed -n 's/.*PROGRAM_VERSION=\([0-9.]*\).*/\1/p') + echo "PROGRAM_VERSION=$PROGRAM_VERSION" + echo "PROGRAM_VERSION_LATEST=$PROGRAM_VERSION_LATEST" + + if [ "$PROGRAM_VERSION" != "$PROGRAM_VERSION_LATEST" ]; then + sed -i "s/PROGRAM_VERSION=$PROGRAM_VERSION/PROGRAM_VERSION=$PROGRAM_VERSION_LATEST/" .github/variables/repository-variables.env + git add .github/variables/repository-variables.env + git commit -m "Mise à jour de la version de GLPI à $PROGRAM_VERSION_LATEST" + git push else - echo "Le programme est à jour." - exit 1 # Arrête la pipeline avec un code d'erreur + echo "La version de GLPI est déjà à jour" + exit 1 fi From 37c55fcdb3ff858f4c86435aa124f35203c0ae74 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 19:54:13 +0200 Subject: [PATCH 39/43] Create check_glpi_version.yml --- .github/workflows/check_glpi_version.yml | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/check_glpi_version.yml diff --git a/.github/workflows/check_glpi_version.yml b/.github/workflows/check_glpi_version.yml new file mode 100644 index 00000000..c6180401 --- /dev/null +++ b/.github/workflows/check_glpi_version.yml @@ -0,0 +1,37 @@ +name: Check GLPI Version + +on: + schedule: + - cron: '0 * * * *' + +jobs: + check_version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests beautifulsoup4 + + - name: Check GLPI version + run: python check_glpi_version.py + + - name: Store new version + if: ${{ success() }} + run: | + echo "NEW_GLPI_VERSION=$(cat new_glpi_version.txt)" >> $GITHUB_ENV + + - name: Run build for new version + if: ${{ success() }} + run: | + echo "Build process starts for new GLPI version ${{ env.NEW_GLPI_VERSION }}" + # Ajoutez ici les étapes pour lancer le build avec la nouvelle version From 728379691e206ddb5d2a7ba002da306571f38123 Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 19:57:15 +0200 Subject: [PATCH 40/43] Create check_glpi_version.py --- check_glpi_version.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 check_glpi_version.py diff --git a/check_glpi_version.py b/check_glpi_version.py new file mode 100644 index 00000000..1c671ad9 --- /dev/null +++ b/check_glpi_version.py @@ -0,0 +1,31 @@ +import os +import requests +from bs4 import BeautifulSoup + +url = "https://glpi-project.org/fr/telecharger-glpi/" +response = requests.get(url) +soup = BeautifulSoup(response.text, 'html.parser') +version_tag = soup.find('p', {'style': 'text-align: center;'}) + +if not version_tag: + print("GLPI version tag not found.") + exit(1) + +version_text = version_tag.text.strip() +current_version = version_text.split(" ")[-1] + +try: + with open("last_glpi_version.txt", "r") as f: + last_version = f.read().strip() +except FileNotFoundError: + last_version = None + +if current_version != last_version: + print(f"New GLPI version found: {current_version}") + with open("new_glpi_version.txt", "w") as f: + f.write(current_version) + with open("last_glpi_version.txt", "w") as f: + f.write(current_version) +else: + print(f"No new version found. Current version is {current_version}.") + exit(78) From e4c587c97feead896b54d97ba1525efbb5937cef Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 19:58:42 +0200 Subject: [PATCH 41/43] Update check_glpi_version.yml --- .github/workflows/check_glpi_version.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_glpi_version.yml b/.github/workflows/check_glpi_version.yml index c6180401..dda17b72 100644 --- a/.github/workflows/check_glpi_version.yml +++ b/.github/workflows/check_glpi_version.yml @@ -3,6 +3,7 @@ name: Check GLPI Version on: schedule: - cron: '0 * * * *' + workflow_dispatch: jobs: check_version: From d1a1b4ec7c199fd1486f40c796c52bb9e720c9ab Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 20:31:29 +0200 Subject: [PATCH 42/43] Update check_glpi_version.yml --- .github/workflows/check_glpi_version.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_glpi_version.yml b/.github/workflows/check_glpi_version.yml index dda17b72..bdaf44b7 100644 --- a/.github/workflows/check_glpi_version.yml +++ b/.github/workflows/check_glpi_version.yml @@ -4,7 +4,7 @@ on: schedule: - cron: '0 * * * *' workflow_dispatch: - + jobs: check_version: runs-on: ubuntu-latest @@ -23,6 +23,13 @@ jobs: python -m pip install --upgrade pip pip install requests beautifulsoup4 + - name: Download last GLPI version artifact + uses: actions/download-artifact@v2 + with: + name: last_glpi_version + path: ./last_glpi_version + continue-on-error: true + - name: Check GLPI version run: python check_glpi_version.py @@ -36,3 +43,10 @@ jobs: run: | echo "Build process starts for new GLPI version ${{ env.NEW_GLPI_VERSION }}" # Ajoutez ici les étapes pour lancer le build avec la nouvelle version + + - name: Upload new last GLPI version artifact + if: ${{ success() }} + uses: actions/upload-artifact@v2 + with: + name: last_glpi_version + path: ./last_glpi_version/last_glpi_version.txt From 99523e242662aad6135e9062c7acc3f292806a9d Mon Sep 17 00:00:00 2001 From: Antoine Guyon Date: Mon, 27 Mar 2023 20:36:13 +0200 Subject: [PATCH 43/43] Update check_glpi_version.yml --- .github/workflows/check_glpi_version.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_glpi_version.yml b/.github/workflows/check_glpi_version.yml index bdaf44b7..ad2fc636 100644 --- a/.github/workflows/check_glpi_version.yml +++ b/.github/workflows/check_glpi_version.yml @@ -27,7 +27,7 @@ jobs: uses: actions/download-artifact@v2 with: name: last_glpi_version - path: ./last_glpi_version + path: ./last_glpi_version.txt continue-on-error: true - name: Check GLPI version @@ -49,4 +49,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: last_glpi_version - path: ./last_glpi_version/last_glpi_version.txt + path: ./last_glpi_version.txt