diff --git a/.github/workflows/service_docker-build-and-publish.yml b/.github/workflows/service_docker-build-and-publish.yml index 769f88cb..b0c7e935 100644 --- a/.github/workflows/service_docker-build-and-publish.yml +++ b/.github/workflows/service_docker-build-and-publish.yml @@ -66,9 +66,8 @@ jobs: - name: Assemble PHP versions into the matrix. 😎 id: get-php-versions run: | - MATRIX_JSON=$(yq -o=json scripts/conf/php-versions.yml | jq -c '{include: [(.php_variations[] | {name, supported_os: (.supported_os // ["alpine", "bullseye", "bookworm"])} ) as $variation | .php_versions[] | .minor_versions[] | .patch_versions[] as $patch | .base_os[] as $os | select($variation.supported_os | if length == 0 then . else . | index($os.name) end) | {patch_version: $patch, base_os: $os.name, php_variation: $variation.name}]} | {include: (.include | sort_by(.patch_version | split(".") | map(tonumber) | . as $nums | ($nums[0]*10000 + $nums[1]*100 + $nums[2])) | reverse)}') - echo "php-version-map-json=${MATRIX_JSON}" >> $GITHUB_OUTPUT - echo "${MATRIX_JSON}" | jq '.' + chmod +x ./scripts/generate-matrix.sh + MATRIX_JSON=$(./scripts/generate-matrix.sh) - name: Upload the php-versions.yml file uses: actions/upload-artifact@v4 diff --git a/docs/content/docs/7.reference/1.environment-variable-specification.md b/docs/content/docs/7.reference/1.environment-variable-specification.md index 59746417..d940a883 100644 --- a/docs/content/docs/7.reference/1.environment-variable-specification.md +++ b/docs/content/docs/7.reference/1.environment-variable-specification.md @@ -19,7 +19,7 @@ We like to customize our images on a per app basis using environment variables. `APACHE_START_SERVERS`
*Default: "2"*|Sets the number of child server processes created on startup.(Official docs)|fpm-apache `APACHE_THREAD_LIMIT`
*Default: "64"*|Set the maximum configured value for ThreadsPerChild for the lifetime of the Apache httpd process. (Official docs)|fpm-apache `APACHE_THREADS_PER_CHILD`
*Default: "25"*|This directive sets the number of threads created by each child process. (Official docs)|fpm-apache -`APP_BASE_DIR`
*Default: "/var/www/html"*|Change this only if you mount your application to a different directory within the container. ℹ️ Be sure to change `NGINX_WEBROOT`, `APACHE_DOCUMENT_ROOT`, `UNIT_WEBROOT`, etc if it applies to your use case as well.|all +`APP_BASE_DIR`
*Default: "/var/www/html"*
*FrankenPHP: "/app"*|Change this only if you mount your application to a different directory within the container. ℹ️ Be sure to change `NGINX_WEBROOT`, `APACHE_DOCUMENT_ROOT`, `UNIT_WEBROOT`, etc if it applies to your use case as well.|all `AUTORUN_ENABLED`
*Default: "false"*|Enable or disable all automations. It's advised to set this to `false` in certain CI environments (especially during a composer install). If this is set to `false`, all `AUTORUN_*` behaviors will also be disabled.| all `AUTORUN_LARAVEL_CONFIG_CACHE`
*Default: "true"*|Automatically run "php artisan config:cache" on container start.
ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all `AUTORUN_LARAVEL_EVENT_CACHE`
*Default: "true"*|Automatically run "php artisan event:cache" on container start.
ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all @@ -33,7 +33,7 @@ We like to customize our images on a per app basis using environment variables. `COMPOSER_HOME`
*Default: "/composer"*|The COMPOSER_HOME variable allows you to change the Composer home directory. This is a hidden, global (per-user on the machine) directory that is shared between all projects.|all `COMPOSER_MAX_PARALLEL_HTTP`
*Default: "24"*|Set to an integer to configure how many files can be downloaded in parallel. Composer ships with 12 by default and must be between 1 and 50. If your proxy has issues with concurrency maybe you want to lower this. Increasing it should generally not result in performance gains.|all `DISABLE_DEFAULT_CONFIG`
*Default: "false"*|Get full customization of the image and disable all default configurations and automations.| all -`HEALTHCHECK_PATH`
*Default: "/healthcheck"*|Set the path for the health check endpoint. (Official docs)|all (except `cli`) +`HEALTHCHECK_PATH`
*Default: "/healthcheck"*|Set the path for the health check endpoint. (Official docs)|all (except `cli` and `frankenphp`) `LOG_OUTPUT_LEVEL`
*Default: "warn"*|Set your container output different verbosity levels: debug, info, off |all `NGINX_FASTCGI_BUFFERS`
*Default: "8 8k"*|Sets the number and size of the buffers used for reading a response from a FastCGI server. (Official Docs)|fpm-nginx `NGINX_FASTCGI_BUFFER_SIZE`
*Default: "8k"*|Sets the size of the buffer used for reading a response from a FastCGI server. (Official Docs)|fpm-nginx diff --git a/scripts/conf/php-versions-base-config.yml b/scripts/conf/php-versions-base-config.yml index e2ea3e69..900d2e39 100644 --- a/scripts/conf/php-versions-base-config.yml +++ b/scripts/conf/php-versions-base-config.yml @@ -54,6 +54,13 @@ php_variations: - bullseye - bookworm - name: fpm-nginx + - name: frankenphp + supported_os: + - bookworm + excluded_minor_versions: + - "7.4" + - "8.0" + - "8.1" - name: unit supported_os: # Alpine with Unit is not supported yet. Submit a PR if you can help (https://github.com/serversideup/docker-php/issues/233) - bullseye diff --git a/scripts/generate-matrix.sh b/scripts/generate-matrix.sh new file mode 100755 index 00000000..9111dbbd --- /dev/null +++ b/scripts/generate-matrix.sh @@ -0,0 +1,34 @@ +#!/bin/bash +################################################### +# Usage: generate-matrix.sh +################################################### +# This script is used to generate the GitHub Actions +# matrix for the PHP versions and OS combinations. +# +# 👉 REQUIRED FILES +# - PHP_VERSIONS_FILE must be valid and set to a valid file path +# (defaults to scripts/conf/php-versions.yml) + +set -euo pipefail + +# Path to the PHP versions configuration file +PHP_VERSIONS_FILE="${PHP_VERSIONS_FILE:-"scripts/conf/php-versions.yml"}" + +# Generate and output the MATRIX_JSON +yq -o=json "$PHP_VERSIONS_FILE" | +jq -c '{ + include: [ + (.php_variations[] | + {name, supported_os: (.supported_os // ["alpine", "bullseye", "bookworm"]), excluded_minor_versions: (.excluded_minor_versions // [])} + ) as $variation | + .php_versions[] | + .minor_versions[] | + # Check if the minor version is not in the excluded list for the variation + select([.minor] | inside($variation.excluded_minor_versions | map(.)) | not) | + .patch_versions[] as $patch | + .base_os[] as $os | + select($variation.supported_os | if length == 0 then . else . | index($os.name) end) | + {patch_version: $patch, base_os: $os.name, php_variation: $variation.name} + ] +} | +{include: (.include | sort_by(.patch_version | split(".") | map(tonumber) | . as $nums | ($nums[0]*10000 + $nums[1]*100 + $nums[2])) | reverse)}' diff --git a/src/common/usr/local/bin/docker-php-serversideup-dep-install-alpine b/src/common/usr/local/bin/docker-php-serversideup-dep-install-alpine index be14e8ac..2e8265e3 100644 --- a/src/common/usr/local/bin/docker-php-serversideup-dep-install-alpine +++ b/src/common/usr/local/bin/docker-php-serversideup-dep-install-alpine @@ -24,22 +24,14 @@ if [ "$NAME" != "Alpine Linux" ] || [ $# -eq 0 ]; then exit 0 fi -############ -# Functions -############ -convert_comma_delimited_to_space_separated() { - echo $1 | tr ',' ' ' -} - ############ # Main ############ -DEP_PACKAGES=$(convert_comma_delimited_to_space_separated "$@") +DEP_PACKAGES="$@" echo "🤖 Installing: $DEP_PACKAGES" apk update apk add --no-cache $DEP_PACKAGES - echo "🧼 Cleaning up installation of: $DEP_PACKAGES" rm -rf /var/cache/apk/* diff --git a/src/common/usr/local/bin/docker-php-serversideup-dep-install-debian b/src/common/usr/local/bin/docker-php-serversideup-dep-install-debian index 309a9cf9..daa5e1fc 100644 --- a/src/common/usr/local/bin/docker-php-serversideup-dep-install-debian +++ b/src/common/usr/local/bin/docker-php-serversideup-dep-install-debian @@ -25,22 +25,14 @@ if [ "$NAME" != "Debian GNU/Linux" ] || [ $# -eq 0 ]; then exit 0 fi -############ -# Functions -############ -convert_comma_delimited_to_space_separated() { - echo $1 | tr ',' ' ' -} - ############ # Main ############ -DEP_PACKAGES=$(convert_comma_delimited_to_space_separated "$@") +DEP_PACKAGES="$@" echo "🤖 Installing: $DEP_PACKAGES" apt-get update apt-get install -y $DEP_PACKAGES - echo "🧼 Cleaning up installation of: $DEP_PACKAGES" apt-get clean rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/src/variations/frankenphp/Dockerfile b/src/variations/frankenphp/Dockerfile new file mode 100644 index 00000000..98dddedc --- /dev/null +++ b/src/variations/frankenphp/Dockerfile @@ -0,0 +1,73 @@ +ARG BASE_OS_VERSION='bookworm' +ARG PHP_VERSION='8.3' +ARG FRANKEN_PHP_VERSION='1.2.2' +ARG PHP_VARIATION='frankenphp' +ARG BASE_IMAGE="dunglas/frankenphp:${FRANKEN_PHP_VERSION}-php${PHP_VERSION}-${BASE_OS_VERSION}" + +########## +# CLI: Main Image +########## +FROM ${BASE_IMAGE} + +ARG DEPENDENCY_PACKAGES_ALPINE='shadow' +ARG DEPENDENCY_PACKAGES_DEBIAN='zip' +ARG DEPENDENCY_PHP_EXTENSIONS='opcache pcntl pdo_mysql pdo_pgsql redis zip' + +LABEL org.opencontainers.image.title="serversideup/php (${PHP_VARIATION})" \ + org.opencontainers.image.description="Supercharge your PHP experience. Based off the offical PHP images, serversideup/php includes pre-configured PHP extensions and settings for enhanced performance and security. Optimized for Laravel and WordPress." \ + org.opencontainers.image.url="https://serversideup.net/open-source/docker-php/" \ + org.opencontainers.image.source="https://github.com/serversideup/docker-php" \ + org.opencontainers.image.documentation="https://serversideup.net/open-source/docker-php/docs/" \ + org.opencontainers.image.vendor="ServerSideUp" \ + org.opencontainers.image.authors="Jay Rogers (@jaydrogers)" \ + org.opencontainers.image.version="${REPOSITORY_BUILD_VERSION}" \ + org.opencontainers.image.licenses="GPL-3.0-or-later" + +ENV APP_BASE_DIR=/app \ + COMPOSER_ALLOW_SUPERUSER=1 \ + COMPOSER_HOME=/composer \ + COMPOSER_MAX_PARALLEL_HTTP=24 \ + DISABLE_DEFAULT_CONFIG=false \ + LOG_OUTPUT_LEVEL=warn \ + PHP_DATE_TIMEZONE="UTC" \ + PHP_DISPLAY_ERRORS=Off \ + PHP_DISPLAY_STARTUP_ERRORS=Off \ + PHP_ERROR_LOG="/dev/stderr" \ + PHP_ERROR_REPORTING="22527" \ + PHP_MAX_EXECUTION_TIME="99" \ + PHP_MAX_INPUT_TIME="-1" \ + PHP_MEMORY_LIMIT="256M" \ + PHP_OPCACHE_ENABLE="0" \ + PHP_OPCACHE_INTERNED_STRINGS_BUFFER="8" \ + PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \ + PHP_OPCACHE_MEMORY_CONSUMPTION="128" \ + PHP_OPCACHE_REVALIDATE_FREQ="2" \ + PHP_OPEN_BASEDIR="" \ + PHP_POST_MAX_SIZE="100M" \ + PHP_SESSION_COOKIE_SECURE=false \ + PHP_UPLOAD_MAX_FILE_SIZE="100M" \ + SHOW_WELCOME_MESSAGE=true + +# copy our scripts +COPY --chmod=755 src/common/ / + +# install pecl extensions & dependencies +RUN docker-php-serversideup-dep-install-alpine "${DEPENDENCY_PACKAGES_ALPINE}" && \ + docker-php-serversideup-dep-install-debian "${DEPENDENCY_PACKAGES_DEBIAN}" && \ + docker-php-serversideup-install-php-ext-installer && \ + \ + # Make composer cache directory + mkdir -p "${COMPOSER_HOME}" && \ + chown -R www-data:www-data "${COMPOSER_HOME}" && \ + \ + # Install default PHP extensions + install-php-extensions "${DEPENDENCY_PHP_EXTENSIONS}" + +# install composer from Composer's official Docker image +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR ${APP_BASE_DIR} + +ENTRYPOINT ["docker-php-serversideup-entrypoint"] + +CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] \ No newline at end of file