diff --git a/Dockerfile b/Dockerfile index 2b2d70a..c6f61aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,37 +13,36 @@ RUN apt update \ && 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 \ - php8.3 \ - php8.3-mysql \ - php8.3-ldap \ - php8.3-xmlrpc \ - php8.3-imap \ - php8.3-curl \ - php8.3-gd \ - php8.3-mbstring \ - php8.3-xml \ - php-cas \ - php8.3-intl \ - php8.3-zip \ - php8.3-bz2 \ - php8.3-redis \ - cron \ - jq \ - libldap-2.5-0 \ - libldap-common \ - libsasl2-2 \ - libsasl2-modules \ - libsasl2-modules-db \ + apache2 \ + php8.3 \ + php8.3-mysql \ + php8.3-ldap \ + php8.3-xmlrpc \ + php8.3-imap \ + php8.3-curl \ + php8.3-gd \ + php8.3-mbstring \ + php8.3-xml \ + php-cas \ + php8.3-intl \ + php8.3-zip \ + php8.3-bz2 \ + php8.3-redis \ + cron \ + jq \ + libldap-2.5-0 \ + libldap-common \ + libsasl2-2 \ + libsasl2-modules \ + libsasl2-modules-db \ && rm -rf /var/lib/apt/lists/* # Copy and set permissions for the GLPI start script COPY glpi-start.sh /opt/glpi-start.sh +# RUN chmod +x /opt/glpi-start.sh && chown glpi:glpi /opt/glpi-start.sh RUN chmod +x /opt/glpi-start.sh -# Set the entrypoint to the GLPI start script -# ENTRYPOINT ["/opt/glpi-start.sh"] -# CMD ["/opt/glpi-start.sh"] +CMD ["/bin/bash", "/opt/glpi-start.sh"] # Expose ports 80 and 443 EXPOSE 80 443 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index edd2f30..4bf4f01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,11 +10,11 @@ services: - /var/lib/mysql:/var/lib/mysql env_file: - ./mariadb.env - restart: always + restart: no #GLPI Container glpi: - image: diouxx/glpi + image: harbor.beantech.cloud/devsecops/glpi:php8.3 container_name : glpi hostname: glpi ports: @@ -24,5 +24,6 @@ services: - /etc/localtime:/etc/localtime:ro - /var/www/html/glpi/:/var/www/html/glpi environment: - - TIMEZONE=Europe/Brussels - restart: always + - TIMEZONE=Europe/Rome + - VERSION_GLPI=10.0.16 + restart: no diff --git a/glpi-start.sh b/glpi-start.sh index e67b2ad..796dcfb 100644 --- a/glpi-start.sh +++ b/glpi-start.sh @@ -1,13 +1,14 @@ #!/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) +[[ ! "$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 n -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; +if [[ -z "${TIMEZONE}" ]]; then + echo "TIMEZONE is unset" +else + 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 #Enable session.cookie_httponly @@ -17,15 +18,13 @@ FOLDER_GLPI=glpi/ FOLDER_WEB=/var/www/html/ #check if TLS_REQCERT is present -if !(grep -q "TLS_REQCERT" /etc/ldap/ldap.conf) -then +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 + 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}/bin)" ]; -then +if [ "$(ls ${FOLDER_WEB}${FOLDER_GLPI}/bin)" ]; then echo "GLPI is already installed" 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 \") @@ -52,14 +51,14 @@ TARGET_GLPI_MAJOR_VERSION=$(echo $TARGET_GLPI_VERSION | cut -d. -f1) # Compare the numeric value of the version number to the target number if [[ $LOCAL_GLPI_VERSION_NUM -lt $TARGET_GLPI_VERSION_NUM || $LOCAL_GLPI_MAJOR_VERSION -lt $TARGET_GLPI_MAJOR_VERSION ]]; then - 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 + 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 else - set +H - echo -e "\n\tDocumentRoot /var/www/html/glpi/public\n\n\t\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\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 + set +H + echo -e "\n\tDocumentRoot /var/www/html/glpi/public\n\n\t\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\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 fi #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 service cron start