From bd69096b853ea3bc4453a17f94b21d9a0b8045ff Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 11:30:50 +0100 Subject: [PATCH 01/23] refactor: split in multiple files --- latest/docker-entrypoint.d/10-fix-files.sh | 8 ++++++++ latest/docker-entrypoint.d/10-postinstall.sh | 20 ------------------- latest/docker-entrypoint.d/20-install.sh | 6 ++++++ latest/docker-entrypoint.d/30-update.sh | 6 ++++++ .../docker-entrypoint.d/40-fix-permission.sh | 5 +++++ 5 files changed, 25 insertions(+), 20 deletions(-) create mode 100755 latest/docker-entrypoint.d/10-fix-files.sh delete mode 100755 latest/docker-entrypoint.d/10-postinstall.sh create mode 100755 latest/docker-entrypoint.d/20-install.sh create mode 100755 latest/docker-entrypoint.d/30-update.sh create mode 100755 latest/docker-entrypoint.d/40-fix-permission.sh diff --git a/latest/docker-entrypoint.d/10-fix-files.sh b/latest/docker-entrypoint.d/10-fix-files.sh new file mode 100755 index 0000000..018f2a3 --- /dev/null +++ b/latest/docker-entrypoint.d/10-fix-files.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ ! -d /var/www/itsm-ng/files/_cache ]; then + mkdir -pv /var/www/itsm-ng/files/{_cache,_cron,_dumps,_graphs,_lock,_pictures,_plugins,_rss,_sessions,_tmp,_uploads} + + chown -R www-data:www-data /var/www/itsm-ng/files +fi + diff --git a/latest/docker-entrypoint.d/10-postinstall.sh b/latest/docker-entrypoint.d/10-postinstall.sh deleted file mode 100755 index 467ee00..0000000 --- a/latest/docker-entrypoint.d/10-postinstall.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - mkdir -p /var/www/itsm-ng/files/{_cache,_cron,_dumps,_graphs,_lock,_pictures,_plugins,_rss,_sessions,_tmp,_uploads} - chown -R www-data:www-data /var/www/itsm-ng/files -fi - -if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 - cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n - chown -R www-data:www-data /var/www/itsm-ng/files - rm /var/www/itsm-ng/install/install.php -fi - -if [ -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 - cd /var/www/itsm-ng && php bin/console itsmng:database:update -n -fi - -chown -R www-data:www-data /var/www/itsm-ng/files /var/www/itsm-ng/config diff --git a/latest/docker-entrypoint.d/20-install.sh b/latest/docker-entrypoint.d/20-install.sh new file mode 100755 index 0000000..b63eefd --- /dev/null +++ b/latest/docker-entrypoint.d/20-install.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then + sleep 5 + cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n +fi diff --git a/latest/docker-entrypoint.d/30-update.sh b/latest/docker-entrypoint.d/30-update.sh new file mode 100755 index 0000000..a8bdd39 --- /dev/null +++ b/latest/docker-entrypoint.d/30-update.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -f /var/www/itsm-ng/config/config_db.php ]; then + sleep 5 + cd /var/www/itsm-ng && php bin/console itsmng:database:update -n +fi diff --git a/latest/docker-entrypoint.d/40-fix-permission.sh b/latest/docker-entrypoint.d/40-fix-permission.sh new file mode 100755 index 0000000..765eb01 --- /dev/null +++ b/latest/docker-entrypoint.d/40-fix-permission.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ -f /var/www/itsm-ng/config/config_db.php ]; then + chown -R www-data:www-data /var/www/itsm-ng/files +fi From 2ef1418fc55fb5ff68fa4953e92392553c8d0cb2 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 11:37:35 +0100 Subject: [PATCH 02/23] feat: wait if mysql server is down --- latest/docker-entrypoint.d/20-install.sh | 8 +++++++- latest/docker-entrypoint.d/30-update.sh | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/latest/docker-entrypoint.d/20-install.sh b/latest/docker-entrypoint.d/20-install.sh index b63eefd..142dc73 100755 --- a/latest/docker-entrypoint.d/20-install.sh +++ b/latest/docker-entrypoint.d/20-install.sh @@ -1,6 +1,12 @@ #!/bin/sh +# Wait for MySQL to be ready +until nc -z -v -w30 $MARIADB_HOST 3306; do + echo "Waiting for MySQL connection..." + sleep 2 +done + +# Run the installation if config_db.php doesn't exist if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n fi diff --git a/latest/docker-entrypoint.d/30-update.sh b/latest/docker-entrypoint.d/30-update.sh index a8bdd39..ccb0d69 100755 --- a/latest/docker-entrypoint.d/30-update.sh +++ b/latest/docker-entrypoint.d/30-update.sh @@ -1,6 +1,12 @@ #!/bin/sh +# Wait for MySQL to be ready +until nc -z -v -w30 $MARIADB_HOST 3306; do + echo "Waiting for MySQL connection..." + sleep 2 +done + +# Run the update if config_db.php exist if [ -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 cd /var/www/itsm-ng && php bin/console itsmng:database:update -n fi From 3f82b06df10d65930ed01903a068cab3784c82f8 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 11:56:58 +0100 Subject: [PATCH 03/23] feat: add netcat --- latest/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest/Dockerfile b/latest/Dockerfile index be1cdd4..27aa542 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -4,7 +4,7 @@ ARG REPO="itsmng" ARG VERSION=2.0.1 RUN apt update && apt dist-upgrade -y && \ - apt install -y apache2 wget php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc && \ + apt install -y apache2 wget php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc netcat-traditional && \ a2enmod proxy_fcgi setenvif && \ a2enconf php8.2-fpm && \ apt-get -y clean && \ From 43689a950206284c6d061488e938199f00fd75f2 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:26:15 +0100 Subject: [PATCH 04/23] fix --- latest/docker-entrypoint.d/20-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/latest/docker-entrypoint.d/20-install.sh b/latest/docker-entrypoint.d/20-install.sh index 142dc73..d98a290 100755 --- a/latest/docker-entrypoint.d/20-install.sh +++ b/latest/docker-entrypoint.d/20-install.sh @@ -8,5 +8,6 @@ done # Run the installation if config_db.php doesn't exist if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then + chown -R www-data:www-data /var/www/itsm-ng/files/ cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n fi From a9bada7d4110fbc631bb88400391d5b8a7448017 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:29:27 +0100 Subject: [PATCH 05/23] feat: use github cache --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 262394b..2934302 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,4 +41,6 @@ jobs: docker.io/itsmng/itsm-ng:${{ github.ref_name }} docker.io/itsmng/itsm-ng:latest context: latest + - cache-from: type=gha + - cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 From 3ba5a926ec77b1f06bcd3d17cf3a0cb1bdfca5e8 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:32:11 +0100 Subject: [PATCH 06/23] fix: --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2934302..7a3829c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,6 @@ jobs: docker.io/itsmng/itsm-ng:${{ github.ref_name }} docker.io/itsmng/itsm-ng:latest context: latest - - cache-from: type=gha - - cache-to: type=gha,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 From e81a13e28bda8fe9394e150c5da75d8368ba419d Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:50:32 +0100 Subject: [PATCH 07/23] debug --- latest/docker-entrypoint.d/20-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest/docker-entrypoint.d/20-install.sh b/latest/docker-entrypoint.d/20-install.sh index d98a290..43deb6f 100755 --- a/latest/docker-entrypoint.d/20-install.sh +++ b/latest/docker-entrypoint.d/20-install.sh @@ -8,6 +8,6 @@ done # Run the installation if config_db.php doesn't exist if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - chown -R www-data:www-data /var/www/itsm-ng/files/ + chmod -R 777 /var/www/itsm-ng/files/_session cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n fi From 772746f726b48647db47882516f8c1aa9525c802 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:53:03 +0100 Subject: [PATCH 08/23] fix --- latest/docker-entrypoint.d/20-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/latest/docker-entrypoint.d/20-install.sh b/latest/docker-entrypoint.d/20-install.sh index 43deb6f..4b8194e 100755 --- a/latest/docker-entrypoint.d/20-install.sh +++ b/latest/docker-entrypoint.d/20-install.sh @@ -8,6 +8,6 @@ done # Run the installation if config_db.php doesn't exist if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - chmod -R 777 /var/www/itsm-ng/files/_session + chmod -R 777 /var/www/itsm-ng/files/_sessions cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n fi From ca2c0d201d1a1d526fd9b235aa079568537fbb8a Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Mon, 9 Dec 2024 13:59:06 +0100 Subject: [PATCH 09/23] fix: --- latest/docker-entrypoint.d/10-fix-files.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/latest/docker-entrypoint.d/10-fix-files.sh b/latest/docker-entrypoint.d/10-fix-files.sh index 018f2a3..adfbcfe 100755 --- a/latest/docker-entrypoint.d/10-fix-files.sh +++ b/latest/docker-entrypoint.d/10-fix-files.sh @@ -1,7 +1,17 @@ #!/bin/sh if [ ! -d /var/www/itsm-ng/files/_cache ]; then - mkdir -pv /var/www/itsm-ng/files/{_cache,_cron,_dumps,_graphs,_lock,_pictures,_plugins,_rss,_sessions,_tmp,_uploads} + mkdir -pv /var/www/itsm-ng/files/_cache \ + /var/www/itsm-ng/files/_cron \ + /var/www/itsm-ng/files/_dumps \ + /var/www/itsm-ng/files/_graphs \ + /var/www/itsm-ng/files/_lock \ + /var/www/itsm-ng/files/_pictures \ + /var/www/itsm-ng/files/_plugins \ + /var/www/itsm-ng/files/_rss \ + /var/www/itsm-ng/files/_sessions \ + /var/www/itsm-ng/files/_tmp \ + /var/www/itsm-ng/files/_uploads chown -R www-data:www-data /var/www/itsm-ng/files fi From ac618dd483848fa7c1f81632631125bfdae83b94 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:05:27 +0100 Subject: [PATCH 10/23] feat: add cron image --- cron/Dockerfile | 7 +++++ cron/docker-entrypoint.d/10-check_bdd.sh | 7 +++++ cron/docker-entrypoint.d/20-cron.sh | 3 ++ cron/docker-entrypoint.d/30-ocsinventory.sh | 5 +++ cron/docker-entrypoint.sh | 35 +++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 cron/Dockerfile create mode 100755 cron/docker-entrypoint.d/10-check_bdd.sh create mode 100755 cron/docker-entrypoint.d/20-cron.sh create mode 100755 cron/docker-entrypoint.d/30-ocsinventory.sh create mode 100755 cron/docker-entrypoint.sh diff --git a/cron/Dockerfile b/cron/Dockerfile new file mode 100644 index 0000000..7da22aa --- /dev/null +++ b/cron/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:bookworm-slim + +COPY ./docker-entrypoint.sh /docker-entrypoint.sh +COPY ./docker-entrypoint.d /docker-entrypoint.d + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD exit diff --git a/cron/docker-entrypoint.d/10-check_bdd.sh b/cron/docker-entrypoint.d/10-check_bdd.sh new file mode 100755 index 0000000..54bc978 --- /dev/null +++ b/cron/docker-entrypoint.d/10-check_bdd.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Wait for MySQL to be ready +until nc -z -v -w30 $MARIADB_HOST 3306; do + echo "Waiting for MySQL connection..." + sleep 2 +done diff --git a/cron/docker-entrypoint.d/20-cron.sh b/cron/docker-entrypoint.d/20-cron.sh new file mode 100755 index 0000000..582976f --- /dev/null +++ b/cron/docker-entrypoint.d/20-cron.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +php /var/www/itsm-ng/front/cron.php diff --git a/cron/docker-entrypoint.d/30-ocsinventory.sh b/cron/docker-entrypoint.d/30-ocsinventory.sh new file mode 100755 index 0000000..c7f04f2 --- /dev/null +++ b/cron/docker-entrypoint.d/30-ocsinventory.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ ! -f /var/www/itsm-ng/plugins/ocsinventoryng/scripts/run.php ]; then + php /var/www/itsm-ng/plugins/ocsinventoryng/scripts/run.php +fi diff --git a/cron/docker-entrypoint.sh b/cron/docker-entrypoint.sh new file mode 100755 index 0000000..fcdda4c --- /dev/null +++ b/cron/docker-entrypoint.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# vim:sw=4:ts=4:et + +set -e + +if [ -z "${ITSMNG_ENTRYPOINT_QUIET_LOGS:-}" ]; then + exec 3>&1 + else + exec 3>/dev/null +fi + +if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" + + echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if ! [ -x "$f" ]; then + chmod +x $f + fi + + echo -e >&3 "\n$0: Launching ${f}\n" + "$f" + ;; + *) echo -e >&3 "\n$0: Ignoring ${f}\n" ;; + esac + done + + echo >&3 "$0: Configuration complete; ready for start up" +else + echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration" +fi + +exec "$@" From da37b0a5f77834a3c0c9b126a5f7b68422214130 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:07:15 +0100 Subject: [PATCH 11/23] feat: build cron image in ci --- .github/workflows/build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7a3829c..ec5cc88 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,3 +44,17 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 + + + + - name: Build and push cron image + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ghcr.io/itsmng/itsm-ng:${{ github.ref_name }}-cron + ghcr.io/itsmng/itsm-ng:latest-cron + context: latest + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 From 1e472e17338c2736934f3496c9de3ebfcddb19e5 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:08:52 +0100 Subject: [PATCH 12/23] refactor: remove old docker images --- 1.6.5/Dockerfile | 27 -------------- 1.6.5/Makefile | 14 -------- 1.6.5/docker-compose.yml | 40 --------------------- 1.6.5/docker-entrypoint.d/10-postinstall.sh | 15 -------- 1.6.5/docker-entrypoint.sh | 35 ------------------ 1.6.5/files/itsm-ng.conf | 9 ----- 6 files changed, 140 deletions(-) delete mode 100644 1.6.5/Dockerfile delete mode 100644 1.6.5/Makefile delete mode 100644 1.6.5/docker-compose.yml delete mode 100755 1.6.5/docker-entrypoint.d/10-postinstall.sh delete mode 100755 1.6.5/docker-entrypoint.sh delete mode 100644 1.6.5/files/itsm-ng.conf diff --git a/1.6.5/Dockerfile b/1.6.5/Dockerfile deleted file mode 100644 index 5fb00fa..0000000 --- a/1.6.5/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM debian:bookworm-slim - -ARG REPO="itsmng" -ARG VERSION=1.6.5 - -RUN apt update && apt dist-upgrade -y && \ - apt install -y apache2 wget php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc && \ - a2enmod proxy_fcgi setenvif && \ - a2enconf php8.2-fpm && \ - apt-get -y clean && \ - rm -r /var/lib/apt/lists/* && \ - rm /etc/apache2/sites-enabled/000-default.conf - -RUN cd /var/www && \ - wget -q "https://github.com/$REPO/itsm-ng/releases/download/v$VERSION/itsm-ng-$VERSION.tgz" && \ - tar -xf itsm-ng-${VERSION}.tgz && \ - rm -rf itsm-ng-${VERSION}.tgz && \ - chown -R www-data:www-data /var/www/itsm-ng - -COPY files/itsm-ng.conf /etc/apache2/sites-enabled/ -COPY ./docker-entrypoint.sh /docker-entrypoint.sh -COPY ./docker-entrypoint.d /docker-entrypoint.d - -EXPOSE 80 - -ENTRYPOINT ["/docker-entrypoint.sh"] -CMD /etc/init.d/php8.2-fpm start && apachectl -D FOREGROUND diff --git a/1.6.5/Makefile b/1.6.5/Makefile deleted file mode 100644 index 5e19717..0000000 --- a/1.6.5/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CTN=`which podman >/dev/null 2>&1 && echo podman || echo docker` -IMAGENAME="itsmng" -REPO="itsmng" -VVERSION="1.6.4" - - -all: - make -B itsmng - -clean: - $(CTN) rmi -f $(IMAGENAME):$(VVERSION) - -itsmng: - $(CTN) build --build-arg VERSION="$(VVERSION)" --build-arg REPO="$(REPO)" -t $(IMAGENAME):$(VVERSION) . diff --git a/1.6.5/docker-compose.yml b/1.6.5/docker-compose.yml deleted file mode 100644 index 3607a28..0000000 --- a/1.6.5/docker-compose.yml +++ /dev/null @@ -1,40 +0,0 @@ -version: '3' -services: - itsmweb : - image : docker.io/itsmng/itsm-ng:1.6.5 - depends_on: - - itsmdb - container_name : itsmweb - restart: always - ports : - - "8080:80" - volumes : - - itsmng-config:/var/www/itsm-ng/config - - itsmng-plugins:/var/www/itsm-ng/plugins - - itsmng-files:/var/www/itsm-ng/files - environment: - MARIADB_HOST : itsmdb - MARIADB_USER : itsmng - MARIADB_PASSWORD : itsmng - MARIADB_DATABASE : itsmng - itsmdb : - image: docker.io/mariadb:10.6 - container_name: itsmdb - command: --default-authentication-plugin=mysql_native_password - restart: always - volumes : - - itsmng-data:/var/lib/mysql - environment: - MARIADB_AUTO_UPGRADE: "yes" - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: "yes" - MYSQL_ROOT_PASSWORD: iamastrongpassword - MARIADB_USER : itsmng - MARIADB_PASSWORD : itsmng - MARIADB_DATABASE : itsmng - -volumes: - itsmng-config: - itsmng-plugins: - itsmng-files: - itsmng-data: - diff --git a/1.6.5/docker-entrypoint.d/10-postinstall.sh b/1.6.5/docker-entrypoint.d/10-postinstall.sh deleted file mode 100755 index a46b794..0000000 --- a/1.6.5/docker-entrypoint.d/10-postinstall.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -if [ ! -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 - cd /var/www/itsm-ng && php bin/console itsmng:database:install -H $MARIADB_HOST -u $MARIADB_USER -p $MARIADB_PASSWORD -d $MARIADB_DATABASE -n - chown -R www-data:www-data /var/www/itsm-ng/files - rm /var/www/itsm-ng/install/install.php -fi - -if [ -f /var/www/itsm-ng/config/config_db.php ]; then - sleep 5 - cd /var/www/itsm-ng && php bin/console itsmng:database:update -n -fi - -chown -R www-data:www-data /var/www/itsm-ng/files /var/www/itsm-ng/config diff --git a/1.6.5/docker-entrypoint.sh b/1.6.5/docker-entrypoint.sh deleted file mode 100755 index fcdda4c..0000000 --- a/1.6.5/docker-entrypoint.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# vim:sw=4:ts=4:et - -set -e - -if [ -z "${ITSMNG_ENTRYPOINT_QUIET_LOGS:-}" ]; then - exec 3>&1 - else - exec 3>/dev/null -fi - -if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then - echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" - - echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" - find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do - case "$f" in - *.sh) - if ! [ -x "$f" ]; then - chmod +x $f - fi - - echo -e >&3 "\n$0: Launching ${f}\n" - "$f" - ;; - *) echo -e >&3 "\n$0: Ignoring ${f}\n" ;; - esac - done - - echo >&3 "$0: Configuration complete; ready for start up" -else - echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration" -fi - -exec "$@" diff --git a/1.6.5/files/itsm-ng.conf b/1.6.5/files/itsm-ng.conf deleted file mode 100644 index e396764..0000000 --- a/1.6.5/files/itsm-ng.conf +++ /dev/null @@ -1,9 +0,0 @@ - - DocumentRoot /var/www/itsm-ng - - - Options -Indexes +FollowSymLinks - AllowOverride All - Require all granted - - From 04fedf2485803e4e2bbc60cc44385dfc2f43318f Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:10:00 +0100 Subject: [PATCH 13/23] fix: use cron folder in ci --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec5cc88..d618104 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,7 @@ jobs: tags: | ghcr.io/itsmng/itsm-ng:${{ github.ref_name }}-cron ghcr.io/itsmng/itsm-ng:latest-cron - context: latest + context: cron cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/arm64 From 47f4ed152b06080ec82674192f5e5fc0a92685e3 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:17:25 +0100 Subject: [PATCH 14/23] fix: netcat commad --- cron/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cron/Dockerfile b/cron/Dockerfile index 7da22aa..c6b2470 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,5 +1,7 @@ FROM debian:bookworm-slim +RUN apt update && apt install -y netcat-traditional + COPY ./docker-entrypoint.sh /docker-entrypoint.sh COPY ./docker-entrypoint.d /docker-entrypoint.d From c010aea80fa967234693cabd7e8f0abd2f5393d5 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 10:46:48 +0100 Subject: [PATCH 15/23] feat: fix php command not found --- cron/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron/Dockerfile b/cron/Dockerfile index c6b2470..2dd0d17 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,6 +1,6 @@ FROM debian:bookworm-slim -RUN apt update && apt install -y netcat-traditional +RUN apt update && apt install -y php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc netcat-traditional COPY ./docker-entrypoint.sh /docker-entrypoint.sh COPY ./docker-entrypoint.d /docker-entrypoint.d From 82f38ddf6a1c877c791574d0db247f8af998ff15 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 11:17:50 +0100 Subject: [PATCH 16/23] refactor: use base image --- cron/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cron/Dockerfile b/cron/Dockerfile index 2dd0d17..037bdd6 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,6 +1,4 @@ -FROM debian:bookworm-slim - -RUN apt update && apt install -y php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc netcat-traditional +FROM ghcr.io/itsmng/itsm-ng:latest-cron COPY ./docker-entrypoint.sh /docker-entrypoint.sh COPY ./docker-entrypoint.d /docker-entrypoint.d From 6990f652c5fa36ac218f4ca9a8704a67bad46ad0 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 11:35:44 +0100 Subject: [PATCH 17/23] fix: download itsmng release --- cron/Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cron/Dockerfile b/cron/Dockerfile index 037bdd6..a0c4360 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,5 +1,13 @@ FROM ghcr.io/itsmng/itsm-ng:latest-cron +ARG REPO="itsmng" +ARG VERSION=2.0.2 + +RUN cd /var/www && \ + wget -q "https://github.com/$REPO/itsm-ng/releases/download/v$VERSION/itsm-ng-v$VERSION.tgz" && \ + tar -xf itsm-ng-v${VERSION}.tgz && \ + rm -rf itsm-ng-v${VERSION}.tgz + COPY ./docker-entrypoint.sh /docker-entrypoint.sh COPY ./docker-entrypoint.d /docker-entrypoint.d From 551db231f70b05ae776e980fbd43f841f18bd8e5 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 11:46:40 +0100 Subject: [PATCH 18/23] fix: wget error --- cron/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cron/Dockerfile b/cron/Dockerfile index a0c4360..915eb4c 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -3,7 +3,9 @@ FROM ghcr.io/itsmng/itsm-ng:latest-cron ARG REPO="itsmng" ARG VERSION=2.0.2 -RUN cd /var/www && \ +RUN apt update &&\ + apt install wget -y && \ + cd /var/www && \ wget -q "https://github.com/$REPO/itsm-ng/releases/download/v$VERSION/itsm-ng-v$VERSION.tgz" && \ tar -xf itsm-ng-v${VERSION}.tgz && \ rm -rf itsm-ng-v${VERSION}.tgz From 8080074161b5aa14b4fec7b4b4dc59921eab8235 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 11:54:08 +0100 Subject: [PATCH 19/23] fix: condition --- cron/docker-entrypoint.d/30-ocsinventory.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron/docker-entrypoint.d/30-ocsinventory.sh b/cron/docker-entrypoint.d/30-ocsinventory.sh index c7f04f2..7774b7d 100755 --- a/cron/docker-entrypoint.d/30-ocsinventory.sh +++ b/cron/docker-entrypoint.d/30-ocsinventory.sh @@ -1,5 +1,5 @@ #!/bin/sh -if [ ! -f /var/www/itsm-ng/plugins/ocsinventoryng/scripts/run.php ]; then +if [ -f /var/www/itsm-ng/plugins/ocsinventoryng/scripts/run.php ]; then php /var/www/itsm-ng/plugins/ocsinventoryng/scripts/run.php fi From 446bcbb7f48c85a7952eb4799ef8e020b569d40c Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 13:16:24 +0100 Subject: [PATCH 20/23] refactor: remove VERSION refine --- latest/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/latest/Dockerfile b/latest/Dockerfile index 27aa542..42db96f 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -1,7 +1,6 @@ FROM debian:bookworm-slim ARG REPO="itsmng" -ARG VERSION=2.0.1 RUN apt update && apt dist-upgrade -y && \ apt install -y apache2 wget php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc netcat-traditional && \ From 0dc2db60932bdcc41c971508f873df488a60e815 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 13:18:14 +0100 Subject: [PATCH 21/23] fix: use version tag in ci --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d618104..d403c1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,6 +40,8 @@ jobs: ghcr.io/itsmng/itsm-ng:latest docker.io/itsmng/itsm-ng:${{ github.ref_name }} docker.io/itsmng/itsm-ng:latest + build-args: | + VERSION=${{ github.ref_name }} context: latest cache-from: type=gha cache-to: type=gha,mode=max @@ -54,6 +56,8 @@ jobs: tags: | ghcr.io/itsmng/itsm-ng:${{ github.ref_name }}-cron ghcr.io/itsmng/itsm-ng:latest-cron + build-args: | + VERSION=${{ github.ref_name }} context: cron cache-from: type=gha cache-to: type=gha,mode=max From cac322ffd1cff2c59a2e83cce54ccf5fa107e2c8 Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 13:22:37 +0100 Subject: [PATCH 22/23] fix: arg --- latest/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/latest/Dockerfile b/latest/Dockerfile index 42db96f..dc5d1a3 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -1,6 +1,7 @@ FROM debian:bookworm-slim ARG REPO="itsmng" +ARG VERSION RUN apt update && apt dist-upgrade -y && \ apt install -y apache2 wget php php-fpm php-mysql php-intl php-mbstring php-gd php-ldap php-simplexml php-curl php-apcu php-xmlrpc netcat-traditional && \ From e8187d84cabf5454b2c4f5ee0f05a8d237a9732e Mon Sep 17 00:00:00 2001 From: Florian Blanchet Date: Wed, 11 Dec 2024 13:24:44 +0100 Subject: [PATCH 23/23] fix: arg --- cron/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cron/Dockerfile b/cron/Dockerfile index 915eb4c..d7ea443 100644 --- a/cron/Dockerfile +++ b/cron/Dockerfile @@ -1,7 +1,7 @@ FROM ghcr.io/itsmng/itsm-ng:latest-cron ARG REPO="itsmng" -ARG VERSION=2.0.2 +ARG VERSION RUN apt update &&\ apt install wget -y && \