Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FrankenPHP support #283

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
40fb22a
Removed comma trimming from package install
jaydrogers Feb 7, 2024
fde0dff
Moved Matrix job generation to a dedicated script
jaydrogers Feb 8, 2024
6e9f0d6
Added first draft of FrankenPHP
jaydrogers Feb 8, 2024
137daa9
Add BUILDKIT_PROGRESS environment variable
jaydrogers Feb 8, 2024
cf876a3
Fix typo in script name
jaydrogers Feb 8, 2024
4c5bd04
Changed name to development images
jaydrogers Feb 8, 2024
ac18d72
Working local PHP
jaydrogers Feb 9, 2024
9a64385
Working entrypoint
jaydrogers Feb 9, 2024
c86f1d1
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers Apr 3, 2024
5e55811
Added OPcache settings
jaydrogers Apr 3, 2024
799b6a6
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers Apr 4, 2024
1cc15aa
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers Apr 4, 2024
8f7b15b
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers May 13, 2024
1efb583
chore: Add SHOW_WELCOME_MESSAGE flag to Dockerfile
jaydrogers May 13, 2024
09ba2c3
chore: Add opcache to DEPENDENCY_PHP_EXTENSIONS in Dockerfile
jaydrogers May 13, 2024
5e2dcf2
chore: Update FRANKEN_PHP_VERSION to 1.1.4 in Dockerfile
jaydrogers May 13, 2024
d1bcbc6
Moved matrix to dedicated script
jaydrogers May 13, 2024
df97ef1
Add sorting
jaydrogers May 13, 2024
8a51c14
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers Jul 31, 2024
2bb76ce
chore: Update FRANKEN_PHP_VERSION to 1.2.2 in Dockerfile
jaydrogers Jul 31, 2024
0ab9bd3
Update `APP_BASE_DIR` default value to "/var/www/html" and add a new …
jaydrogers Jul 31, 2024
73b4031
Merge branch 'main' into 280-create-a-frankenphp-variation
jaydrogers Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/service_docker-build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ We like to customize our images on a per app basis using environment variables.
`APACHE_START_SERVERS`<br />*Default: "2"*|Sets the number of child server processes created on startup.(<a target="_blank" href="https://httpd.apache.org/docs/2.4/mod/mpm_common.html#startservers">Official docs</a>)|fpm-apache
`APACHE_THREAD_LIMIT`<br />*Default: "64"*|Set the maximum configured value for ThreadsPerChild for the lifetime of the Apache httpd process. (<a target="_blank" href="https://httpd.apache.org/docs/2.4/mod/mpm_common.html#threadlimit">Official docs</a>)|fpm-apache
`APACHE_THREADS_PER_CHILD`<br />*Default: "25"*|This directive sets the number of threads created by each child process. (<a target="_blank" href="https://httpd.apache.org/docs/2.4/mod/mpm_common.html#threadsperchild">Official docs</a>)|fpm-apache
`APP_BASE_DIR`<br />*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`<br />*Default: "/var/www/html"*<br />*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`<br />*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`<br />*Default: "true"*|Automatically run "php artisan config:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
`AUTORUN_LARAVEL_EVENT_CACHE`<br />*Default: "true"*|Automatically run "php artisan event:cache" on container start. <br />ℹ️ Requires `AUTORUN_ENABLED = true` to run.| all
Expand All @@ -33,7 +33,7 @@ We like to customize our images on a per app basis using environment variables.
`COMPOSER_HOME`<br />*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`<br />*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`<br />*Default: "false"*|Get full customization of the image and disable all default configurations and automations.| all
`HEALTHCHECK_PATH`<br />*Default: "/healthcheck"*|Set the path for the health check endpoint. (<a target="_blank" href="https://docs.docker.com/engine/reference/builder/#healthcheck">Official docs</a>)|all (except `cli`)
`HEALTHCHECK_PATH`<br />*Default: "/healthcheck"*|Set the path for the health check endpoint. (<a target="_blank" href="https://docs.docker.com/engine/reference/builder/#healthcheck">Official docs</a>)|all (except `cli` and `frankenphp`)
`LOG_OUTPUT_LEVEL`<br />*Default: "warn"*|Set your container output different verbosity levels: debug, info, off |all
`NGINX_FASTCGI_BUFFERS`<br />*Default: "8 8k"*|Sets the number and size of the buffers used for reading a response from a FastCGI server. (<a target="_blank" href="https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffers">Official Docs</a>)|fpm-nginx
`NGINX_FASTCGI_BUFFER_SIZE`<br />*Default: "8k"*|Sets the size of the buffer used for reading a response from a FastCGI server. (<a target="_blank" href="https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffer_size">Official Docs</a>)|fpm-nginx
Expand Down
7 changes: 7 additions & 0 deletions scripts/conf/php-versions-base-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions scripts/generate-matrix.sh
Original file line number Diff line number Diff line change
@@ -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)}'
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
73 changes: 73 additions & 0 deletions src/variations/frankenphp/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]