diff --git a/.github/workflows/check_glpi_version.yml b/.github/workflows/check_glpi_version.yml new file mode 100644 index 00000000..ad2fc636 --- /dev/null +++ b/.github/workflows/check_glpi_version.yml @@ -0,0 +1,52 @@ +name: Check GLPI Version + +on: + schedule: + - cron: '0 * * * *' + workflow_dispatch: + +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: Download last GLPI version artifact + uses: actions/download-artifact@v2 + with: + name: last_glpi_version + path: ./last_glpi_version.txt + continue-on-error: true + + - 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 + + - name: Upload new last GLPI version artifact + if: ${{ success() }} + uses: actions/upload-artifact@v2 + with: + name: last_glpi_version + path: ./last_glpi_version.txt diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..bd035f8f --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,23 @@ +name: Docker GLPI Build + +#on: [push] +on: [workflow_dispatch] + +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:$(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) + docker push aguyonnet/glpi:latest diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..8dae3fec --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,39 @@ +name: Mise à jour automatique du programme + +on: + schedule: + - cron: '0 * * * *' # Exécute la pipeline toutes les heures + workflow_dispatch: + +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
+ export PROGRAM_VERSION_LATEST=$(cat current_version.txt)
+
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Configurer Git
+ run: |
+ git config user.name "GitHub Actions Bot"
+ git config user.email "actions@github.com"
+
+ - 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 "La version de GLPI est déjà à jour"
+ exit 1
+ fi
diff --git a/Dockerfile b/Dockerfile
index 0c37521e..b69df318 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,7 @@
#On choisit une debian
-FROM debian:10.4
+FROM debian:10
-MAINTAINER DiouxX "github@diouxx.be"
+MAINTAINER Aguyonnet "f.guyonantoine@gmail.com"
#Ne pas poser de question à l'installation
ENV DEBIAN_FRONTEND noninteractive
@@ -9,7 +9,9 @@ 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 \
+apache2-utils \
php7.3 \
php7.3-mysql \
php7.3-ldap \
@@ -32,9 +34,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 bash /opt/glpi-install.sh
ENTRYPOINT ["/opt/glpi-start.sh"]
#Exposition des ports
-EXPOSE 80 443
+EXPOSE 80
diff --git a/README.md b/README.md
index b9894ac6..70ff4006 100644
--- a/README.md
+++ b/README.md
@@ -1,88 +1,34 @@
# Project to deploy GLPI with docker
-  [](http://microbadger.com/images/diouxx/glpi "Get your own image badge on microbadger.com") 
-
-# 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
-```
+Edit the glpi-install.sh specify a version in the VERSION_GLPI var, then launch a build
# Deploy with docker-compose
## Deploy without persistence data ( for quickly test )
```yaml
-version: "3.2"
+version: "3.5"
services:
-#Mysql Container
- mysql:
- image: mysql:5.7.23
- container_name: mysql
- hostname: mysql
+#mariadb Container
+ mariadb:
+ image: mariadb:latest
+ container_name: mariadb
+ hostname: mariadb
environment:
- - MYSQL_ROOT_PASSWORD=password
- - MYSQL_DATABASE=glpidb
- - MYSQL_USER=glpi_user
- - MYSQL_PASSWORD=glpi
+ - mariadb_ROOT_PASSWORD=password
+ - mariadb_DATABASE=glpidb
+ - mariadb_USER=glpi_user
+ - mariadb_PASSWORD=glpi
#GLPI Container
glpi:
- image: diouxx/glpi
+ image: aguyonnet/glpi
container_name : glpi
hostname: glpi
ports:
@@ -91,18 +37,18 @@ services:
## 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 :
+To deploy with docker compose, you use *docker-compose.yml* and *mariadb.env* file.
+You can modify **_mariadb.env_** to personalize settings like :
-* MySQL root password
+* mariadb root password
* GLPI database
* GLPI user database
* GLPI user password
-### mysql.env
+### mariadb.env
```
-MYSQL_ROOT_PASSWORD=diouxx
+MYSQL_ROOT_PASSWORD=aguyonnet
MYSQL_DATABASE=glpidb
MYSQL_USER=glpi_user
MYSQL_PASSWORD=glpi
@@ -110,23 +56,23 @@ MYSQL_PASSWORD=glpi
### docker-compose .yml
```yaml
-version: "3.2"
+version: "3.5"
services:
-#Mysql Container
- mysql:
- image: mysql:5.7.23
- container_name: mysql
- hostname: mysql
+#mariadb Container
+ mariadb:
+ image: mariadb:latest
+ container_name: mariadb-glpi
+ hostname: mariadb
volumes:
- - /var/lib/mysql:/var/lib/mysql
+ - glpi-db:/var/lib/mysql
env_file:
- - ./mysql.env
+ - ./mariadb.env
restart: always
#GLPI Container
glpi:
- image: diouxx/glpi
+ image: aguyonnet/glpi
container_name : glpi
hostname: glpi
ports:
@@ -134,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/Brussels
+ - TIMEZONE=Europe/Paris
restart: always
+volumes:
+ glpi-db:
+ glpi-data:
```
To deploy, just run the following command on the same directory as files
@@ -153,7 +102,7 @@ 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
+docker run --name glpi -p 80:80 --env "TIMEZONE=Europe/Paris" -d aguyonnet/glpi
```
From docker-compose
@@ -161,5 +110,5 @@ From docker-compose
Modify this settings
```yaml
environment:
- TIMEZONE=Europe/Brussels
+ TIMEZONE=Europe/Paris
```
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)
diff --git a/docker-compose.yml b/docker-compose.yml
index d620157d..18ae5903 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,20 +1,20 @@
-version: "3.2"
+version: "3.5"
services:
-#Mysql Container
- mysql:
- image: mysql:5.7.23
- container_name: mysql
- hostname: mysql
+#mariadb Container
+ mariadb:
+ image: mariadb:latest
+ container_name: mariadb-glpi
+ hostname: mariadb
volumes:
- - /var/lib/mysql:/var/lib/mysql
+ - glpi-db:/var/lib/mysql
env_file:
- - ./mysql.env
+ - ./mariadb.env
restart: always
#GLPI Container
glpi:
- image: diouxx/glpi
+ image: aguyonnet/glpi
container_name : glpi
hostname: glpi
ports:
@@ -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/Brussels
- restart: always
\ No newline at end of file
+ - TIMEZONE=Europe/Paris
+ restart: always
+
+volumes:
+ glpi-db:
+ glpi-data:
diff --git a/glpi-install.sh b/glpi-install.sh
new file mode 100644
index 00000000..48cb64b3
--- /dev/null
+++ b/glpi-install.sh
@@ -0,0 +1,34 @@
+#!/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)
+#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;
+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
+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 "