From 3939dfbea428f21503eaae85329c3b4a486986cb Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Wed, 26 Nov 2025 14:38:47 +0100 Subject: [PATCH 01/28] Fix --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3ed1911..6681c94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,8 @@ opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini" #SUPERVISORD RUN mkdir -p /var/log/supervisor -COPY supervisor/* /etc/supervisor +COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf # Setup Crone RUN mkdir -p /var/log/cron && \ -- 2.54.0 From 189dc975bd35cf9adc8febcea6f56e24274c1f5b Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Wed, 28 Jan 2026 10:40:10 +0100 Subject: [PATCH 02/28] Refactor Docker setup: move Dockerfiles to respective directories and add supervisor configurations --- .gitea/workflows/docker-build.yaml | 36 +++++++- Dockerfile => apache/Dockerfile | 0 .../supervisor}/conf.d/laravel-queues.conf | 0 .../supervisor}/supervisord.conf | 0 fmp-alpine/Dockerfile | 83 +++++++++++++++++++ 5 files changed, 116 insertions(+), 3 deletions(-) rename Dockerfile => apache/Dockerfile (100%) rename {supervisor => apache/supervisor}/conf.d/laravel-queues.conf (100%) rename {supervisor => apache/supervisor}/supervisord.conf (100%) create mode 100644 fmp-alpine/Dockerfile diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index f90c93b..8dddafa 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -33,10 +33,8 @@ jobs: - uses: docker/build-push-action@v6 with: - context: . + context: ./apache/ push: true - labels: | - org.steelants.image.traffic.version=${{ env.release_version }} tags: git.steelants.cz/steelants/docker_php_base:latest # ✅ Notifikace při úspěšném deploymentu @@ -52,6 +50,38 @@ jobs: Commit: ${{ github.sha }} Version: ${{ env.release_version }} + # ❌ Notifikace při neúspěšném deploymentu + - name: Discord Webhook Failure + if: failure() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ❌ Build failed! + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + Version: ${{ env.release_version }} + + - uses: docker/build-push-action@v6 + with: + context: ./fmp-alpine/ + push: true + tags: git.steelants.cz/steelants/docker_php_base:fpm-alpine-latest + + # ✅ Notifikace při úspěšném deploymentu + - name: Discord Webhook Success + if: success() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ✅ Build successful! + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + Version: ${{ env.release_version }} + # ❌ Notifikace při neúspěšném deploymentu - name: Discord Webhook Failure if: failure() diff --git a/Dockerfile b/apache/Dockerfile similarity index 100% rename from Dockerfile rename to apache/Dockerfile diff --git a/supervisor/conf.d/laravel-queues.conf b/apache/supervisor/conf.d/laravel-queues.conf similarity index 100% rename from supervisor/conf.d/laravel-queues.conf rename to apache/supervisor/conf.d/laravel-queues.conf diff --git a/supervisor/supervisord.conf b/apache/supervisor/supervisord.conf similarity index 100% rename from supervisor/supervisord.conf rename to apache/supervisor/supervisord.conf diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile new file mode 100644 index 0000000..a573415 --- /dev/null +++ b/fmp-alpine/Dockerfile @@ -0,0 +1,83 @@ +FROM php:8.4-fpm-alpine + +ENV TZ="Europe/Prague" \ + PHP_OPCACHE_ENABLE=1 \ + PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \ + PHP_OPCACHE_REVALIDATE_FREQ=0 \ + PHP_OPCACHE_MEMORY_CONSUMPTION=192 \ + PHP_OPCACHE_MAX_ACCELERATED_FILES=20000 \ + PHP_OPCACHE_MAX_WASTED_PERCENTAGE=10 \ + PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ + APP_ENV=production \ + APP_DEBUG=false + +RUN apk add --no-cache \ + tzdata \ + bash \ + ca-certificates \ + libpq \ + libzip \ + imagemagick \ + imagemagick-dev \ + librsvg \ + freetype \ + libjpeg-turbo \ + libpng \ + icu \ + oniguruma \ + libxml2 + +RUN apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + postgresql-dev \ + libzip-dev \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + icu-dev \ + libxml2-dev + +RUN docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg \ + && docker-php-ext-install -j$(nproc) \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + zip \ + bcmath \ + soap \ + sockets \ + pcntl \ + gd \ + intl \ + opcache + +RUN pecl install imagick \ + && docker-php-ext-enable imagick + +RUN apk del .build-deps + +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ + && echo "date.timezone=${TZ}" > "$PHP_INI_DIR/conf.d/99-timezone.ini" + +RUN { \ + echo "memory_limit=256M"; \ + echo "upload_max_filesize=100M"; \ + echo "post_max_size=100M"; \ + echo "realpath_cache_size=4096K"; \ + echo "realpath_cache_ttl=600"; \ +} > "$PHP_INI_DIR/conf.d/99-laravel.ini" + +RUN { \ + echo "[opcache]"; \ + echo "opcache.enable=${PHP_OPCACHE_ENABLE}"; \ + echo "opcache.enable_cli=0"; \ + echo "opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}"; \ + echo "opcache.revalidate_freq=${PHP_OPCACHE_REVALIDATE_FREQ}"; \ + echo "opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}"; \ + echo "opcache.interned_strings_buffer=${PHP_OPCACHE_INTERNED_STRINGS_BUFFER}"; \ + echo "opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}"; \ + echo "opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}"; \ + echo "opcache.save_comments=1"; \ +} > "$PHP_INI_DIR/conf.d/10-opcache.ini" \ No newline at end of file -- 2.54.0 From b6f8151bd4746856e2da292d0869bf8b923455a1 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Wed, 28 Jan 2026 10:41:13 +0100 Subject: [PATCH 03/28] Fixes --- .gitea/workflows/docker-build.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 8dddafa..4de8997 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -44,7 +44,7 @@ jobs: with: webhook-url: ${{ secrets.WEBHOOK_URL }} content: | - ✅ Build successful! + ✅ APACHE - Build successful! Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} @@ -57,7 +57,7 @@ jobs: with: webhook-url: ${{ secrets.WEBHOOK_URL }} content: | - ❌ Build failed! + ❌ APACHE - Build failed! Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} @@ -76,7 +76,7 @@ jobs: with: webhook-url: ${{ secrets.WEBHOOK_URL }} content: | - ✅ Build successful! + ✅ FMP - ALPINE - Build successful! Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} @@ -89,7 +89,7 @@ jobs: with: webhook-url: ${{ secrets.WEBHOOK_URL }} content: | - ❌ Build failed! + ❌ FMP - ALPINE - Build failed! Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} -- 2.54.0 From c498df805cd6a9bc4b6f9e6a88373037a1a8879e Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Wed, 28 Jan 2026 11:16:03 +0100 Subject: [PATCH 04/28] Fix --- fmp-alpine/Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index a573415..402c1cb 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -35,7 +35,8 @@ RUN apk add --no-cache --virtual .build-deps \ libjpeg-turbo-dev \ libpng-dev \ icu-dev \ - libxml2-dev + libxml2-dev \ + linux-headers RUN docker-php-ext-configure gd \ --with-freetype \ @@ -47,11 +48,11 @@ RUN docker-php-ext-configure gd \ zip \ bcmath \ soap \ - sockets \ - pcntl \ gd \ intl \ - opcache + opcache \ + sockets \ + pcntl RUN pecl install imagick \ && docker-php-ext-enable imagick -- 2.54.0 From 34cc835f1cabb59c9f0f890ec19e6a1ff67e7178 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Thu, 29 Jan 2026 15:36:15 +0100 Subject: [PATCH 05/28] Fixes --- .gitea/workflows/docker-build-dev.yaml | 66 -------------------------- 1 file changed, 66 deletions(-) delete mode 100644 .gitea/workflows/docker-build-dev.yaml diff --git a/.gitea/workflows/docker-build-dev.yaml b/.gitea/workflows/docker-build-dev.yaml deleted file mode 100644 index 49f14fa..0000000 --- a/.gitea/workflows/docker-build-dev.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: "Build - Docker Image - RC" -run-name: ${{ gitea.actor }} is runs ci pipeline - -on: - push: - branches: - - dev - - schedule: - - cron: "0 1 * * *" - -concurrency: - group: docker-build-dev - cancel-in-progress: true - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - packages: write - container: - image: catthehacker/ubuntu:act-latest - steps: - - uses: actions/checkout@v3 - - - uses: docker/setup-buildx-action@v1 - - - uses: docker/login-action@v3 - with: - registry: git.steelants.cz - username: ${{ secrets.GITEAUSER }} - password: ${{ secrets.GITEAPASSWD }} - - - uses: docker/build-push-action@v6 - with: - context: . - push: true - labels: | - org.steelants.image.traffic.version=${{ env.release_version }} - tags: git.steelants.cz/steelants/docker_php_base:dev - - # ✅ Notifikace při úspěšném deploymentu - - name: Discord Webhook Success - if: success() - uses: tsickert/discord-webhook@v6.0.0 - with: - webhook-url: ${{ secrets.WEBHOOK_URL }} - content: | - ✅ Build successful! - Repo: ${{ github.repository }} - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - Version: ${{ env.release_version }} - - # ❌ Notifikace při neúspěšném deploymentu - - name: Discord Webhook Failure - if: failure() - uses: tsickert/discord-webhook@v6.0.0 - with: - webhook-url: ${{ secrets.WEBHOOK_URL }} - content: | - ❌ Build failed! - Repo: ${{ github.repository }} - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - Version: ${{ env.release_version }} \ No newline at end of file -- 2.54.0 From 85ed62b401c8d630bd88aae97f6adba820836fe3 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Thu, 29 Jan 2026 15:37:40 +0100 Subject: [PATCH 06/28] Fix context paths in Docker build configuration --- .gitea/workflows/docker-build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 4de8997..bdf40dc 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -33,7 +33,7 @@ jobs: - uses: docker/build-push-action@v6 with: - context: ./apache/ + context: apache push: true tags: git.steelants.cz/steelants/docker_php_base:latest @@ -65,7 +65,7 @@ jobs: - uses: docker/build-push-action@v6 with: - context: ./fmp-alpine/ + context: fmp-alpine push: true tags: git.steelants.cz/steelants/docker_php_base:fpm-alpine-latest -- 2.54.0 From a9e3ace71799cdbb0d1d11b153866dce2cdbf040 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 3 Feb 2026 08:18:23 +0100 Subject: [PATCH 07/28] Fix oo cache --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 85d492e..21f5c2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,7 +64,7 @@ RUN docker-php-ext-install \ soap \ gd -RUN docker-php-ext-enable imagick +RUN docker-php-ext-enable imagick opcache # PHP RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ -- 2.54.0 From 7461f0a25e9e4b6f8f43971db50988319f6b312e Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 3 Feb 2026 09:22:25 +0100 Subject: [PATCH 08/28] Fixes --- apache/Dockerfile | 7 ++++++- fmp-alpine/Dockerfile | 29 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apache/Dockerfile b/apache/Dockerfile index 21f5c2b..4f7b858 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -52,6 +52,9 @@ RUN --mount=type=cache,target=/var/cache/apt \ RUN a2enmod rewrite # Install PHP extensions +RUN docker-php-ext-configure \ + opcache --enable-opcache + RUN docker-php-ext-install \ pdo_mysql \ pgsql \ @@ -64,7 +67,9 @@ RUN docker-php-ext-install \ soap \ gd -RUN docker-php-ext-enable imagick opcache +RUN docker-php-ext-enable \ + imagick \ + opcache # PHP RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index 402c1cb..87a2384 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -38,21 +38,20 @@ RUN apk add --no-cache --virtual .build-deps \ libxml2-dev \ linux-headers -RUN docker-php-ext-configure gd \ - --with-freetype \ - --with-jpeg \ - && docker-php-ext-install -j$(nproc) \ - pdo_mysql \ - pdo_pgsql \ - pgsql \ - zip \ - bcmath \ - soap \ - gd \ - intl \ - opcache \ - sockets \ - pcntl +RUN docker-php-ext-configure \ + gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + zip \ + bcmath \ + soap \ + gd \ + intl \ + opcache \ + sockets \ + pcntl RUN pecl install imagick \ && docker-php-ext-enable imagick -- 2.54.0 From 16bd69589061cdc846897e2938e2849a9d163a9a Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 3 Feb 2026 09:24:57 +0100 Subject: [PATCH 09/28] Small Fixes --- apache/Dockerfile | 4 ++-- apache/supervisor/conf.d/laravel-queues.conf | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apache/Dockerfile b/apache/Dockerfile index 4f7b858..3e2ce5e 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -79,7 +79,7 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini" #OPCACHE -RUN echo '\n\ +RUN echo "\n\ [opcache]\n\ opcache.enable=1\n\ opcache.revalidate_freq=0\n\ @@ -88,7 +88,7 @@ opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}\n\ opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}\n\ opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}\n\ opcache.interned_strings_buffer=16\n\ -opcache.fast_shutdown=1' >> "$PHP_INI_DIR/conf.d/opcache.ini" +opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini" #SUPERVISORD RUN mkdir -p /var/log/supervisor diff --git a/apache/supervisor/conf.d/laravel-queues.conf b/apache/supervisor/conf.d/laravel-queues.conf index ab09892..31c7045 100644 --- a/apache/supervisor/conf.d/laravel-queues.conf +++ b/apache/supervisor/conf.d/laravel-queues.conf @@ -1,19 +1,19 @@ [program:queue-default] -command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=default,importstatistics +command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics user=www-data autostart=true autorestart=true stdout_logfile=/var/log/supervisor/queue-default.log [program:queue-statistics] -command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=statistics +command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=statistics user=www-data autostart=true autorestart=true stdout_logfile=/var/log/supervisor/queue-statistics.log [program:queue-detections] -command=/usr/local/bin/php /var/www/html/artisan queue:work --queue=detections +command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=detections user=www-data autostart=true autorestart=true -- 2.54.0 From 24381ef43f5099233208b6c1258a6a97315c6040 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Tue, 3 Feb 2026 09:25:07 +0100 Subject: [PATCH 10/28] Update queue-statistics command sleep duration to 5 seconds --- apache/supervisor/conf.d/laravel-queues.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache/supervisor/conf.d/laravel-queues.conf b/apache/supervisor/conf.d/laravel-queues.conf index 31c7045..74d99b5 100644 --- a/apache/supervisor/conf.d/laravel-queues.conf +++ b/apache/supervisor/conf.d/laravel-queues.conf @@ -6,7 +6,7 @@ autorestart=true stdout_logfile=/var/log/supervisor/queue-default.log [program:queue-statistics] -command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=statistics +command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=5 --tries=3 --queue=statistics user=www-data autostart=true autorestart=true -- 2.54.0 From 4706600cb082eef14eaef51adbb7679cc4c22fe2 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sun, 15 Feb 2026 18:50:25 +0100 Subject: [PATCH 11/28] Add additional PHP extensions and system dependencies to Dockerfile --- apache/Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apache/Dockerfile b/apache/Dockerfile index 85d492e..9436f69 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -23,6 +23,9 @@ RUN --mount=type=cache,target=/var/cache/apt \ libzip-dev \ zip \ unzip \ + zlib1g-dev \ + libicu-dev \ + g++ \ nodejs \ npm \ cron \ @@ -51,6 +54,8 @@ RUN --mount=type=cache,target=/var/cache/apt \ # Enable Apache mod_rewrite for URL rewriting RUN a2enmod rewrite +RUN docker-php-ext-configure intl + # Install PHP extensions RUN docker-php-ext-install \ pdo_mysql \ @@ -62,7 +67,8 @@ RUN docker-php-ext-install \ sockets\ bcmath \ soap \ - gd + gd \ + intl RUN docker-php-ext-enable imagick -- 2.54.0 From 88f12b18bceba12f710487240dee0347e942f9bc Mon Sep 17 00:00:00 2001 From: Patrik Sztefek Date: Tue, 17 Feb 2026 18:27:35 +0100 Subject: [PATCH 12/28] Readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6556b52 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +``` +docker build -t git.steelants.cz/steelants/docker_php_base:latest . +docker push git.steelants.cz/steelants/docker_php_base:latest +``` \ No newline at end of file -- 2.54.0 From 4db9a0f2248a4099e2dbb3f60341bcfc382cad6e Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 17 Feb 2026 18:34:33 +0000 Subject: [PATCH 13/28] Update fmp-alpine/Dockerfile --- fmp-alpine/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index 87a2384..b684622 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -49,6 +49,7 @@ RUN docker-php-ext-configure \ soap \ gd \ intl \ + bcmath \ opcache \ sockets \ pcntl -- 2.54.0 From d0440712b569f8812a1fc34e5ad6599007d65040 Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 17 Feb 2026 18:36:41 +0000 Subject: [PATCH 14/28] Update fmp-alpine/Dockerfile --- fmp-alpine/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index b684622..87a2384 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -49,7 +49,6 @@ RUN docker-php-ext-configure \ soap \ gd \ intl \ - bcmath \ opcache \ sockets \ pcntl -- 2.54.0 From bc7dd69990d79a0668aba05e65e738d2dce1d4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C5=A0paninger?= Date: Tue, 17 Feb 2026 19:07:30 +0000 Subject: [PATCH 15/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6556b52..6f61e50 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ``` -docker build -t git.steelants.cz/steelants/docker_php_base:latest . +docker build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t git.steelants.cz/steelants/docker_php_base:latest ./apache docker push git.steelants.cz/steelants/docker_php_base:latest ``` \ No newline at end of file -- 2.54.0 From 39f26ae755c2366ccddf3f0056416fa42c7b9de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20=C5=A0paninger?= Date: Tue, 17 Feb 2026 19:07:40 +0000 Subject: [PATCH 16/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f61e50..b6e9223 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -``` +```bash docker build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t git.steelants.cz/steelants/docker_php_base:latest ./apache docker push git.steelants.cz/steelants/docker_php_base:latest ``` \ No newline at end of file -- 2.54.0 From fdb2ce81556df117915dbc7b95079c4f64824808 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sun, 22 Feb 2026 16:33:58 +0100 Subject: [PATCH 17/28] FIx --- .gitea/workflows/docker-build.yaml | 108 ++++++++++++++++------------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index bdf40dc..46489fd 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -5,52 +5,97 @@ on: push: branches: - main - + schedule: - cron: "0 1 * * *" + workflow_dispatch: + concurrency: group: docker-build-prod cancel-in-progress: true jobs: - publish: + + # ─── APACHE ─────────────────────────────────────────────────────────────── + + build-apache-amd64: + runs-on: ubuntu-latest + permissions: + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: apache + platforms: linux/amd64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + build-apache-arm64: + runs-on: ubuntu-latest-arm + permissions: + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: apache + platforms: linux/arm64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + manifest-apache: + needs: [build-apache-amd64, build-apache-arm64] runs-on: ubuntu-latest permissions: packages: write container: image: catthehacker/ubuntu:act-latest steps: - - uses: actions/checkout@v3 - - uses: docker/setup-buildx-action@v1 - - uses: docker/login-action@v3 with: registry: git.steelants.cz username: ${{ secrets.GITEAUSER }} password: ${{ secrets.GITEAPASSWD }} + - name: Create and push multi-arch manifest + run: | + docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:latest \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-amd64.outputs.digest }} \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-arm64.outputs.digest }} - - uses: docker/build-push-action@v6 - with: - context: apache - push: true - tags: git.steelants.cz/steelants/docker_php_base:latest - - # ✅ Notifikace při úspěšném deploymentu - name: Discord Webhook Success if: success() uses: tsickert/discord-webhook@v6.0.0 with: webhook-url: ${{ secrets.WEBHOOK_URL }} content: | - ✅ APACHE - Build successful! + ✅ APACHE - Build successful! (amd64 + arm64) Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} - Version: ${{ env.release_version }} - # ❌ Notifikace při neúspěšném deploymentu - name: Discord Webhook Failure if: failure() uses: tsickert/discord-webhook@v6.0.0 @@ -61,36 +106,3 @@ jobs: Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} - Version: ${{ env.release_version }} - - - uses: docker/build-push-action@v6 - with: - context: fmp-alpine - push: true - tags: git.steelants.cz/steelants/docker_php_base:fpm-alpine-latest - - # ✅ Notifikace při úspěšném deploymentu - - name: Discord Webhook Success - if: success() - uses: tsickert/discord-webhook@v6.0.0 - with: - webhook-url: ${{ secrets.WEBHOOK_URL }} - content: | - ✅ FMP - ALPINE - Build successful! - Repo: ${{ github.repository }} - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - Version: ${{ env.release_version }} - - # ❌ Notifikace při neúspěšném deploymentu - - name: Discord Webhook Failure - if: failure() - uses: tsickert/discord-webhook@v6.0.0 - with: - webhook-url: ${{ secrets.WEBHOOK_URL }} - content: | - ❌ FMP - ALPINE - Build failed! - Repo: ${{ github.repository }} - Branch: ${{ github.ref_name }} - Commit: ${{ github.sha }} - Version: ${{ env.release_version }} \ No newline at end of file -- 2.54.0 From 2ab9a9c1d5265e1282777696296bc9e9125b3fbc Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Mon, 24 Aug 2026 20:54:08 +0200 Subject: [PATCH 18/28] Fix Image jpeg support for imagick --- apache/Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apache/Dockerfile b/apache/Dockerfile index dd4ad3c..75e53b7 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -25,6 +25,10 @@ RUN --mount=type=cache,target=/var/cache/apt \ unzip \ zlib1g-dev \ libicu-dev \ + libjpeg-dev \ + libpng-dev \ + libwebp-dev \ + libfreetype6-dev \ g++ \ nodejs \ npm \ @@ -56,6 +60,8 @@ RUN a2enmod rewrite RUN docker-php-ext-configure intl +RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp + # Install PHP extensions RUN docker-php-ext-configure \ opcache --enable-opcache @@ -77,6 +83,10 @@ RUN docker-php-ext-enable \ imagick \ opcache +# Fail fast if the JPEG delegate did not make it into the image +RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \ + php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";' + # PHP RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \ -- 2.54.0 From 83b31d5c371570ed6ce49f9da8073a028b551015 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 19 Sep 2026 12:13:31 +0200 Subject: [PATCH 19/28] Fix --- .gitea/workflows/docker-build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 46489fd..0129390 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -22,6 +22,7 @@ jobs: build-apache-amd64: runs-on: ubuntu-latest permissions: + contents: read packages: write container: image: catthehacker/ubuntu:act-latest @@ -45,6 +46,7 @@ jobs: build-apache-arm64: runs-on: ubuntu-latest-arm permissions: + contents: read packages: write container: image: catthehacker/ubuntu:act-latest @@ -69,6 +71,7 @@ jobs: needs: [build-apache-amd64, build-apache-arm64] runs-on: ubuntu-latest permissions: + contents: read packages: write container: image: catthehacker/ubuntu:act-latest -- 2.54.0 From f8103a04503b84507b5cd876ef0afa638256e673 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 24 Oct 2026 20:34:29 +0200 Subject: [PATCH 20/28] Fixes --- .gitea/workflows/docker-build.yaml | 3 +++ apache/Dockerfile | 3 ++- fmp-alpine/Dockerfile | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 0129390..8bc86e9 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -77,6 +77,9 @@ jobs: image: catthehacker/ubuntu:act-latest steps: - uses: docker/setup-buildx-action@v1 + with: + driver: docker + - uses: docker/login-action@v3 with: registry: git.steelants.cz diff --git a/apache/Dockerfile b/apache/Dockerfile index 75e53b7..78e3272 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -77,7 +77,8 @@ RUN docker-php-ext-install \ bcmath \ soap \ gd \ - intl + intl \ + calendar RUN docker-php-ext-enable \ imagick \ diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index 87a2384..eececbf 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -51,7 +51,8 @@ RUN docker-php-ext-configure \ intl \ opcache \ sockets \ - pcntl + pcntl \ + calendar RUN pecl install imagick \ && docker-php-ext-enable imagick -- 2.54.0 From 6ebb259757f75aa603bbabb469f895b2d01bc3f1 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 24 Oct 2026 20:35:19 +0200 Subject: [PATCH 21/28] Fix --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cd7411 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.megamemory/* -- 2.54.0 From 085ab7e9b85293fe165cb4a0ccb6e3f77b573534 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 18:29:05 +0100 Subject: [PATCH 22/28] Progress --- apache/Dockerfile | 7 ++- apache/supervisor/conf.d/laravel-queues.conf | 6 +-- fmp-alpine/Dockerfile | 48 +++++++++++++++++-- fmp-alpine/docker-entrypoint.sh | 17 +++++++ .../supervisor/conf.d/laravel-queues.conf | 20 ++++++++ fmp-alpine/supervisor/supervisord.conf | 6 +++ 6 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 fmp-alpine/docker-entrypoint.sh create mode 100644 fmp-alpine/supervisor/conf.d/laravel-queues.conf create mode 100644 fmp-alpine/supervisor/supervisord.conf diff --git a/apache/Dockerfile b/apache/Dockerfile index 78e3272..9b59410 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -1,9 +1,12 @@ # Use PHP with Apache as the base image FROM php:8.4-apache +# Application root (default keeps the original /var/www/html layout) +ENV APP_ROOT="/var/www/html" + # Environment ENV TZ="Europe/Prague" \ - APACHE_DOCUMENT_ROOT="/var/www/html/public" \ + APACHE_DOCUMENT_ROOT="${APP_ROOT}/public" \ PHP_INI_FILE="$PHP_INI_DIR/php.ini" \ PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \ PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \ @@ -114,7 +117,7 @@ COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queu # Setup Crone RUN mkdir -p /var/log/cron && \ -echo "* * * * * www-data cd /var/www/html && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab +echo "* * * * * www-data cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab # Install composer # bun RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/apache/supervisor/conf.d/laravel-queues.conf b/apache/supervisor/conf.d/laravel-queues.conf index 74d99b5..f11adc6 100644 --- a/apache/supervisor/conf.d/laravel-queues.conf +++ b/apache/supervisor/conf.d/laravel-queues.conf @@ -1,19 +1,19 @@ [program:queue-default] -command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics user=www-data autostart=true autorestart=true stdout_logfile=/var/log/supervisor/queue-default.log [program:queue-statistics] -command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=5 --tries=3 --queue=statistics +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics user=www-data autostart=true autorestart=true stdout_logfile=/var/log/supervisor/queue-statistics.log [program:queue-detections] -command=/usr/local/bin/php /var/www/html/artisan queue:work --sleep=3 --tries=3 --queue=detections +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections user=www-data autostart=true autorestart=true diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index eececbf..40a7fff 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -1,6 +1,12 @@ FROM php:8.4-fpm-alpine +# Application root (same default as the apache image) +ENV APP_ROOT="/var/www/html" + ENV TZ="Europe/Prague" \ + ENABLE_CRON=0 \ + ENABLE_SUPERVISOR=0 \ + COMPOSER_ALLOW_SUPERUSER=1 \ PHP_OPCACHE_ENABLE=1 \ PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \ PHP_OPCACHE_REVALIDATE_FREQ=0 \ @@ -25,7 +31,17 @@ RUN apk add --no-cache \ libpng \ icu \ oniguruma \ - libxml2 + libxml2 \ + libwebp \ + git \ + nano \ + zip \ + unzip \ + nodejs \ + npm \ + supervisor \ + mysql-client \ + postgresql-client RUN apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ @@ -33,13 +49,14 @@ RUN apk add --no-cache --virtual .build-deps \ libzip-dev \ freetype-dev \ libjpeg-turbo-dev \ + libwebp-dev \ libpng-dev \ icu-dev \ libxml2-dev \ linux-headers RUN docker-php-ext-configure \ - gd --with-freetype --with-jpeg \ + gd --with-freetype --with-jpeg --with-webp \ && docker-php-ext-install -j$(nproc) \ pdo_mysql \ pdo_pgsql \ @@ -59,6 +76,13 @@ RUN pecl install imagick \ RUN apk del .build-deps +# Fail fast if the JPEG delegate did not make it into the image +RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \ + php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";' + +# Composer +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer + RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ && echo "date.timezone=${TZ}" > "$PHP_INI_DIR/conf.d/99-timezone.ini" @@ -81,4 +105,22 @@ RUN { \ echo "opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}"; \ echo "opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}"; \ echo "opcache.save_comments=1"; \ -} > "$PHP_INI_DIR/conf.d/10-opcache.ini" \ No newline at end of file +} > "$PHP_INI_DIR/conf.d/10-opcache.ini" + +# Supervisor (queue workers, started when ENABLE_SUPERVISOR=1) +RUN mkdir -p /var/log/supervisor +COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf + +# Cron (Laravel scheduler, started when ENABLE_CRON=1) +RUN mkdir -p /var/log/cron && \ + echo "* * * * * cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" > /etc/crontabs/www-data + +# Entrypoint +COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +WORKDIR ${APP_ROOT} + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["php-fpm"] diff --git a/fmp-alpine/docker-entrypoint.sh b/fmp-alpine/docker-entrypoint.sh new file mode 100644 index 0000000..76dc355 --- /dev/null +++ b/fmp-alpine/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +# Optional background services, only started together with php-fpm so that +# one-off commands (php artisan ..., composer ...) are passed through untouched. +case "$1" in + php-fpm*) + if [ "${ENABLE_CRON:-0}" = "1" ]; then + crond -b -L /var/log/cron/cron.log + fi + if [ "${ENABLE_SUPERVISOR:-0}" = "1" ]; then + supervisord -c /etc/supervisor/supervisord.conf + fi + ;; +esac + +exec docker-php-entrypoint "$@" diff --git a/fmp-alpine/supervisor/conf.d/laravel-queues.conf b/fmp-alpine/supervisor/conf.d/laravel-queues.conf new file mode 100644 index 0000000..f11adc6 --- /dev/null +++ b/fmp-alpine/supervisor/conf.d/laravel-queues.conf @@ -0,0 +1,20 @@ +[program:queue-default] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-default.log + +[program:queue-statistics] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-statistics.log + +[program:queue-detections] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-detections.log \ No newline at end of file diff --git a/fmp-alpine/supervisor/supervisord.conf b/fmp-alpine/supervisor/supervisord.conf new file mode 100644 index 0000000..2e99660 --- /dev/null +++ b/fmp-alpine/supervisor/supervisord.conf @@ -0,0 +1,6 @@ +[supervisord] +logfile=/var/log/supervisor/supervisord.log +pidfile=/run/supervisord.pid + +[include] +files = /etc/supervisor/conf.d/*.conf -- 2.54.0 From 411f7be8966dc573ceb6c572679b0b1461bcd081 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:16:51 +0100 Subject: [PATCH 23/28] Refactoring --- apache/Dockerfile | 10 ++++------ apache/entrypoint.d/10-opcache.sh | 8 ++++++++ apache/entrypoint.d/15-composer.sh | 11 ++++++++++ apache/entrypoint.d/20-env.sh | 17 ++++++++++++++++ apache/entrypoint.d/25-key.sh | 14 +++++++++++++ apache/entrypoint.d/26-cache.sh | 9 +++++++++ apache/entrypoint.d/27-sqlite.sh | 8 ++++++++ apache/entrypoint.d/30-storage.sh | 6 ++++++ apache/entrypoint.d/35-migrate.sh | 6 ++++++ apache/entrypoint.d/90-supervisord.sh | 12 +++++++++++ .../laravel-queues.conf | 0 apache/supervisor.d/laravel-scheduler.conf | 6 ++++++ apache/supervisor.d/reverb.conf.example | 8 ++++++++ apache/supervisor/supervisord.conf | 6 ------ fmp-alpine/Dockerfile | 20 +++++-------------- fmp-alpine/docker-entrypoint.sh | 17 ---------------- fmp-alpine/entrypoint.d/10-opcache.sh | 8 ++++++++ fmp-alpine/entrypoint.d/15-composer.sh | 11 ++++++++++ fmp-alpine/entrypoint.d/20-env.sh | 17 ++++++++++++++++ fmp-alpine/entrypoint.d/25-key.sh | 14 +++++++++++++ fmp-alpine/entrypoint.d/26-cache.sh | 9 +++++++++ fmp-alpine/entrypoint.d/27-sqlite.sh | 8 ++++++++ fmp-alpine/entrypoint.d/30-storage.sh | 6 ++++++ fmp-alpine/entrypoint.d/35-migrate.sh | 6 ++++++ fmp-alpine/entrypoint.d/90-supervisord.sh | 12 +++++++++++ .../laravel-queues.conf | 0 .../supervisor.d/laravel-scheduler.conf | 6 ++++++ fmp-alpine/supervisor.d/reverb.conf.example | 8 ++++++++ fmp-alpine/supervisor/supervisord.conf | 6 ------ 29 files changed, 219 insertions(+), 50 deletions(-) create mode 100644 apache/entrypoint.d/10-opcache.sh create mode 100644 apache/entrypoint.d/15-composer.sh create mode 100644 apache/entrypoint.d/20-env.sh create mode 100644 apache/entrypoint.d/25-key.sh create mode 100644 apache/entrypoint.d/26-cache.sh create mode 100644 apache/entrypoint.d/27-sqlite.sh create mode 100644 apache/entrypoint.d/30-storage.sh create mode 100644 apache/entrypoint.d/35-migrate.sh create mode 100644 apache/entrypoint.d/90-supervisord.sh rename apache/{supervisor/conf.d => supervisor.d}/laravel-queues.conf (100%) create mode 100644 apache/supervisor.d/laravel-scheduler.conf create mode 100644 apache/supervisor.d/reverb.conf.example delete mode 100644 apache/supervisor/supervisord.conf delete mode 100644 fmp-alpine/docker-entrypoint.sh create mode 100644 fmp-alpine/entrypoint.d/10-opcache.sh create mode 100644 fmp-alpine/entrypoint.d/15-composer.sh create mode 100644 fmp-alpine/entrypoint.d/20-env.sh create mode 100644 fmp-alpine/entrypoint.d/25-key.sh create mode 100644 fmp-alpine/entrypoint.d/26-cache.sh create mode 100644 fmp-alpine/entrypoint.d/27-sqlite.sh create mode 100644 fmp-alpine/entrypoint.d/30-storage.sh create mode 100644 fmp-alpine/entrypoint.d/35-migrate.sh create mode 100644 fmp-alpine/entrypoint.d/90-supervisord.sh rename fmp-alpine/{supervisor/conf.d => supervisor.d}/laravel-queues.conf (100%) create mode 100644 fmp-alpine/supervisor.d/laravel-scheduler.conf create mode 100644 fmp-alpine/supervisor.d/reverb.conf.example delete mode 100644 fmp-alpine/supervisor/supervisord.conf diff --git a/apache/Dockerfile b/apache/Dockerfile index 9b59410..ee965f7 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -112,12 +112,10 @@ opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini" #SUPERVISORD RUN mkdir -p /var/log/supervisor -COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf -COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf +COPY ./supervisor.d/ /etc/supervisor/conf.d/ -# Setup Crone -RUN mkdir -p /var/log/cron && \ -echo "* * * * * www-data cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab +#ENTRYPOINTS +COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ # Install composer # bun RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer @@ -126,7 +124,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \ sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \ sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \ - sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground + sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/apache2-foreground #Cleaning RUN apt-get clean && \ diff --git a/apache/entrypoint.d/10-opcache.sh b/apache/entrypoint.d/10-opcache.sh new file mode 100644 index 0000000..e8e315d --- /dev/null +++ b/apache/entrypoint.d/10-opcache.sh @@ -0,0 +1,8 @@ +#!/bin/sh +for ini in "${PHP_INI_DIR}"/conf.d/*opcache.ini; do + if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then + sed -ri -e "s!opcache.validate_timestamps=.*!opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}!g" "$ini" + else + sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "$ini" + fi +done diff --git a/apache/entrypoint.d/15-composer.sh b/apache/entrypoint.d/15-composer.sh new file mode 100644 index 0000000..ad0ded5 --- /dev/null +++ b/apache/entrypoint.d/15-composer.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Composer dependencies +[ -f composer.json ] || exit 0 + +if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then + echo "Initial setup nebo debug mód - instalace Composeru s dev závislostmi" + composer install --prefer-dist --optimize-autoloader +else + echo "Produkční instalace - Composer bez dev závislostí" + composer install --prefer-dist --no-dev --optimize-autoloader +fi diff --git a/apache/entrypoint.d/20-env.sh b/apache/entrypoint.d/20-env.sh new file mode 100644 index 0000000..cc6073c --- /dev/null +++ b/apache/entrypoint.d/20-env.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Prepares .env. When /config is mounted, .env is restored from /config/.env and saved there on first creation. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +[ -f artisan ] || exit 0 + +if [ -d /config ] && [ -f /config/.env ]; then + echo "Using existing /config/.env" + cp /config/.env .env +elif [ ! -f .env ] && [ -f .env.example ]; then + echo "Creating .env from example" + cp .env.example .env + chown "$(stat -c %u:%g .env.example)" .env + if [ -d /config ]; then + cp .env /config/.env + fi +fi diff --git a/apache/entrypoint.d/25-key.sh b/apache/entrypoint.d/25-key.sh new file mode 100644 index 0000000..647f744 --- /dev/null +++ b/apache/entrypoint.d/25-key.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Generates APP_KEY only when none exists yet (env or .env), so an existing key is never rotated. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +[ -f artisan ] || exit 0 +[ -f .env ] || exit 0 +[ -n "$APP_KEY" ] && exit 0 + +if ! grep -Eq '^APP_KEY=.+' .env; then + echo "Generating application key" + php artisan key:generate --force --no-interaction + [ -d /config ] && cp .env /config/.env +fi +exit 0 diff --git a/apache/entrypoint.d/26-cache.sh b/apache/entrypoint.d/26-cache.sh new file mode 100644 index 0000000..4aa6872 --- /dev/null +++ b/apache/entrypoint.d/26-cache.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Clear Laravel caches +[ -f artisan ] || exit 0 + +echo "Clearing Laravel caches" +php artisan cache:clear +php artisan config:clear +php artisan route:clear +php artisan view:clear diff --git a/apache/entrypoint.d/27-sqlite.sh b/apache/entrypoint.d/27-sqlite.sh new file mode 100644 index 0000000..5a58ed1 --- /dev/null +++ b/apache/entrypoint.d/27-sqlite.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# SQLite database initialization +if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then + if [ ! -f database/database.sqlite ]; then + echo "Creating empty SQLite database" + touch database/database.sqlite + fi +fi diff --git a/apache/entrypoint.d/30-storage.sh b/apache/entrypoint.d/30-storage.sh new file mode 100644 index 0000000..c579e3f --- /dev/null +++ b/apache/entrypoint.d/30-storage.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Link storage and seed database if first init +[ -f artisan ] || exit 0 + +echo "Linking storage directory" +php artisan storage:link diff --git a/apache/entrypoint.d/35-migrate.sh b/apache/entrypoint.d/35-migrate.sh new file mode 100644 index 0000000..d0458d7 --- /dev/null +++ b/apache/entrypoint.d/35-migrate.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Migrate database +[ -f artisan ] || exit 0 + +echo "Running database migrations" +php artisan migrate --force --no-interaction diff --git a/apache/entrypoint.d/90-supervisord.sh b/apache/entrypoint.d/90-supervisord.sh new file mode 100644 index 0000000..4650f53 --- /dev/null +++ b/apache/entrypoint.d/90-supervisord.sh @@ -0,0 +1,12 @@ +#!/bin/sh +cat > /etc/supervisor/supervisord.conf <<'EOF' +[supervisord] +nodaemon=true +logfile=/var/log/supervisor/supervisord.log + +[include] +files = /etc/supervisor/conf.d/*.conf +EOF + +# nodaemon=true keeps supervisord in the foreground, so detach it here +supervisord -c /etc/supervisor/supervisord.conf & diff --git a/apache/supervisor/conf.d/laravel-queues.conf b/apache/supervisor.d/laravel-queues.conf similarity index 100% rename from apache/supervisor/conf.d/laravel-queues.conf rename to apache/supervisor.d/laravel-queues.conf diff --git a/apache/supervisor.d/laravel-scheduler.conf b/apache/supervisor.d/laravel-scheduler.conf new file mode 100644 index 0000000..bb2bfb7 --- /dev/null +++ b/apache/supervisor.d/laravel-scheduler.conf @@ -0,0 +1,6 @@ +[program:scheduler] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan schedule:work +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/scheduler.log diff --git a/apache/supervisor.d/reverb.conf.example b/apache/supervisor.d/reverb.conf.example new file mode 100644 index 0000000..a42dce6 --- /dev/null +++ b/apache/supervisor.d/reverb.conf.example @@ -0,0 +1,8 @@ +; Example only, not loaded (supervisor includes just *.conf). +; To enable it, copy it to /etc/supervisor/conf.d/reverb.conf (or rename it to reverb.conf in supervisor.d). +[program:reverb] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan reverb:start --host=0.0.0.0 --no-interaction --debug +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/reverb.log diff --git a/apache/supervisor/supervisord.conf b/apache/supervisor/supervisord.conf deleted file mode 100644 index 67127ed..0000000 --- a/apache/supervisor/supervisord.conf +++ /dev/null @@ -1,6 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/var/log/supervisor/supervisord.log - -[include] -files = /etc/supervisor/conf.d/*.conf \ No newline at end of file diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index 40a7fff..c7ff9d2 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -4,8 +4,6 @@ FROM php:8.4-fpm-alpine ENV APP_ROOT="/var/www/html" ENV TZ="Europe/Prague" \ - ENABLE_CRON=0 \ - ENABLE_SUPERVISOR=0 \ COMPOSER_ALLOW_SUPERUSER=1 \ PHP_OPCACHE_ENABLE=1 \ PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \ @@ -107,20 +105,12 @@ RUN { \ echo "opcache.save_comments=1"; \ } > "$PHP_INI_DIR/conf.d/10-opcache.ini" -# Supervisor (queue workers, started when ENABLE_SUPERVISOR=1) +# Supervisor (queue workers + scheduler, started from entrypoint.d/90-supervisord.sh) RUN mkdir -p /var/log/supervisor -COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf -COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf +COPY ./supervisor.d/ /etc/supervisor/conf.d/ -# Cron (Laravel scheduler, started when ENABLE_CRON=1) -RUN mkdir -p /var/log/cron && \ - echo "* * * * * cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" > /etc/crontabs/www-data - -# Entrypoint -COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN chmod +x /usr/local/bin/docker-entrypoint.sh +# Entrypoint scripts (run in order from the stock entrypoint) +COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ +RUN sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/docker-php-entrypoint WORKDIR ${APP_ROOT} - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["php-fpm"] diff --git a/fmp-alpine/docker-entrypoint.sh b/fmp-alpine/docker-entrypoint.sh deleted file mode 100644 index 76dc355..0000000 --- a/fmp-alpine/docker-entrypoint.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -e - -# Optional background services, only started together with php-fpm so that -# one-off commands (php artisan ..., composer ...) are passed through untouched. -case "$1" in - php-fpm*) - if [ "${ENABLE_CRON:-0}" = "1" ]; then - crond -b -L /var/log/cron/cron.log - fi - if [ "${ENABLE_SUPERVISOR:-0}" = "1" ]; then - supervisord -c /etc/supervisor/supervisord.conf - fi - ;; -esac - -exec docker-php-entrypoint "$@" diff --git a/fmp-alpine/entrypoint.d/10-opcache.sh b/fmp-alpine/entrypoint.d/10-opcache.sh new file mode 100644 index 0000000..e8e315d --- /dev/null +++ b/fmp-alpine/entrypoint.d/10-opcache.sh @@ -0,0 +1,8 @@ +#!/bin/sh +for ini in "${PHP_INI_DIR}"/conf.d/*opcache.ini; do + if [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "false" ]; then + sed -ri -e "s!opcache.validate_timestamps=.*!opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}!g" "$ini" + else + sed -ri -e 's!opcache.enable=1!opcache.enable=0!g' "$ini" + fi +done diff --git a/fmp-alpine/entrypoint.d/15-composer.sh b/fmp-alpine/entrypoint.d/15-composer.sh new file mode 100644 index 0000000..ad0ded5 --- /dev/null +++ b/fmp-alpine/entrypoint.d/15-composer.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Composer dependencies +[ -f composer.json ] || exit 0 + +if [ "$init" = "true" ] || [ "$(echo "$APP_DEBUG" | tr '[:upper:]' '[:lower:]')" = "true" ]; then + echo "Initial setup nebo debug mód - instalace Composeru s dev závislostmi" + composer install --prefer-dist --optimize-autoloader +else + echo "Produkční instalace - Composer bez dev závislostí" + composer install --prefer-dist --no-dev --optimize-autoloader +fi diff --git a/fmp-alpine/entrypoint.d/20-env.sh b/fmp-alpine/entrypoint.d/20-env.sh new file mode 100644 index 0000000..cc6073c --- /dev/null +++ b/fmp-alpine/entrypoint.d/20-env.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Prepares .env. When /config is mounted, .env is restored from /config/.env and saved there on first creation. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +[ -f artisan ] || exit 0 + +if [ -d /config ] && [ -f /config/.env ]; then + echo "Using existing /config/.env" + cp /config/.env .env +elif [ ! -f .env ] && [ -f .env.example ]; then + echo "Creating .env from example" + cp .env.example .env + chown "$(stat -c %u:%g .env.example)" .env + if [ -d /config ]; then + cp .env /config/.env + fi +fi diff --git a/fmp-alpine/entrypoint.d/25-key.sh b/fmp-alpine/entrypoint.d/25-key.sh new file mode 100644 index 0000000..647f744 --- /dev/null +++ b/fmp-alpine/entrypoint.d/25-key.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Generates APP_KEY only when none exists yet (env or .env), so an existing key is never rotated. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +[ -f artisan ] || exit 0 +[ -f .env ] || exit 0 +[ -n "$APP_KEY" ] && exit 0 + +if ! grep -Eq '^APP_KEY=.+' .env; then + echo "Generating application key" + php artisan key:generate --force --no-interaction + [ -d /config ] && cp .env /config/.env +fi +exit 0 diff --git a/fmp-alpine/entrypoint.d/26-cache.sh b/fmp-alpine/entrypoint.d/26-cache.sh new file mode 100644 index 0000000..4aa6872 --- /dev/null +++ b/fmp-alpine/entrypoint.d/26-cache.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Clear Laravel caches +[ -f artisan ] || exit 0 + +echo "Clearing Laravel caches" +php artisan cache:clear +php artisan config:clear +php artisan route:clear +php artisan view:clear diff --git a/fmp-alpine/entrypoint.d/27-sqlite.sh b/fmp-alpine/entrypoint.d/27-sqlite.sh new file mode 100644 index 0000000..5a58ed1 --- /dev/null +++ b/fmp-alpine/entrypoint.d/27-sqlite.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# SQLite database initialization +if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then + if [ ! -f database/database.sqlite ]; then + echo "Creating empty SQLite database" + touch database/database.sqlite + fi +fi diff --git a/fmp-alpine/entrypoint.d/30-storage.sh b/fmp-alpine/entrypoint.d/30-storage.sh new file mode 100644 index 0000000..c579e3f --- /dev/null +++ b/fmp-alpine/entrypoint.d/30-storage.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Link storage and seed database if first init +[ -f artisan ] || exit 0 + +echo "Linking storage directory" +php artisan storage:link diff --git a/fmp-alpine/entrypoint.d/35-migrate.sh b/fmp-alpine/entrypoint.d/35-migrate.sh new file mode 100644 index 0000000..d0458d7 --- /dev/null +++ b/fmp-alpine/entrypoint.d/35-migrate.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Migrate database +[ -f artisan ] || exit 0 + +echo "Running database migrations" +php artisan migrate --force --no-interaction diff --git a/fmp-alpine/entrypoint.d/90-supervisord.sh b/fmp-alpine/entrypoint.d/90-supervisord.sh new file mode 100644 index 0000000..4650f53 --- /dev/null +++ b/fmp-alpine/entrypoint.d/90-supervisord.sh @@ -0,0 +1,12 @@ +#!/bin/sh +cat > /etc/supervisor/supervisord.conf <<'EOF' +[supervisord] +nodaemon=true +logfile=/var/log/supervisor/supervisord.log + +[include] +files = /etc/supervisor/conf.d/*.conf +EOF + +# nodaemon=true keeps supervisord in the foreground, so detach it here +supervisord -c /etc/supervisor/supervisord.conf & diff --git a/fmp-alpine/supervisor/conf.d/laravel-queues.conf b/fmp-alpine/supervisor.d/laravel-queues.conf similarity index 100% rename from fmp-alpine/supervisor/conf.d/laravel-queues.conf rename to fmp-alpine/supervisor.d/laravel-queues.conf diff --git a/fmp-alpine/supervisor.d/laravel-scheduler.conf b/fmp-alpine/supervisor.d/laravel-scheduler.conf new file mode 100644 index 0000000..bb2bfb7 --- /dev/null +++ b/fmp-alpine/supervisor.d/laravel-scheduler.conf @@ -0,0 +1,6 @@ +[program:scheduler] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan schedule:work +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/scheduler.log diff --git a/fmp-alpine/supervisor.d/reverb.conf.example b/fmp-alpine/supervisor.d/reverb.conf.example new file mode 100644 index 0000000..a42dce6 --- /dev/null +++ b/fmp-alpine/supervisor.d/reverb.conf.example @@ -0,0 +1,8 @@ +; Example only, not loaded (supervisor includes just *.conf). +; To enable it, copy it to /etc/supervisor/conf.d/reverb.conf (or rename it to reverb.conf in supervisor.d). +[program:reverb] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan reverb:start --host=0.0.0.0 --no-interaction --debug +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/reverb.log diff --git a/fmp-alpine/supervisor/supervisord.conf b/fmp-alpine/supervisor/supervisord.conf deleted file mode 100644 index 2e99660..0000000 --- a/fmp-alpine/supervisor/supervisord.conf +++ /dev/null @@ -1,6 +0,0 @@ -[supervisord] -logfile=/var/log/supervisor/supervisord.log -pidfile=/run/supervisord.pid - -[include] -files = /etc/supervisor/conf.d/*.conf -- 2.54.0 From 3883abbc85b93ee8c9578eed1bcaac607791a5a0 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:28:45 +0100 Subject: [PATCH 24/28] Speed Up Build --- apache/Dockerfile | 7 ++++++- apache/entrypoint-runner.sh | 9 +++++++++ apache/entrypoint.d/05-permissions.sh | 10 ++++++++++ fmp-alpine/Dockerfile | 7 ++++++- fmp-alpine/entrypoint-runner.sh | 9 +++++++++ fmp-alpine/entrypoint.d/05-permissions.sh | 10 ++++++++++ 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 apache/entrypoint-runner.sh create mode 100644 apache/entrypoint.d/05-permissions.sh create mode 100644 fmp-alpine/entrypoint-runner.sh create mode 100644 fmp-alpine/entrypoint.d/05-permissions.sh diff --git a/apache/Dockerfile b/apache/Dockerfile index ee965f7..6990875 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -116,6 +116,11 @@ COPY ./supervisor.d/ /etc/supervisor/conf.d/ #ENTRYPOINTS COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ +COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh + +# Persistent .env storage (see entrypoint.d/20-env.sh) +RUN mkdir -p /config +VOLUME /config # Install composer # bun RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer @@ -124,7 +129,7 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \ sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \ sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \ - sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/apache2-foreground + sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/apache2-foreground #Cleaning RUN apt-get clean && \ diff --git a/apache/entrypoint-runner.sh b/apache/entrypoint-runner.sh new file mode 100644 index 0000000..da50d06 --- /dev/null +++ b/apache/entrypoint-runner.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Legacy images ship their own start.sh in the app root and do the whole setup themselves. +[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0 + +for f in /etc/entrypoint.d/*.sh; do + if [ -x "$f" ]; then + "$f" || { echo "entrypoint script failed: $f" >&2; exit 1; } + fi +done diff --git a/apache/entrypoint.d/05-permissions.sh b/apache/entrypoint.d/05-permissions.sh new file mode 100644 index 0000000..9e9c34f --- /dev/null +++ b/apache/entrypoint.d/05-permissions.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +for dir in storage bootstrap/cache; do + if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then + chown -R www-data:www-data "$dir" + fi +done +exit 0 diff --git a/fmp-alpine/Dockerfile b/fmp-alpine/Dockerfile index c7ff9d2..4b7c15a 100644 --- a/fmp-alpine/Dockerfile +++ b/fmp-alpine/Dockerfile @@ -111,6 +111,11 @@ COPY ./supervisor.d/ /etc/supervisor/conf.d/ # Entrypoint scripts (run in order from the stock entrypoint) COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/ -RUN sed -i 's#^exec #for f in /etc/entrypoint.d/*.sh; do if [ -x "$f" ]; then "$f" || { echo "entrypoint script failed: $f" >\&2; exit 1; }; fi; done\n\nexec #' /usr/local/bin/docker-php-entrypoint +COPY --chmod=755 ./entrypoint-runner.sh /usr/local/bin/entrypoint-runner.sh + +# Persistent .env storage (see entrypoint.d/20-env.sh) +RUN mkdir -p /config +VOLUME /config +RUN sed -i 's#^exec #entrypoint-runner.sh\n\nexec #' /usr/local/bin/docker-php-entrypoint WORKDIR ${APP_ROOT} diff --git a/fmp-alpine/entrypoint-runner.sh b/fmp-alpine/entrypoint-runner.sh new file mode 100644 index 0000000..da50d06 --- /dev/null +++ b/fmp-alpine/entrypoint-runner.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Legacy images ship their own start.sh in the app root and do the whole setup themselves. +[ -f "${APP_ROOT:-/var/www/html}/start.sh" ] && exit 0 + +for f in /etc/entrypoint.d/*.sh; do + if [ -x "$f" ]; then + "$f" || { echo "entrypoint script failed: $f" >&2; exit 1; } + fi +done diff --git a/fmp-alpine/entrypoint.d/05-permissions.sh b/fmp-alpine/entrypoint.d/05-permissions.sh new file mode 100644 index 0000000..9e9c34f --- /dev/null +++ b/fmp-alpine/entrypoint.d/05-permissions.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Mounted volumes are usually root-owned, so www-data could not write into storage and bootstrap/cache. +cd "${APP_ROOT:-/var/www/html}" || exit 0 + +for dir in storage bootstrap/cache; do + if [ -d "$dir" ] && [ "$(stat -c %U "$dir")" != "www-data" ]; then + chown -R www-data:www-data "$dir" + fi +done +exit 0 -- 2.54.0 From 056f95384c2be1d840beb541b2de1b2cc22ce39c Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:29:48 +0100 Subject: [PATCH 25/28] V2 --- {apache => v2-apache}/Dockerfile | 0 {apache => v2-apache}/entrypoint-runner.sh | 0 {apache => v2-apache}/entrypoint.d/05-permissions.sh | 0 {apache => v2-apache}/entrypoint.d/10-opcache.sh | 0 {apache => v2-apache}/entrypoint.d/15-composer.sh | 0 {apache => v2-apache}/entrypoint.d/20-env.sh | 0 {apache => v2-apache}/entrypoint.d/25-key.sh | 0 {apache => v2-apache}/entrypoint.d/26-cache.sh | 0 {apache => v2-apache}/entrypoint.d/27-sqlite.sh | 0 {apache => v2-apache}/entrypoint.d/30-storage.sh | 0 {apache => v2-apache}/entrypoint.d/35-migrate.sh | 0 {apache => v2-apache}/entrypoint.d/90-supervisord.sh | 0 {apache => v2-apache}/supervisor.d/laravel-queues.conf | 0 {apache => v2-apache}/supervisor.d/laravel-scheduler.conf | 0 {apache => v2-apache}/supervisor.d/reverb.conf.example | 0 {fmp-alpine => v2-fmp-alpine}/Dockerfile | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint-runner.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/05-permissions.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/10-opcache.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/15-composer.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/20-env.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/25-key.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/26-cache.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/27-sqlite.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/30-storage.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/35-migrate.sh | 0 {fmp-alpine => v2-fmp-alpine}/entrypoint.d/90-supervisord.sh | 0 {fmp-alpine => v2-fmp-alpine}/supervisor.d/laravel-queues.conf | 0 {fmp-alpine => v2-fmp-alpine}/supervisor.d/laravel-scheduler.conf | 0 {fmp-alpine => v2-fmp-alpine}/supervisor.d/reverb.conf.example | 0 30 files changed, 0 insertions(+), 0 deletions(-) rename {apache => v2-apache}/Dockerfile (100%) rename {apache => v2-apache}/entrypoint-runner.sh (100%) rename {apache => v2-apache}/entrypoint.d/05-permissions.sh (100%) rename {apache => v2-apache}/entrypoint.d/10-opcache.sh (100%) rename {apache => v2-apache}/entrypoint.d/15-composer.sh (100%) rename {apache => v2-apache}/entrypoint.d/20-env.sh (100%) rename {apache => v2-apache}/entrypoint.d/25-key.sh (100%) rename {apache => v2-apache}/entrypoint.d/26-cache.sh (100%) rename {apache => v2-apache}/entrypoint.d/27-sqlite.sh (100%) rename {apache => v2-apache}/entrypoint.d/30-storage.sh (100%) rename {apache => v2-apache}/entrypoint.d/35-migrate.sh (100%) rename {apache => v2-apache}/entrypoint.d/90-supervisord.sh (100%) rename {apache => v2-apache}/supervisor.d/laravel-queues.conf (100%) rename {apache => v2-apache}/supervisor.d/laravel-scheduler.conf (100%) rename {apache => v2-apache}/supervisor.d/reverb.conf.example (100%) rename {fmp-alpine => v2-fmp-alpine}/Dockerfile (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint-runner.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/05-permissions.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/10-opcache.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/15-composer.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/20-env.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/25-key.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/26-cache.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/27-sqlite.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/30-storage.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/35-migrate.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/entrypoint.d/90-supervisord.sh (100%) rename {fmp-alpine => v2-fmp-alpine}/supervisor.d/laravel-queues.conf (100%) rename {fmp-alpine => v2-fmp-alpine}/supervisor.d/laravel-scheduler.conf (100%) rename {fmp-alpine => v2-fmp-alpine}/supervisor.d/reverb.conf.example (100%) diff --git a/apache/Dockerfile b/v2-apache/Dockerfile similarity index 100% rename from apache/Dockerfile rename to v2-apache/Dockerfile diff --git a/apache/entrypoint-runner.sh b/v2-apache/entrypoint-runner.sh similarity index 100% rename from apache/entrypoint-runner.sh rename to v2-apache/entrypoint-runner.sh diff --git a/apache/entrypoint.d/05-permissions.sh b/v2-apache/entrypoint.d/05-permissions.sh similarity index 100% rename from apache/entrypoint.d/05-permissions.sh rename to v2-apache/entrypoint.d/05-permissions.sh diff --git a/apache/entrypoint.d/10-opcache.sh b/v2-apache/entrypoint.d/10-opcache.sh similarity index 100% rename from apache/entrypoint.d/10-opcache.sh rename to v2-apache/entrypoint.d/10-opcache.sh diff --git a/apache/entrypoint.d/15-composer.sh b/v2-apache/entrypoint.d/15-composer.sh similarity index 100% rename from apache/entrypoint.d/15-composer.sh rename to v2-apache/entrypoint.d/15-composer.sh diff --git a/apache/entrypoint.d/20-env.sh b/v2-apache/entrypoint.d/20-env.sh similarity index 100% rename from apache/entrypoint.d/20-env.sh rename to v2-apache/entrypoint.d/20-env.sh diff --git a/apache/entrypoint.d/25-key.sh b/v2-apache/entrypoint.d/25-key.sh similarity index 100% rename from apache/entrypoint.d/25-key.sh rename to v2-apache/entrypoint.d/25-key.sh diff --git a/apache/entrypoint.d/26-cache.sh b/v2-apache/entrypoint.d/26-cache.sh similarity index 100% rename from apache/entrypoint.d/26-cache.sh rename to v2-apache/entrypoint.d/26-cache.sh diff --git a/apache/entrypoint.d/27-sqlite.sh b/v2-apache/entrypoint.d/27-sqlite.sh similarity index 100% rename from apache/entrypoint.d/27-sqlite.sh rename to v2-apache/entrypoint.d/27-sqlite.sh diff --git a/apache/entrypoint.d/30-storage.sh b/v2-apache/entrypoint.d/30-storage.sh similarity index 100% rename from apache/entrypoint.d/30-storage.sh rename to v2-apache/entrypoint.d/30-storage.sh diff --git a/apache/entrypoint.d/35-migrate.sh b/v2-apache/entrypoint.d/35-migrate.sh similarity index 100% rename from apache/entrypoint.d/35-migrate.sh rename to v2-apache/entrypoint.d/35-migrate.sh diff --git a/apache/entrypoint.d/90-supervisord.sh b/v2-apache/entrypoint.d/90-supervisord.sh similarity index 100% rename from apache/entrypoint.d/90-supervisord.sh rename to v2-apache/entrypoint.d/90-supervisord.sh diff --git a/apache/supervisor.d/laravel-queues.conf b/v2-apache/supervisor.d/laravel-queues.conf similarity index 100% rename from apache/supervisor.d/laravel-queues.conf rename to v2-apache/supervisor.d/laravel-queues.conf diff --git a/apache/supervisor.d/laravel-scheduler.conf b/v2-apache/supervisor.d/laravel-scheduler.conf similarity index 100% rename from apache/supervisor.d/laravel-scheduler.conf rename to v2-apache/supervisor.d/laravel-scheduler.conf diff --git a/apache/supervisor.d/reverb.conf.example b/v2-apache/supervisor.d/reverb.conf.example similarity index 100% rename from apache/supervisor.d/reverb.conf.example rename to v2-apache/supervisor.d/reverb.conf.example diff --git a/fmp-alpine/Dockerfile b/v2-fmp-alpine/Dockerfile similarity index 100% rename from fmp-alpine/Dockerfile rename to v2-fmp-alpine/Dockerfile diff --git a/fmp-alpine/entrypoint-runner.sh b/v2-fmp-alpine/entrypoint-runner.sh similarity index 100% rename from fmp-alpine/entrypoint-runner.sh rename to v2-fmp-alpine/entrypoint-runner.sh diff --git a/fmp-alpine/entrypoint.d/05-permissions.sh b/v2-fmp-alpine/entrypoint.d/05-permissions.sh similarity index 100% rename from fmp-alpine/entrypoint.d/05-permissions.sh rename to v2-fmp-alpine/entrypoint.d/05-permissions.sh diff --git a/fmp-alpine/entrypoint.d/10-opcache.sh b/v2-fmp-alpine/entrypoint.d/10-opcache.sh similarity index 100% rename from fmp-alpine/entrypoint.d/10-opcache.sh rename to v2-fmp-alpine/entrypoint.d/10-opcache.sh diff --git a/fmp-alpine/entrypoint.d/15-composer.sh b/v2-fmp-alpine/entrypoint.d/15-composer.sh similarity index 100% rename from fmp-alpine/entrypoint.d/15-composer.sh rename to v2-fmp-alpine/entrypoint.d/15-composer.sh diff --git a/fmp-alpine/entrypoint.d/20-env.sh b/v2-fmp-alpine/entrypoint.d/20-env.sh similarity index 100% rename from fmp-alpine/entrypoint.d/20-env.sh rename to v2-fmp-alpine/entrypoint.d/20-env.sh diff --git a/fmp-alpine/entrypoint.d/25-key.sh b/v2-fmp-alpine/entrypoint.d/25-key.sh similarity index 100% rename from fmp-alpine/entrypoint.d/25-key.sh rename to v2-fmp-alpine/entrypoint.d/25-key.sh diff --git a/fmp-alpine/entrypoint.d/26-cache.sh b/v2-fmp-alpine/entrypoint.d/26-cache.sh similarity index 100% rename from fmp-alpine/entrypoint.d/26-cache.sh rename to v2-fmp-alpine/entrypoint.d/26-cache.sh diff --git a/fmp-alpine/entrypoint.d/27-sqlite.sh b/v2-fmp-alpine/entrypoint.d/27-sqlite.sh similarity index 100% rename from fmp-alpine/entrypoint.d/27-sqlite.sh rename to v2-fmp-alpine/entrypoint.d/27-sqlite.sh diff --git a/fmp-alpine/entrypoint.d/30-storage.sh b/v2-fmp-alpine/entrypoint.d/30-storage.sh similarity index 100% rename from fmp-alpine/entrypoint.d/30-storage.sh rename to v2-fmp-alpine/entrypoint.d/30-storage.sh diff --git a/fmp-alpine/entrypoint.d/35-migrate.sh b/v2-fmp-alpine/entrypoint.d/35-migrate.sh similarity index 100% rename from fmp-alpine/entrypoint.d/35-migrate.sh rename to v2-fmp-alpine/entrypoint.d/35-migrate.sh diff --git a/fmp-alpine/entrypoint.d/90-supervisord.sh b/v2-fmp-alpine/entrypoint.d/90-supervisord.sh similarity index 100% rename from fmp-alpine/entrypoint.d/90-supervisord.sh rename to v2-fmp-alpine/entrypoint.d/90-supervisord.sh diff --git a/fmp-alpine/supervisor.d/laravel-queues.conf b/v2-fmp-alpine/supervisor.d/laravel-queues.conf similarity index 100% rename from fmp-alpine/supervisor.d/laravel-queues.conf rename to v2-fmp-alpine/supervisor.d/laravel-queues.conf diff --git a/fmp-alpine/supervisor.d/laravel-scheduler.conf b/v2-fmp-alpine/supervisor.d/laravel-scheduler.conf similarity index 100% rename from fmp-alpine/supervisor.d/laravel-scheduler.conf rename to v2-fmp-alpine/supervisor.d/laravel-scheduler.conf diff --git a/fmp-alpine/supervisor.d/reverb.conf.example b/v2-fmp-alpine/supervisor.d/reverb.conf.example similarity index 100% rename from fmp-alpine/supervisor.d/reverb.conf.example rename to v2-fmp-alpine/supervisor.d/reverb.conf.example -- 2.54.0 From 9357f462726ed4072ee0bdb9b1aaccecd481c644 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:34:38 +0100 Subject: [PATCH 26/28] Fix WF and old images --- .gitea/workflows/docker-build.yaml | 192 +++++++++++++++++++ apache/Dockerfile | 137 +++++++++++++ apache/supervisor/conf.d/laravel-queues.conf | 20 ++ apache/supervisor/supervisord.conf | 6 + 4 files changed, 355 insertions(+) create mode 100644 apache/Dockerfile create mode 100644 apache/supervisor/conf.d/laravel-queues.conf create mode 100644 apache/supervisor/supervisord.conf diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml index 8bc86e9..13b5e3f 100644 --- a/.gitea/workflows/docker-build.yaml +++ b/.gitea/workflows/docker-build.yaml @@ -112,3 +112,195 @@ jobs: Repo: ${{ github.repository }} Branch: ${{ github.ref_name }} Commit: ${{ github.sha }} + + # ─── APACHE V2 ──────────────────────────────────────────────────────── + + build-apache-v2-amd64: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: v2-apache + platforms: linux/amd64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + build-apache-v2-arm64: + runs-on: ubuntu-latest-arm + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: v2-apache + platforms: linux/arm64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + manifest-apache-v2: + needs: [build-apache-v2-amd64, build-apache-v2-arm64] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + steps: + - uses: docker/setup-buildx-action@v1 + with: + driver: docker + + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - name: Create and push multi-arch manifest + run: | + docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:v2-latest \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-v2-amd64.outputs.digest }} \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-apache-v2-arm64.outputs.digest }} + + - name: Discord Webhook Success + if: success() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ✅ APACHE V2 - Build successful! (amd64 + arm64) + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + + - name: Discord Webhook Failure + if: failure() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ❌ APACHE V2 - Build failed! + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + + # ─── ALPINE V2 ──────────────────────────────────────────────────────── + + build-alpine-v2-amd64: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: v2-fmp-alpine + platforms: linux/amd64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + build-alpine-v2-arm64: + runs-on: ubuntu-latest-arm + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-buildx-action@v1 + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - id: build + uses: docker/build-push-action@v6 + with: + context: v2-fmp-alpine + platforms: linux/arm64 + outputs: type=image,name=git.steelants.cz/steelants/docker_php_base,push-by-digest=true,name-canonical=true,push=true + + manifest-alpine-v2: + needs: [build-alpine-v2-amd64, build-alpine-v2-arm64] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + container: + image: catthehacker/ubuntu:act-latest + steps: + - uses: docker/setup-buildx-action@v1 + with: + driver: docker + + - uses: docker/login-action@v3 + with: + registry: git.steelants.cz + username: ${{ secrets.GITEAUSER }} + password: ${{ secrets.GITEAPASSWD }} + - name: Create and push multi-arch manifest + run: | + docker buildx imagetools create -t git.steelants.cz/steelants/docker_php_base:alpine-v2-latest \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-alpine-v2-amd64.outputs.digest }} \ + git.steelants.cz/steelants/docker_php_base@${{ needs.build-alpine-v2-arm64.outputs.digest }} + + - name: Discord Webhook Success + if: success() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ✅ ALPINE V2 - Build successful! (amd64 + arm64) + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} + + - name: Discord Webhook Failure + if: failure() + uses: tsickert/discord-webhook@v6.0.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + content: | + ❌ ALPINE V2 - Build failed! + Repo: ${{ github.repository }} + Branch: ${{ github.ref_name }} + Commit: ${{ github.sha }} diff --git a/apache/Dockerfile b/apache/Dockerfile new file mode 100644 index 0000000..9b59410 --- /dev/null +++ b/apache/Dockerfile @@ -0,0 +1,137 @@ +# Use PHP with Apache as the base image +FROM php:8.4-apache + +# Application root (default keeps the original /var/www/html layout) +ENV APP_ROOT="/var/www/html" + +# Environment +ENV TZ="Europe/Prague" \ + APACHE_DOCUMENT_ROOT="${APP_ROOT}/public" \ + PHP_INI_FILE="$PHP_INI_DIR/php.ini" \ + PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \ + PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \ + PHP_OPCACHE_MEMORY_CONSUMPTION="192" \ + PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" \ + COMPOSER_ALLOW_SUPERUSER=1 + +# Timezone +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Install Additional System Dependencies +RUN rm -f /etc/apt/apt.conf.d/docker-clean +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update && apt-get install -yqq --no-install-recommends \ + git \ + libpq-dev \ + libzip-dev \ + zip \ + unzip \ + zlib1g-dev \ + libicu-dev \ + libjpeg-dev \ + libpng-dev \ + libwebp-dev \ + libfreetype6-dev \ + g++ \ + nodejs \ + npm \ + cron \ + nano \ + default-mysql-client \ + postgresql-client \ + imagemagick \ + libmagickwand-dev \ + librsvg2-2 \ + librsvg2-dev \ + librsvg2-bin \ + supervisor && \ + git clone https://github.com/Imagick/imagick --depth 1 /tmp/imagick && \ + cd /tmp/imagick && \ + phpize && \ + ./configure --with-rsvg && \ + ldconfig && \ + make && \ + make install && \ + apt-get autoremove && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + npm config set cache /tmp --global && \ + mkdir -p /var/log/supervisor + +# Enable Apache mod_rewrite for URL rewriting +RUN a2enmod rewrite + +RUN docker-php-ext-configure intl + +RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp + +# Install PHP extensions +RUN docker-php-ext-configure \ + opcache --enable-opcache + +RUN docker-php-ext-install \ + pdo_mysql \ + pgsql \ + pdo_pgsql \ + zip \ + opcache \ + pcntl \ + sockets\ + bcmath \ + soap \ + gd \ + intl \ + calendar + +RUN docker-php-ext-enable \ + imagick \ + opcache + +# Fail fast if the JPEG delegate did not make it into the image +RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ERROR: imagick built without JPEG delegate\n"); exit(1); } echo "imagick JPEG delegate OK\n";' && \ + php -r 'if (!function_exists("imagecreatefromjpeg")) { fwrite(STDERR, "ERROR: gd built without JPEG support\n"); exit(1); } echo "gd JPEG OK\n";' + +# PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ + sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \ + sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \ + sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \ + printf '[Date]\ndate.timezone="%s"\n', $TZ > "$PHP_INI_DIR/conf.d/tzone.ini" + +#OPCACHE +RUN echo "\n\ +[opcache]\n\ +opcache.enable=1\n\ +opcache.revalidate_freq=0\n\ +opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}\n\ +opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}\n\ +opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}\n\ +opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}\n\ +opcache.interned_strings_buffer=16\n\ +opcache.fast_shutdown=1" >> "$PHP_INI_DIR/conf.d/opcache.ini" + +#SUPERVISORD +RUN mkdir -p /var/log/supervisor +COPY ./supervisor/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./supervisor/conf.d/laravel-queues.conf /etc/supervisor/conf.d/laravel-queues.conf + +# Setup Crone +RUN mkdir -p /var/log/cron && \ +echo "* * * * * www-data cd ${APP_ROOT} && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1" >> /etc/crontab + +# Install composer # bun +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Configure Apache DocumentRoot to point to Laravel's public directory +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf && \ + sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf && \ + sed -i 's/^exec /printenv > \/etc\/environment\n\nexec /' /usr/local/bin/apache2-foreground && \ + sed -i 's/^exec /service cron start\n\nexec /' /usr/local/bin/apache2-foreground + +#Cleaning +RUN apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /var/cache/apt/* && \ + rm -rf /usr/share/man/* && \ + rm -rf /usr/share/doc/* && \ + rm -rf /tmp/* \ No newline at end of file diff --git a/apache/supervisor/conf.d/laravel-queues.conf b/apache/supervisor/conf.d/laravel-queues.conf new file mode 100644 index 0000000..f11adc6 --- /dev/null +++ b/apache/supervisor/conf.d/laravel-queues.conf @@ -0,0 +1,20 @@ +[program:queue-default] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=default,importstatistics +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-default.log + +[program:queue-statistics] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=5 --tries=3 --queue=statistics +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-statistics.log + +[program:queue-detections] +command=/usr/local/bin/php %(ENV_APP_ROOT)s/artisan queue:work --sleep=3 --tries=3 --queue=detections +user=www-data +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/queue-detections.log \ No newline at end of file diff --git a/apache/supervisor/supervisord.conf b/apache/supervisor/supervisord.conf new file mode 100644 index 0000000..67127ed --- /dev/null +++ b/apache/supervisor/supervisord.conf @@ -0,0 +1,6 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisor/supervisord.log + +[include] +files = /etc/supervisor/conf.d/*.conf \ No newline at end of file -- 2.54.0 From ac15216de3c5c415c3dd4fe53ff4b6407e543f00 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:42:46 +0100 Subject: [PATCH 27/28] Update Dockerfile for v2-fmp-alpine: enhance PHP configuration and opcache settings --- README.md | 123 ++++++++++++++++++++++++++++++++++++++- v2-fmp-alpine/Dockerfile | 44 ++++++-------- 2 files changed, 140 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b6e9223..e8a0351 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,125 @@ +# docker_php_base + +Základní Docker image pro Laravel aplikace (PHP 8.4). Registr: `git.steelants.cz/steelants/docker_php_base`. + +Všechny image se buildují pro `linux/amd64` a `linux/arm64` (multi-arch manifest) workflow [`.gitea/workflows/docker-build.yaml`](.gitea/workflows/docker-build.yaml) při push do `main`, každou noc v 1:00 a ručně. + +## Přehled image + +| Tag | Zdrojová složka | Základ | Web server | Stav | +|---|---|---|---|---| +| `latest` | [`apache/`](apache/) | `php:8.4-apache` | Apache (`mod_rewrite`) | původní verze (v1), beze změny | +| `v2-latest` | [`v2-apache/`](v2-apache/) | `php:8.4-apache` | Apache (`mod_rewrite`) | nová verze (v2) | +| `alpine-v2-latest` | [`v2-fmp-alpine/`](v2-fmp-alpine/) | `php:8.4-fpm-alpine` | žádný (jen PHP-FPM) | nová verze (v2), v produkci se nepoužívá | + +Společné pro všechny image: + +- PHP rozšíření: `pdo_mysql`, `pgsql`, `pdo_pgsql`, `zip`, `opcache`, `pcntl`, `sockets`, `bcmath`, `soap`, `gd` (freetype, jpeg, webp), `intl`, `calendar`, `imagick` (s rsvg). Build selže, když `imagick` nebo `gd` nemají podporu JPEG. +- Nástroje: `composer`, `git`, `node` + `npm`, `supervisor`, klienti `mysql` a `psql`. +- Časová zóna `Europe/Prague`, `COMPOSER_ALLOW_SUPERUSER=1`. +- Kořen aplikace `APP_ROOT=/var/www/html`. +- `memory_limit=256M`, `upload_max_filesize` a `post_max_size` `100M`, opcache (`PHP_OPCACHE_*`). +- Apache image: document root `APACHE_DOCUMENT_ROOT=${APP_ROOT}/public` (jde přepsat přes `-e`). + +## v1: `latest` (složka `apache/`) + +Původní chování, nic se nemění: + +- Supervisor konfigurace je statická: `supervisor/supervisord.conf` (`nodaemon=true`, `include conf.d/*.conf`) a `supervisor/conf.d/laravel-queues.conf` (queue workery `default,importstatistics`, `statistics`, `detections`). +- Scheduler běží přes **cron**: `* * * * * www-data cd /var/www/html && php artisan schedule:run`, cron se spouští v `apache2-foreground`. +- Supervisor se sám **nespouští**. Aplikace ho spouští ze svého `start.sh` (`supervisord -n &`). +- Žádné skripty při startu. Veškeré nastavení (`.env`, composer, migrace, cache) dělá `start.sh` aplikace. + +## v2: `v2-latest` a `alpine-v2-latest` + +V2 přesouvá obecné kroky ze `start.sh` aplikace do základního image. Obě v2 varianty mají stejnou strukturu i stejné skripty (`entrypoint.d/`, `supervisor.d/`). + +### Jak se spouští + +1. Původní příkaz kontejneru (`apache2-foreground`, resp. `docker-php-entrypoint php-fpm`) je upravený: těsně před `exec` volá [`entrypoint-runner.sh`](v2-apache/entrypoint-runner.sh). +2. Runner spustí **v abecedním pořadí všechny spustitelné `/etc/entrypoint.d/*.sh`**. Každý běží jako samostatný proces (proměnné se mezi skripty nepředávají). +3. **Selže-li skript, start se zastaví** (`entrypoint script failed: `, kontejner skončí). Ostatní skripty ani web server se nespustí. +4. **Zpětná kompatibilita:** pokud v kořeni aplikace existuje `start.sh` (`$APP_ROOT/start.sh`), runner se přeskočí a `entrypoint.d` se nespustí. Image se starým `start.sh` tak nedostane nové skripty. +5. Pro alpine image platí totéž, jen runner běží ze stock `docker-php-entrypoint`, takže projde každý příkaz (i `docker run image php -v`). Skripty v kontejneru bez aplikace (bez `artisan`, `composer.json`) proto končí kódem 0. + +### Skripty v `/etc/entrypoint.d/` (pořadí spouštění) + +| Skript | Co dělá | Poznámka | +|---|---|---| +| `05-permissions.sh` | `chown -R www-data:www-data` na `storage` a `bootstrap/cache`, jen když je vlastník horní složky jiný | namountované volume bývá root-owned | +| `10-opcache.sh` | `APP_DEBUG=false` → nastaví `opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}`; jinak (i když `APP_DEBUG` není nastavené) → `opcache.enable=0` | upravuje `*opcache.ini` v `$PHP_INI_DIR/conf.d` | +| `15-composer.sh` | bez `composer.json` nic; jinak `composer install --prefer-dist --optimize-autoloader` (s dev závislostmi při `APP_DEBUG=true`), jinak s `--no-dev` | běží při **každém** startu, vyžaduje síť. `$init` se nepředává, rozhoduje jen `APP_DEBUG` | +| `20-env.sh` | existuje `/config/.env` → zkopíruje ho do `.env`; jinak, chybí-li `.env` a je `.env.example`, vytvoří `.env` z příkladu a uloží do `/config/.env` | jen s `artisan`, `/config` je vždy volume | +| `25-key.sh` | `php artisan key:generate --force --no-interaction` jen když `APP_KEY` není v prostředí ani v `.env`; vygenerovaný `.env` uloží do `/config/.env` | existující klíč nikdy nepřepíše | +| `26-cache.sh` | `cache:clear`, `config:clear`, `route:clear`, `view:clear` | jen s `artisan`. Při `CACHE_STORE=database` běží před migracemi | +| `27-sqlite.sh` | je-li sqlite (`DB_CONNECTION=sqlite` v `.env` i v prostředí, nebo `DEPLOY_ENV=sqlite`), vytvoří prázdný `database/database.sqlite` | složka `database/` musí existovat | +| `30-storage.sh` | `php artisan storage:link` | jen s `artisan` | +| `35-migrate.sh` | `php artisan migrate --force --no-interaction` | běží při **každém** startu každého kontejneru, tedy i workerů a replik | +| `90-supervisord.sh` | zapíše `/etc/supervisor/supervisord.conf` (`nodaemon=true`, `include /etc/supervisor/conf.d/*.conf`) a spustí `supervisord` na pozadí | | + +Vlastní skript aplikace přidáš do `/etc/entrypoint.d/` s vhodným číslem (soubor musí končit `.sh`, být spustitelný a používat `#!/bin/sh`). Chceš-li skript vypnout, smaž ho (`RUN rm /etc/entrypoint.d/35-migrate.sh`). + +### Supervisor (`/etc/supervisor/conf.d/`) + +Soubory ze složky `supervisor.d/` se kopírují do `/etc/supervisor/conf.d/` a supervisor načte všechny `*.conf`: + +- `laravel-queues.conf`: tři queue workery (`default,importstatistics`, `statistics`, `detections`), `user=www-data`, `autorestart`. +- `laravel-scheduler.conf`: `php artisan schedule:work` (vyžaduje Laravel 8+). **Nahrazuje cron**, ten v2 neobsahuje. +- `reverb.conf.example`: příklad programu `reverb:start --host=0.0.0.0 --no-interaction --debug`. Nenačítá se (přípona `.example`). Zapneš ho tak, že ho zkopíruješ jako `reverb.conf`. + +Cesty ke `artisan` se berou z `%(ENV_APP_ROOT)s`. Programy lze přidat nebo přepsat vlastními soubory v `conf.d`. + +### Volume + +- `/config`: perzistentní `.env` a `APP_KEY` (viz `20-env.sh`, `25-key.sh`). Bez připojeného volume se `.env` a vygenerovaný klíč ztratí při novém kontejneru. Spolehlivější je nastavit `APP_KEY` jako proměnnou prostředí. +- `storage/app` volume si deklaruje aplikace sama. + +### Proměnné prostředí + +| Proměnná | Výchozí | Význam | +|---|---|---| +| `APP_ROOT` | `/var/www/html` | kořen aplikace (skripty, cron/supervisor) | +| `APACHE_DOCUMENT_ROOT` | `${APP_ROOT}/public` | document root (jen apache) | +| `APP_DEBUG` | nenastaveno (alpine: `false`) | řídí opcache a typ `composer install` | +| `PHP_OPCACHE_VALIDATE_TIMESTAMPS` | apache `1`, alpine `0` | použije se při `APP_DEBUG=false` | +| `PHP_OPCACHE_*` | viz Dockerfile | velikosti opcache | +| `APP_KEY` | nenastaveno | je-li nastavená, klíč se negeneruje | +| `DB_CONNECTION`, `DEPLOY_ENV` | nenastaveno | spouští přípravu sqlite (`27-sqlite.sh`) | +| `APP_ENV` | alpine `production` | | + +### Rozdíly mezi `v2-latest` (apache) a `alpine-v2-latest` + +- Alpine je PHP-FPM bez web serveru, před něj musí přijít vlastní web server (např. nginx). +- Alpine nastavuje `APP_ENV=production` a `APP_DEBUG=false`, takže `10-opcache.sh` ponechá opcache zapnutou a `15-composer.sh` použije `--no-dev`. +- Alpine používá `docker-php-entrypoint` a nemá `mod_rewrite`. +- Alpine image se v produkci nepoužívá, byl ověřen jen testy na atrapě `artisan`. + +## Migrace aplikace na v2 (podklad pro AI) + +Postup pro aplikaci, která dnes dědí z `docker_php_base:latest` a má vlastní `start.sh` s `CMD ["/var/www/html/start.sh"]`: + +1. V `Dockerfile` změň `FROM` na `git.steelants.cz/steelants/docker_php_base:v2-latest`. +2. Smaž `start.sh` a řádky `RUN chmod +x /var/www/html/start.sh` a `CMD ["/var/www/html/start.sh"]`. Výchozí příkaz `apache2-foreground` už spouští `entrypoint.d`. Dokud `start.sh` v `APP_ROOT` existuje, v2 skripty se nespustí. +3. Smaž z `Dockerfile` to, co už je v základu: `RUN mkdir -p /config`, `VOLUME /config` a `docker-php-ext-install calendar` (`calendar` je v základu). `VOLUME` pro `storage/app` nech v aplikaci. +4. Z původního `start.sh` už jsou v základu: příprava `.env` z `/config`, generování `APP_KEY`, sqlite, `composer install`, `storage:link`, `migrate`, `*:clear`, úprava opcache a spuštění supervisoru. +5. V základu **není**: `config:cache`, `route:cache`, `view:cache` pro produkci, a `init` (rozlišení prvního startu pro composer). Pokud je aplikace potřebuje, přidej vlastní skript, např. `entrypoint.d/50-optimize.sh` (běží po `26-cache.sh`), a zkopíruj ho `COPY --chmod=755 entrypoint.d/ /etc/entrypoint.d/`. +6. Reverb (`php artisan reverb:start ... &` v `start.sh`) nahraď souborem `/etc/supervisor/conf.d/reverb.conf` (zkopíruj z `reverb.conf.example`). Řádek se `&` ze `start.sh` odstraň, jinak poběží dvakrát. +7. Odstraň ze `start.sh`/Dockeru vlastní spouštění `supervisord`. `90-supervisord.sh` ho spouští sám, dva supervisory by znamenaly duplicitní workery i scheduler. +8. Cron už v základu není a scheduler běží přes supervisor (`schedule:work`, Laravel 8+). Aplikace, která dřív spoléhala na cron z `latest` a nespouštěla supervisor, scheduler při přechodu ztratí. + +Na co si dát při migraci pozor: + +- Skripty jsou **fail-fast**. Chyba migrace, composeru nebo `cache:clear` zastaví start kontejneru. +- Migrace běží při každém startu každého kontejneru. U více replik se mohou přetahovat o zámek. +- `composer install` běží při každém startu a potřebuje síť. Pokud je `vendor` hotový v buildu, zvaž smazání `15-composer.sh`. +- `10-opcache.sh` vypíná opcache i tehdy, když `APP_DEBUG` není nastavené. Nastav `APP_DEBUG=false`, chceš-li opcache v produkci. +- Skripty byly ověřeny na atrapě `artisan` a prázdném projektu, ne na plné Laravel aplikaci. + +## Ruční build + ```bash docker build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t git.steelants.cz/steelants/docker_php_base:latest ./apache +docker build -t git.steelants.cz/steelants/docker_php_base:v2-latest ./v2-apache +docker build -t git.steelants.cz/steelants/docker_php_base:alpine-v2-latest ./v2-fmp-alpine docker push git.steelants.cz/steelants/docker_php_base:latest -``` \ No newline at end of file +``` diff --git a/v2-fmp-alpine/Dockerfile b/v2-fmp-alpine/Dockerfile index 4b7c15a..be7cafb 100644 --- a/v2-fmp-alpine/Dockerfile +++ b/v2-fmp-alpine/Dockerfile @@ -4,16 +4,12 @@ FROM php:8.4-fpm-alpine ENV APP_ROOT="/var/www/html" ENV TZ="Europe/Prague" \ + PHP_INI_FILE="$PHP_INI_DIR/php.ini" \ COMPOSER_ALLOW_SUPERUSER=1 \ - PHP_OPCACHE_ENABLE=1 \ - PHP_OPCACHE_VALIDATE_TIMESTAMPS=0 \ - PHP_OPCACHE_REVALIDATE_FREQ=0 \ - PHP_OPCACHE_MEMORY_CONSUMPTION=192 \ - PHP_OPCACHE_MAX_ACCELERATED_FILES=20000 \ - PHP_OPCACHE_MAX_WASTED_PERCENTAGE=10 \ - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ - APP_ENV=production \ - APP_DEBUG=false + PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \ + PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \ + PHP_OPCACHE_MEMORY_CONSUMPTION="192" \ + PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10" RUN apk add --no-cache \ tzdata \ @@ -81,29 +77,25 @@ RUN php -r 'if (!in_array("JPEG", Imagick::queryFormats())) { fwrite(STDERR, "ER # Composer COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer -RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ - && echo "date.timezone=${TZ}" > "$PHP_INI_DIR/conf.d/99-timezone.ini" - -RUN { \ - echo "memory_limit=256M"; \ - echo "upload_max_filesize=100M"; \ - echo "post_max_size=100M"; \ - echo "realpath_cache_size=4096K"; \ - echo "realpath_cache_ttl=600"; \ -} > "$PHP_INI_DIR/conf.d/99-laravel.ini" +# PHP +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_FILE" && \ + sed -i "s|memory_limit = 128M|memory_limit = 256M |g" "$PHP_INI_FILE" && \ + sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 100M |g" "$PHP_INI_FILE" && \ + sed -i "s|post_max_size = 8M|post_max_size = 100M |g" "$PHP_INI_FILE" && \ + printf '[Date]\ndate.timezone="%s"\n' "$TZ" > "$PHP_INI_DIR/conf.d/tzone.ini" +#OPCACHE RUN { \ echo "[opcache]"; \ - echo "opcache.enable=${PHP_OPCACHE_ENABLE}"; \ - echo "opcache.enable_cli=0"; \ + echo "opcache.enable=1"; \ + echo "opcache.revalidate_freq=0"; \ echo "opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}"; \ - echo "opcache.revalidate_freq=${PHP_OPCACHE_REVALIDATE_FREQ}"; \ - echo "opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}"; \ - echo "opcache.interned_strings_buffer=${PHP_OPCACHE_INTERNED_STRINGS_BUFFER}"; \ echo "opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}"; \ + echo "opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}"; \ echo "opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}"; \ - echo "opcache.save_comments=1"; \ -} > "$PHP_INI_DIR/conf.d/10-opcache.ini" + echo "opcache.interned_strings_buffer=16"; \ + echo "opcache.fast_shutdown=1"; \ +} > "$PHP_INI_DIR/conf.d/opcache.ini" # Supervisor (queue workers + scheduler, started from entrypoint.d/90-supervisord.sh) RUN mkdir -p /var/log/supervisor -- 2.54.0 From 898c5ddb85f9088204949b37a82eed81bb495077 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:46:46 +0100 Subject: [PATCH 28/28] Nemove un used Vars --- README.md | 20 +++++++++++--------- v2-apache/entrypoint.d/27-sqlite.sh | 2 +- v2-fmp-alpine/entrypoint.d/27-sqlite.sh | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e8a0351..7e43863 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ V2 přesouvá obecné kroky ze `start.sh` aplikace do základního image. Obě v | `20-env.sh` | existuje `/config/.env` → zkopíruje ho do `.env`; jinak, chybí-li `.env` a je `.env.example`, vytvoří `.env` z příkladu a uloží do `/config/.env` | jen s `artisan`, `/config` je vždy volume | | `25-key.sh` | `php artisan key:generate --force --no-interaction` jen když `APP_KEY` není v prostředí ani v `.env`; vygenerovaný `.env` uloží do `/config/.env` | existující klíč nikdy nepřepíše | | `26-cache.sh` | `cache:clear`, `config:clear`, `route:clear`, `view:clear` | jen s `artisan`. Při `CACHE_STORE=database` běží před migracemi | -| `27-sqlite.sh` | je-li sqlite (`DB_CONNECTION=sqlite` v `.env` i v prostředí, nebo `DEPLOY_ENV=sqlite`), vytvoří prázdný `database/database.sqlite` | složka `database/` musí existovat | +| `27-sqlite.sh` | je-li sqlite (`DB_CONNECTION=sqlite` v `.env` i v prostředí), vytvoří prázdný `database/database.sqlite` | složka `database/` musí existovat | | `30-storage.sh` | `php artisan storage:link` | jen s `artisan` | | `35-migrate.sh` | `php artisan migrate --force --no-interaction` | běží při **každém** startu každého kontejneru, tedy i workerů a replik | | `90-supervisord.sh` | zapíše `/etc/supervisor/supervisord.conf` (`nodaemon=true`, `include /etc/supervisor/conf.d/*.conf`) a spustí `supervisord` na pozadí | | @@ -78,20 +78,22 @@ Cesty ke `artisan` se berou z `%(ENV_APP_ROOT)s`. Programy lze přidat nebo pře | Proměnná | Výchozí | Význam | |---|---|---| -| `APP_ROOT` | `/var/www/html` | kořen aplikace (skripty, cron/supervisor) | +| `APP_ROOT` | `/var/www/html` | kořen aplikace (skripty, supervisor) | | `APACHE_DOCUMENT_ROOT` | `${APP_ROOT}/public` | document root (jen apache) | -| `APP_DEBUG` | nenastaveno (alpine: `false`) | řídí opcache a typ `composer install` | -| `PHP_OPCACHE_VALIDATE_TIMESTAMPS` | apache `1`, alpine `0` | použije se při `APP_DEBUG=false` | +| `APP_DEBUG` | nenastaveno | řídí opcache a typ `composer install` | +| `PHP_OPCACHE_VALIDATE_TIMESTAMPS` | `1` | použije se při `APP_DEBUG=false` | | `PHP_OPCACHE_*` | viz Dockerfile | velikosti opcache | | `APP_KEY` | nenastaveno | je-li nastavená, klíč se negeneruje | -| `DB_CONNECTION`, `DEPLOY_ENV` | nenastaveno | spouští přípravu sqlite (`27-sqlite.sh`) | -| `APP_ENV` | alpine `production` | | +| `DB_CONNECTION` | nenastaveno | spouští přípravu sqlite (`27-sqlite.sh`) | ### Rozdíly mezi `v2-latest` (apache) a `alpine-v2-latest` -- Alpine je PHP-FPM bez web serveru, před něj musí přijít vlastní web server (např. nginx). -- Alpine nastavuje `APP_ENV=production` a `APP_DEBUG=false`, takže `10-opcache.sh` ponechá opcache zapnutou a `15-composer.sh` použije `--no-dev`. -- Alpine používá `docker-php-entrypoint` a nemá `mod_rewrite`. +Chování je záměrně stejné: stejné výchozí proměnné prostředí, stejné `php.ini` (`memory_limit=256M`, `upload_max_filesize=100M`, `post_max_size=100M`, časová zóna), stejný `opcache.ini`, stejné skripty v `entrypoint.d/` a stejné supervisor programy. Liší se jen to, co vyplývá z technologie: + +- Alpine je PHP-FPM bez web serveru, před něj musí přijít vlastní web server (např. nginx). Nemá `mod_rewrite` ani `APACHE_DOCUMENT_ROOT`. +- Runner běží z jiného místa: apache v `apache2-foreground`, alpine ve stock `docker-php-entrypoint` (projde tedy každý příkaz, i `docker run image php -v`). +- Alpine je postavený na musl a `apk`, apache na Debianu a `apt`. Verze `node`, `git` a klientů se mohou lišit. Composer se do alpine kopíruje z image `composer:2`. +- Apache image navíc zapisuje `printenv` do `/etc/environment` (zbytek po cronu z v1, ve v2 není potřeba). - Alpine image se v produkci nepoužívá, byl ověřen jen testy na atrapě `artisan`. ## Migrace aplikace na v2 (podklad pro AI) diff --git a/v2-apache/entrypoint.d/27-sqlite.sh b/v2-apache/entrypoint.d/27-sqlite.sh index 5a58ed1..7402183 100644 --- a/v2-apache/entrypoint.d/27-sqlite.sh +++ b/v2-apache/entrypoint.d/27-sqlite.sh @@ -1,6 +1,6 @@ #!/bin/sh # SQLite database initialization -if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then +if grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; then if [ ! -f database/database.sqlite ]; then echo "Creating empty SQLite database" touch database/database.sqlite diff --git a/v2-fmp-alpine/entrypoint.d/27-sqlite.sh b/v2-fmp-alpine/entrypoint.d/27-sqlite.sh index 5a58ed1..7402183 100644 --- a/v2-fmp-alpine/entrypoint.d/27-sqlite.sh +++ b/v2-fmp-alpine/entrypoint.d/27-sqlite.sh @@ -1,6 +1,6 @@ #!/bin/sh # SQLite database initialization -if { grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; } || [ "$DEPLOY_ENV" = "sqlite" ]; then +if grep -iq "^DB_CONNECTION=sqlite" .env && [ "$DB_CONNECTION" = "sqlite" ]; then if [ ! -f database/database.sqlite ]; then echo "Creating empty SQLite database" touch database/database.sqlite -- 2.54.0