Compare commits

..

No commits in common. 'f8ceba3d73a11991d60c012f105c34c2712c7842' and '58ff53e00b650a35c9f4ebd54c338edf0988349c' have entirely different histories.

@ -1,23 +0,0 @@
name: Build & Publish Dev Docker image
on:
push:
branches:
- "dev"
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5.3.0
with:
push: true
tags: diouxx/glpi:dev

@ -1,27 +0,0 @@
name: Build & Publish Docker Image
on:
push:
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set output
id: vars
run: echo ::set-output name=tag::$
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: diouxx/glpi:latest

3
.gitignore vendored

@ -1,4 +1 @@
docker-compose-test.yml docker-compose-test.yml
cust-entry.sh
data
start-docker.sh

@ -1,42 +1,32 @@
#On choisit une debian #On choisit une debian
FROM debian:12.5 FROM debian:latest
LABEL org.opencontainers.image.authors="github@diouxx.be"
MAINTAINER DiouxX "github@diouxx.be"
#Ne pas poser de question à l'installation #Ne pas poser de question à l'installation
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
#Installation d'apache et de php8.3 avec extension #Installation d'apache et de php5 avec extension
RUN apt update \ RUN apt update \
&& apt install --yes ca-certificates apt-transport-https lsb-release wget curl \ && apt -y upgrade \
&& curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \ && apt -y install \
&& sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' \
&& apt update \
&& apt install --yes --no-install-recommends \
apache2 \ apache2 \
php8.3 \ php \
php8.3-mysql \ php-mysql \
php8.3-ldap \ php-ldap \
php8.3-xmlrpc \ php-xmlrpc \
php8.3-imap \ php-imap \
php8.3-curl \ curl \
php8.3-gd \ php-curl \
php8.3-mbstring \ php-gd \
php8.3-xml \ php-mbstring \
php-xml \
php-apcu-bc \
php-cas \ php-cas \
php8.3-intl \
php8.3-zip \
php8.3-bz2 \
php8.3-redis \
cron \ cron \
wget \
jq \ jq \
libldap-2.5-0 \ snmpd
libldap-common \
libsasl2-2 \
libsasl2-modules \
libsasl2-modules-db \
&& rm -rf /var/lib/apt/lists/*
#Copie et execution du script pour l'installation et l'initialisation de GLPI #Copie et execution du script pour l'installation et l'initialisation de GLPI
COPY glpi-start.sh /opt/ COPY glpi-start.sh /opt/

@ -1,186 +1,70 @@
# Project to deploy GLPI with docker # 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) [![](https://images.microbadger.com/badges/version/diouxx/glpi.svg)](http://microbadger.com/images/diouxx/glpi "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/diouxx/glpi.svg)](http://microbadger.com/images/diouxx/glpi "Get your own image badge on microbadger.com")
# Table of Contents # Table of Contents
- [Project to deploy GLPI with docker](#project-to-deploy-glpi-with-docker) 1. [Introduction](#introduction)
- [Table of Contents](#table-of-contents) 2. [Deploy CLI](#deploy-with-CLI)
- [Introduction](#introduction) - [Deploy GLPI without database](#deploy-glpi-without-database)
- [Default accounts](#default-accounts) - [Deploy GLPI with existing database](#deploy-glpi-with-existing-database)
- [Deploy with CLI](#deploy-with-cli) - [Deploy GLPI with database and persistance container data](#deploy-glpi-with-database-and-persistance-container-data)
- [Deploy GLPI](#deploy-glpi) - [Deploy a specific release of GLPI](#deploy-a-specific-release-of-glpi)
- [Deploy GLPI with existing database](#deploy-glpi-with-existing-database) 3. [Deploy docker-compose](#deploy-with-docker-compose)
- [Deploy GLPI with database and persistence data](#deploy-glpi-with-database-and-persistence-data) 4. [Environnment variables](#environnment-variables)
- [Deploy a specific release of GLPI](#deploy-a-specific-release-of-glpi) - [Timezone](#timezone)
- [Deploy with docker-compose](#deploy-with-docker-compose)
- [Deploy without persistence data ( for quickly test )](#deploy-without-persistence-data--for-quickly-test-)
- [Deploy a specific release](#deploy-a-specific-release)
- [Deploy with persistence data](#deploy-with-persistence-data)
- [mariadb.env](#mariadbenv)
- [docker-compose .yml](#docker-compose-yml)
- [Environnment variables](#environnment-variables)
- [TIMEZONE](#timezone)
# Introduction # Introduction
Install and run an GLPI instance with docker Install and run an GLPI instance with docker.
## Default accounts
More info in the 📄[Docs](https://glpi-install.readthedocs.io/en/latest/install/wizard.html#end-of-installation)
| Login/Password | Role |
|-------------------- |------------------- |
| glpi/glpi | admin account |
| tech/tech | technical account |
| normal/normal | "normal" account |
| post-only/postonly | post-only account |
# Deploy with CLI # Deploy with CLI
## Deploy GLPI ## Deploy GLPI without database
```sh ```sh
docker run --name mariadb -e MARIADB_ROOT_PASSWORD=diouxx -e MARIADB_DATABASE=glpidb -e MARIADB_USER=glpi_user -e MARIADB_PASSWORD=glpi -d mariadb:10.7 docker run --name glpi -p 80:80 -d diouxx/glpi
docker run --name glpi --link mariadb:mariadb -p 80:80 -d diouxx/glpi
``` ```
## Deploy GLPI with existing database ## Deploy GLPI with existing database
```sh ```sh
docker run --name glpi --link yourdatabase:mariadb -p 80:80 -d diouxx/glpi docker run --name glpi --link yourdatabase:mysql -p 80:80 -d diouxx/glpi
``` ```
## Deploy GLPI with database and persistence data ## Deploy GLPI with database and persistance container data
For an usage on production environnement or daily usage, it's recommanded to use container with volumes to persistent data. For an usage on production environnement or daily usage, it's recommanded to use a data container for persistent data.
* First, create MariaDB container with volume * First, create data container
```sh ```sh
docker run --name mariadb -e MARIADB_ROOT_PASSWORD=diouxx -e MARIADB_DATABASE=glpidb -e MARIADB_USER=glpi_user -e MARIADB_PASSWORD=glpi --volume /var/lib/mysql:/var/lib/mysql -d mariadb:10.7 docker create --name glpi-data --volume /var/www/html/glpi:/var/www/html/glpi busybox /bin/true
``` ```
* Then, create GLPI container with volume and link MariaDB container * Then, you link your data container with GLPI container
```sh ```sh
docker run --name glpi --link mariadb:mariadb --volume /var/www/html/glpi:/var/www/html/glpi -p 80:80 -d diouxx/glpi docker run --name glpi --hostname glpi --link mysql:mysql --volumes-from glpi-data -p 80:80 -d diouxx/glpi
``` ```
Enjoy :) Enjoy :)
## Deploy a specific release of GLPI ## Deploy a specific release of GLPI
Default, docker run will use the latest 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. For an usage on production environnement, it's recommanded to use the latest release.
Here an example for release 9.1.6 : Here an example for release 9.1.6 :
```sh ```sh
docker run --name glpi --hostname glpi --link mariadb:mariadb --volume /var/www/html/glpi:/var/www/html/glpi -p 80:80 --env "VERSION_GLPI=9.1.6" -d diouxx/glpi docker run --name glpi --hostname glpi --link mysql:mysql --volumes-from glpi-data -p 80:80 --env "VERSION_GLPI=9.1.6" -d diouxx/glpi
``` ```
# Deploy with docker-compose # Deploy with docker-compose
## Deploy without persistence data ( for quickly test ) To deploy with docker compose, you use *docker-compose.yml* and *mysql.env* file.
```yaml You can modify **_mysql.env_** to personalize settings like :
version: "3.8"
services:
#MariaDB Container
mariadb:
image: mariadb:10.7
container_name: mariadb
hostname: mariadb
environment:
- MARIADB_ROOT_PASSWORD=password
- MARIADB_DATABASE=glpidb
- MARIADB_USER=glpi_user
- MARIADB_PASSWORD=glpi
#GLPI Container
glpi:
image: diouxx/glpi
container_name : glpi
hostname: glpi
ports:
- "80:80"
```
## Deploy a specific release
```yaml
version: "3.8"
services:
#MariaDB Container
mariadb:
image: mariadb:10.7
container_name: mariadb
hostname: mariadb
environment:
- MARIADB_ROOT_PASSWORD=password
- MARIADB_DATABASE=glpidb
- MARIADB_USER=glpi_user
- MARIADB_PASSWORD=glpi
#GLPI Container
glpi:
image: diouxx/glpi
container_name : glpi
hostname: glpi
environment:
- VERSION_GLPI=9.5.6
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 * MySQL root password
* GLPI database * GLPI database
* GLPI user database * GLPI user database
* GLPI user password * GLPI user password
### mariadb.env
```
MARIADB_ROOT_PASSWORD=diouxx
MARIADB_DATABASE=glpidb
MARIADB_USER=glpi_user
MARIADB_PASSWORD=glpi
```
### docker-compose .yml
```yaml
version: "3.2"
services:
#MariaDB Container
mariadb:
image: mariadb:10.7
container_name: mariadb
hostname: mariadb
volumes:
- /var/lib/mysql:/var/lib/mysql
env_file:
- ./mariadb.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 To deploy, just run the following command on the same directory as files
```sh ```sh
@ -194,13 +78,13 @@ If you need to set timezone for Apache and PHP
From commande line From commande line
```sh ```sh
docker run --name glpi --hostname glpi --link mariadb:mariadb --volumes-from glpi-data -p 80:80 --env "TIMEZONE=Europe/Brussels" -d diouxx/glpi 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 From docker-compose
Modify this settings Modify this settings
```yaml ```yml
environment: environment:
TIMEZONE=Europe/Brussels TIMEZONE=Europe/Brussels
``` ```

@ -1,16 +1,15 @@
version: "3.2" version: "3"
services: services:
#MariaDB Container #Mysql Container
mariadb: mysql:
image: mariadb:10.7 image: mysql:5.7.23
container_name: mariadb container_name: mysql
hostname: mariadb hostname: mysql
volumes: volumes:
- /var/lib/mysql:/var/lib/mysql - /var/lib/mysql:/var/lib/mysql
env_file: env_file:
- ./mariadb.env - ./mysql.env
restart: always
#GLPI Container #GLPI Container
glpi: glpi:
@ -19,10 +18,12 @@ services:
hostname: glpi hostname: glpi
ports: ports:
- "80:80" - "80:80"
links:
- mysql:mysql
volumes: volumes:
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
- /var/www/html/glpi/:/var/www/html/glpi - /var/www/html/glpi/:/var/www/html/glpi
environment: environment:
- TIMEZONE=Europe/Brussels - TIMEZONE=Europe/Brussels
restart: always restart: always

@ -5,14 +5,11 @@
&& VERSION_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep tag_name | cut -d '"' -f 4) && 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"; if [[ -z "${TIMEZONE}" ]]; then echo "TIMEZONE is unset";
else else echo "date.timezone = \"$TIMEZONE\"" > /etc/php/7.0/apache2/conf.d/timezone.ini;
echo "date.timezone = \"$TIMEZONE\"" > /etc/php/8.3/apache2/conf.d/timezone.ini;
echo "date.timezone = \"$TIMEZONE\"" > /etc/php/8.3/cli/conf.d/timezone.ini;
fi fi
#Enable session.cookie_httponly SRC_GLPI=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/tags/${VERSION_GLPI} | jq .assets[0].browser_download_url | tr -d \")
sed -i 's,session.cookie_httponly = *\(on\|off\|true\|false\|0\|1\)\?,session.cookie_httponly = on,gi' /etc/php/8.3/apache2/php.ini TAR_GLPI=$(basename ${SRC_GLPI})
FOLDER_GLPI=glpi/ FOLDER_GLPI=glpi/
FOLDER_WEB=/var/www/html/ FOLDER_WEB=/var/www/html/
@ -20,7 +17,7 @@ FOLDER_WEB=/var/www/html/
if !(grep -q "TLS_REQCERT" /etc/ldap/ldap.conf) if !(grep -q "TLS_REQCERT" /etc/ldap/ldap.conf)
then then
echo "TLS_REQCERT isn't present" echo "TLS_REQCERT isn't present"
echo -e "TLS_REQCERT\tnever" >> /etc/ldap/ldap.conf echo -e "TLS_REQCERT\tnever" >> /etc/ldap/ldap.conf
fi fi
#Téléchargement et extraction des sources de GLPI #Téléchargement et extraction des sources de GLPI
@ -28,46 +25,34 @@ if [ "$(ls ${FOLDER_WEB}${FOLDER_GLPI})" ];
then then
echo "GLPI is already installed" echo "GLPI is already installed"
else else
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})
wget -P ${FOLDER_WEB} ${SRC_GLPI} wget -P ${FOLDER_WEB} ${SRC_GLPI}
tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB} tar -xzf ${FOLDER_WEB}${TAR_GLPI} -C ${FOLDER_WEB}
rm -Rf ${FOLDER_WEB}${TAR_GLPI} rm -Rf ${FOLDER_WEB}${TAR_GLPI}
chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI} chown -R www-data:www-data ${FOLDER_WEB}${FOLDER_GLPI}
fi fi
#Adapt the Apache server according to the version of GLPI installed #Modification du vhost par défaut
## Extract local version installed echo -e "<VirtualHost *:80>\n\tDocumentRoot /var/www/html/glpi\n\n\t<Directory /var/www/html/glpi>\n\t\tAllowOverride All\n\t\tOrder Allow,Deny\n\t\tAllow from all\n\t</Directory>\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
LOCAL_GLPI_VERSION=$(ls ${FOLDER_WEB}/${FOLDER_GLPI}/version)
## Extract major version number
LOCAL_GLPI_MAJOR_VERSION=$(echo $LOCAL_GLPI_VERSION | cut -d. -f1)
## Remove dots from version string
LOCAL_GLPI_VERSION_NUM=${LOCAL_GLPI_VERSION//./}
## Target value is GLPI 1.0.7
TARGET_GLPI_VERSION="10.0.7"
TARGET_GLPI_VERSION_NUM=${TARGET_GLPI_VERSION//./}
TARGET_GLPI_MAJOR_VERSION=$(echo $TARGET_GLPI_VERSION | cut -d. -f1)
# Compare the numeric value of the version number to the target number #Activation du module rewrite d'apache
if [[ $LOCAL_GLPI_VERSION_NUM -lt $TARGET_GLPI_VERSION_NUM || $LOCAL_GLPI_MAJOR_VERSION -lt $TARGET_GLPI_MAJOR_VERSION ]]; then a2enmod rewrite && service apache2 restart && service apache2 stop
echo -e "<VirtualHost *:80>\n\tDocumentRoot /var/www/html/glpi\n\n\t<Directory /var/www/html/glpi>\n\t\tAllowOverride All\n\t\tOrder Allow,Deny\n\t\tAllow from all\n\t</Directory>\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
else
set +H
echo -e "<VirtualHost *:80>\n\tDocumentRoot /var/www/html/glpi/public\n\n\t<Directory /var/www/html/glpi/public>\n\t\tRequire all granted\n\t\tRewriteEngine On\n\t\tRewriteCond %{REQUEST_FILENAME} !-f\n\t\n\t\tRewriteRule ^(.*)$ index.php [QSA,L]\n\t</Directory>\n\n\tErrorLog /var/log/apache2/error-glpi.log\n\tLogLevel warn\n\tCustomLog /var/log/apache2/access-glpi.log combined\n</VirtualHost>" > /etc/apache2/sites-available/000-default.conf
fi
######################
# CRON CONFIGURATION #
######################
#Add scheduled task by cron and enable #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 echo "*/2 * * * * www-data /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpi
#Start cron service #Start cron service
service cron start service cron start
#Activation du module rewrite d'apache ######################
a2enmod rewrite && service apache2 restart && service apache2 stop # SNMP CONFIGURATION #
######################
#Replace Listen localhot SNMP and restart service
sed -ie "s/agentAddress udp:127.0.0.1:161/agentAdrress udp:161/g" /etc/snmp/snmpd.conf
#Fix to really stop apache service snmpd restart
pkill -9 apache
#Lancement du service apache au premier plan #Lancement du service apache au premier plan
/usr/sbin/apache2ctl -D FOREGROUND /usr/sbin/apache2ctl -D FOREGROUND

@ -1,4 +0,0 @@
MARIADB_ROOT_PASSWORD=diouxx
MARIADB_DATABASE=glpidb
MARIADB_USER=glpi_user
MARIADB_PASSWORD=glpi

@ -0,0 +1,4 @@
MYSQL_ROOT_PASSWORD=diouxx
MYSQL_DATABASE=glpidb
MYSQL_USER=glpi_user
MYSQL_PASSWORD=glpi
Loading…
Cancel
Save