From 9357f462726ed4072ee0bdb9b1aaccecd481c644 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Sat, 31 Oct 2026 19:34:38 +0100 Subject: [PATCH] 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