From 8545e467e0da5e22bc31f3fc4408332c18f0c3dc Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Thu, 8 Aug 2024 11:46:04 +0100 Subject: [PATCH] feat: BL-17333 - Dockerfile and resources for Apache PHP 8.2, base image only (#42) * Dockerfile and resources for apache php8.3 * filename uppercased * force commit change filename * remove filename typo to reprompt gha job * repush failed run * add apache proxy files and sysconfig * lint fixes * lint fixes * lint fixes, removing update command * rm cache apk* to remove unneeded cache load * finally, add package versions * more package versions * attempt ignore for package version until we resolve each package specifically * nocache options * use dockerhub alpine image * add tailing lines, remove superfluous comment * revert to 8.2, scale to base php image * remove defunct zip * php82 file name change --- .github/workflows/cd.yaml | 4 ++++ .github/workflows/ci.yaml | 4 ++++ php/8.2/fpm-apache/Dockerfile | 32 +++++++++++++++++++++++++++ php/8.2/fpm-apache/httpd-foreground | 8 +++++++ php/8.2/fpm-apache/httpd-sysconfig | 27 ++++++++++++++++++++++ php/8.2/fpm-apache/php-fpm-proxy.conf | 3 +++ 6 files changed, 78 insertions(+) create mode 100644 php/8.2/fpm-apache/Dockerfile create mode 100644 php/8.2/fpm-apache/httpd-foreground create mode 100644 php/8.2/fpm-apache/httpd-sysconfig create mode 100644 php/8.2/fpm-apache/php-fpm-proxy.conf diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index b1c2465..03448e3 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -68,12 +68,16 @@ jobs: matrix: base: - php/8.2/fpm-nginx + - php/8.2/fpm-apache - php/8.3/fpm-nginx + - php/8.0/cli - php/8.2/cli - php/8.3/cli exclude: - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/fpm-nginx') && 'ignored' || 'php/8.2/fpm-nginx' }} + - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/fpm-apache') && 'ignored' || 'php/8.2/fpm-apache' }} - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.3/fpm-nginx') && 'ignored' || 'php/8.3/fpm-nginx' }} + - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.0/cli') && 'ignored' || 'php/8.0/cli' }} - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/cli') && 'ignored' || 'php/8.2/cli' }} - base: ${{ github.event_name == 'schedule' || needs.release-please.outputs.release_created || contains(needs.orchestrator.outputs.changed-directories, 'php/8.3/cli') && 'ignored' || 'php/8.3/cli' }} uses: ./.github/workflows/docker.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c7de1f8..bf28388 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,12 +34,16 @@ jobs: matrix: base: - php/8.2/fpm-nginx + - php/8.2/fpm-apache - php/8.3/fpm-nginx + - php/8.0/cli - php/8.2/cli - php/8.3/cli exclude: - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/fpm-nginx') && 'ignored' || 'php/8.2/fpm-nginx' }} + - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/fpm-apache') && 'ignored' || 'php/8.2/fpm-apache' }} - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.3/fpm-nginx') && 'ignored' || 'php/8.3/fpm-nginx' }} + - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.0/cli') && 'ignored' || 'php/8.0/cli' }} - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.2/cli') && 'ignored' || 'php/8.2/cli' }} - base: ${{ contains(needs.orchestrator.outputs.changed-directories, 'php/8.3/cli') && 'ignored' || 'php/8.3/cli' }} uses: ./.github/workflows/docker.yaml diff --git a/php/8.2/fpm-apache/Dockerfile b/php/8.2/fpm-apache/Dockerfile new file mode 100644 index 0000000..eeddbf4 --- /dev/null +++ b/php/8.2/fpm-apache/Dockerfile @@ -0,0 +1,32 @@ +FROM php:8.2-fpm-alpine3.20 + +# hadolint ignore=DL3018 +RUN apk update && \ + apk upgrade --no-cache && \ + apk add --no-cache \ + jq \ + openrc \ + apache2 \ + apache2-ctl \ + build-base \ + apache2-proxy && \ + apk del php82-apache2 && \ + rm /var/cache/apk/* + + +# (Default Virtual Host is created with Apache install) +# Disable prefork and enable event +RUN sed -ri -e 's!^LoadModule mpm_prefork_module modules/mod_mpm_prefork.so!#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so!g' /etc/apache2/httpd.conf && \ + sed -ri -e 's!^#LoadModule mpm_event_module modules/mod_mpm_event.so!LoadModule mpm_event_module modules/mod_mpm_event.so!g' /etc/apache2/httpd.conf && \ + sed -ri -e 's!^#LoadModule expires_module modules/mod_expires.so!LoadModule expires_module modules/mod_expires.so!g' /etc/apache2/httpd.conf && \ + sed -ri -e 's!^#LoadModule rewrite_module modules/mod_rewrite.so!LoadModule rewrite_module modules/mod_rewrite.so!g' /etc/apache2/httpd.conf + +# Copy Apache FPM proxy config +COPY ./php-fpm-proxy.conf /etc/apache2/conf.d/php-fpm-proxy.conf + +# Apache Config file +COPY ./httpd-sysconfig /etc/sysconfig/httpd + +# Apache service start script +COPY httpd-foreground /usr/local/bin/ +RUN chmod +x /usr/local/bin/httpd-foreground diff --git a/php/8.2/fpm-apache/httpd-foreground b/php/8.2/fpm-apache/httpd-foreground new file mode 100644 index 0000000..2778461 --- /dev/null +++ b/php/8.2/fpm-apache/httpd-foreground @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +# (this short script is taken from the official Apache Alpine dockerfile) + +# Apache gets grumpy about PID files pre-existing +rm -f /usr/local/apache2/logs/httpd.pid + +exec httpd -DFOREGROUND "$@" diff --git a/php/8.2/fpm-apache/httpd-sysconfig b/php/8.2/fpm-apache/httpd-sysconfig new file mode 100644 index 0000000..07be35e --- /dev/null +++ b/php/8.2/fpm-apache/httpd-sysconfig @@ -0,0 +1,27 @@ +# +# This file can be used to set additional environment variables for +# the httpd process, or pass additional options to the httpd +# executable. +# +# Note: With previous versions of httpd, the MPM could be changed by +# editing an "HTTPD" variable here. With the current version, that +# variable is now ignored. The MPM is a loadable module, and the +# choice of MPM can be changed by editing the configuration file +# /etc/httpd/conf.modules.d/00-mpm.conf. +# + +# +# To pass additional options (for instance, -D definitions) to the +# httpd binary at startup, set OPTIONS here. +# +#OPTIONS= + +# +# This setting ensures the httpd process is started in the "C" locale +# by default. (Some modules will not behave correctly if +# case-sensitive string comparisons are performed in a different +# locale.) +# +LANG=C + +umask 0027 diff --git a/php/8.2/fpm-apache/php-fpm-proxy.conf b/php/8.2/fpm-apache/php-fpm-proxy.conf new file mode 100644 index 0000000..80d49e4 --- /dev/null +++ b/php/8.2/fpm-apache/php-fpm-proxy.conf @@ -0,0 +1,3 @@ + + SetHandler "proxy:fcgi://127.0.0.1:9000" +