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 support for PHP 8.3 #92

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ["8.2", "8.1", "8.0"]
php: ["8.3", "8.2", "8.1", "8.0"]
type: ["php-fpm", "cli"]
include:
- type: php-fpm
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ["8.2", "8.1", "8.0"]
php: ["8.3", "8.2", "8.1", "8.0"]
steps:
- name: Set env
run: |
Expand Down
137 changes: 137 additions & 0 deletions 8.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
ARG PHP_VERSION
ARG PROJECT_TYPE

FROM alpine:3.13 AS iconv-build
RUN apk upgrade --no-cache \
&& apk add --no-cache gnu-libiconv

FROM php:${PHP_VERSION}-${PROJECT_TYPE}-alpine3.19

# setup general options for environment variables
ARG PHP_MEMORY_LIMIT_ARG="256M"
ENV PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT_ARG}
ARG PHP_MAX_EXECUTION_TIME_ARG="120"
ENV PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME_ARG}
ARG PHP_UPLOAD_MAX_FILESIZE_ARG="20M"
ENV PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE_ARG}
ARG PHP_MAX_INPUT_VARS_ARG="1000"
ENV PHP_MAX_INPUT_VARS=${PHP_MAX_INPUT_VARS_ARG}
ARG PHP_POST_MAX_SIZE_ARG="8M"
ENV PHP_POST_MAX_SIZE=${PHP_POST_MAX_SIZE_ARG}

# setup opcache for environment variables
ARG PHP_OPCACHE_ENABLE_ARG="1"
ARG PHP_OPCACHE_REVALIDATE_FREQ_ARG="0"
ARG PHP_OPCACHE_VALIDATE_TIMESTAMPS_ARG="0"
ARG PHP_OPCACHE_MAX_ACCELERATED_FILES_ARG="10000"
ARG PHP_OPCACHE_MEMORY_CONSUMPTION_ARG="128"
ARG PHP_OPCACHE_MAX_WASTED_PERCENTAGE_ARG="10"
ARG PHP_OPCACHE_INTERNED_STRINGS_BUFFER_ARG="16"
ARG PHP_OPCACHE_FAST_SHUTDOWN_ARG="1"
ENV PHP_OPCACHE_ENABLE=$PHP_OPCACHE_ENABLE_ARG
ENV PHP_OPCACHE_REVALIDATE_FREQ=$PHP_OPCACHE_REVALIDATE_FREQ_ARG
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS=$PHP_OPCACHE_VALIDATE_TIMESTAMPS_ARG
ENV PHP_OPCACHE_MAX_ACCELERATED_FILES=$PHP_OPCACHE_MAX_ACCELERATED_FILES_ARG
ENV PHP_OPCACHE_MEMORY_CONSUMPTION=$PHP_OPCACHE_MEMORY_CONSUMPTION_ARG
ENV PHP_OPCACHE_MAX_WASTED_PERCENTAGE=$PHP_OPCACHE_MAX_WASTED_PERCENTAGE_ARG
ENV PHP_OPCACHE_INTERNED_STRINGS_BUFFER=$PHP_OPCACHE_INTERNED_STRINGS_BUFFER_ARG
ENV PHP_OPCACHE_FAST_SHUTDOWN=$PHP_OPCACHE_FAST_SHUTDOWN_ARG

# MozJPEG
ENV MOZJPEG_VERSION="4.1.1"
ENV MOZJPEG_BUILD_DEPS \
autoconf \
automake \
cmake \
build-base \
libtool \
nasm \
pkgconf \
tar

RUN set -ex \
&& apk upgrade --no-cache \
&& apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
$MOZJPEG_BUILD_DEPS \
freetype-dev \
icu-dev \
icu-data-full \
libwebp-dev \
imagemagick-dev \
libjpeg-turbo-dev \
libpng-dev \
libxml2-dev \
libzip-dev \
postgresql-dev \
&& apk add --no-cache \
gifsicle \
imagemagick \
jpegoptim \
libjpeg-turbo-utils \
libwebp-tools \
optipng \
libpng-static \
pngquant \
zlib-static \
&& docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
&& docker-php-ext-install -j$(nproc) \
bcmath \
gd \
intl \
opcache \
pdo \
pdo_mysql \
pdo_pgsql \
soap \
zip \
&& pecl install \
redis \
&& docker-php-ext-enable \
redis

# Install imagick from master because there's no tagged release in PECL yet with fixes for PHP 8.3
# https://github.com/Imagick/imagick/issues/640
# Workaround from https://github.com/yiisoft/yii2-docker/compare/324f7e8a36b394d637f1b327d474597b8a49f7de...master
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions imagick/imagick@master

# https://github.com/craftcms/docker/issues/16
COPY --from=iconv-build /usr/lib/preloadable_libiconv.so /usr/lib/preloadable_libiconv.so

# https://github.com/docker-library/php/issues/1121
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so

# MozJPEG
WORKDIR /tmp
ADD https://github.com/mozilla/mozjpeg/archive/v${MOZJPEG_VERSION}.tar.gz ./
RUN set -ex \
&& tar -xzf v${MOZJPEG_VERSION}.tar.gz \
&& cd ./mozjpeg-${MOZJPEG_VERSION} \
&& cmake -DCMAKE_BUILD_TYPE=Release . \
&& make install

RUN ln -s /opt/mozjpeg/bin/jpegtran /usr/local/bin/mozjpegtran
RUN ln -s /opt/mozjpeg/bin/cjpeg /usr/local/bin/mozcjpeg

# Cleanup
RUN RUNTIME_DEPS="$(scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u)" \
&& apk add --no-cache --virtual .runtime-deps $RUNTIME_DEPS \
&& apk del --no-network .build-deps \
&& rm -rf /tmp/*

# copy custom.ini settings
COPY craft-cms.ini /usr/local/etc/php/conf.d/

# run container as the www-data user
USER www-data

# set the working directory for convenience
WORKDIR /app
1 change: 1 addition & 0 deletions 8.3/craft-cms-xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xdebug.mode=develop,debug
14 changes: 14 additions & 0 deletions 8.3/craft-cms.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
memory_limit=${PHP_MEMORY_LIMIT}
max_execution_time=${PHP_MAX_EXECUTION_TIME}
upload_max_filesize=${PHP_UPLOAD_MAX_FILESIZE}
max_input_vars=${PHP_MAX_INPUT_VARS}
post_max_size=${PHP_POST_MAX_SIZE}
[opcache]
opcache.enable=${PHP_OPCACHE_ENABLE}
opcache.revalidate_freq=${PHP_OPCACHE_REVALIDATE_FREQ}
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}
opcache.interned_strings_buffer=${PHP_OPCACHE_INTERNED_STRINGS_BUFFER}
opcache.fast_shutdown=${PHP_OPCACHE_FAST_SHUTDOWN}
33 changes: 33 additions & 0 deletions 8.3/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG PHP_VERSION
ARG PROJECT_TYPE
FROM craftcms/${PROJECT_TYPE}:${PHP_VERSION}

# disable opcache
ENV PHP_OPCACHE_ENABLE=0

USER root

COPY craft-cms-xdebug.ini /usr/local/etc/php/conf.d/

RUN set -ex \
&& apk upgrade --no-cache \
&& apk --no-cache add --virtual .build-deps $PHPIZE_DEPS \
&& apk --no-cache add \
git \
mariadb-connector-c \
mysql-client \
nodejs \
npm \
postgresql-client \
linux-headers \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del --no-network .build-deps

# install composer
RUN set -ex && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

# expose additional ports for node
EXPOSE 3000 3001

USER www-data
33 changes: 32 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.PHONY: build snyk

LOCAL_PHP_VERSION ?= 8.2
LOCAL_PHP_VERSION ?= 8.3

build: all-cli all-cli-dev all-php-fpm all-php-fpm-dev all-nginx all-nginx-dev
snyk: snyk-all-cli snyk-all-cli-dev snyk-all-php-fpm snyk-all-php-fpm-dev snyk-all-nginx snyk-all-nginx-dev

all-cli:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.3 \
--build-arg PROJECT_TYPE=cli \
-t craftcms/cli:8.3 8.3
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.2 \
--build-arg PROJECT_TYPE=cli \
Expand All @@ -20,6 +24,11 @@ all-cli:
-t craftcms/cli:8.0 8.0

all-cli-dev:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
-f 8.3/dev.Dockerfile \
--build-arg PHP_VERSION=8.3 \
--build-arg PROJECT_TYPE=cli \
-t craftcms/cli:8.3-dev 8.3
docker buildx build --load --platform linux/amd64 --builder all-platforms \
-f 8.2/dev.Dockerfile \
--build-arg PHP_VERSION=8.2 \
Expand All @@ -37,6 +46,10 @@ all-cli-dev:
-t craftcms/cli:8.0-dev 8.0

all-php-fpm:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.3 \
--build-arg PROJECT_TYPE=fpm \
-t craftcms/php-fpm:8.3 8.3
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.2 \
--build-arg PROJECT_TYPE=fpm \
Expand All @@ -51,6 +64,11 @@ all-php-fpm:
-t craftcms/php-fpm:8.0 8.0

all-php-fpm-dev:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
-f 8.3/dev.Dockerfile \
--build-arg PHP_VERSION=8.3 \
--build-arg PROJECT_TYPE=php-fpm \
-t craftcms/php-fpm:8.3-dev 8.3
docker buildx build --load --platform linux/amd64 --builder all-platforms \
-f 8.2/dev.Dockerfile \
--build-arg PHP_VERSION=8.2 \
Expand All @@ -68,6 +86,9 @@ all-php-fpm-dev:
-t craftcms/php-fpm:8.0-dev 8.0

all-nginx:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.3 \
-t craftcms/nginx:8.3 nginx
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.2 \
-t craftcms/nginx:8.2 nginx
Expand All @@ -79,6 +100,10 @@ all-nginx:
-t craftcms/nginx:8.0 nginx

all-nginx-dev:
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.3 \
--build-arg NGINX_CONF=dev.default.conf \
-t craftcms/nginx:8.3-dev nginx
docker buildx build --load --platform linux/amd64 --builder all-platforms \
--build-arg PHP_VERSION=8.2 \
--build-arg NGINX_CONF=dev.default.conf \
Expand Down Expand Up @@ -152,36 +177,42 @@ snyk-local:

snyk-all-cli:
snyk container test \
craftcms/cli:8.3 \
craftcms/cli:8.2 \
craftcms/cli:8.1 \
craftcms/cli:8.0

snyk-all-cli-dev:
snyk container test \
craftcms/cli:8.3-dev \
craftcms/cli:8.2-dev \
craftcms/cli:8.1-dev \
craftcms/cli:8.0-dev

snyk-all-php-fpm:
snyk container test \
craftcms/php-fpm:8.3 \
craftcms/php-fpm:8.2 \
craftcms/php-fpm:8.1 \
craftcms/php-fpm:8.0

snyk-all-php-fpm-dev:
snyk container test \
craftcms/php-fpm:8.3-dev \
craftcms/php-fpm:8.2-dev \
craftcms/php-fpm:8.1-dev \
craftcms/php-fpm:8.0-dev

snyk-all-nginx:
snyk container test \
craftcms/nginx:8.3 \
craftcms/nginx:8.2 \
craftcms/nginx:8.1 \
craftcms/nginx:8.0

snyk-all-nginx-dev:
snyk container test \
craftcms/nginx:8.3-dev \
craftcms/nginx:8.2-dev \
craftcms/nginx:8.1-dev \
craftcms/nginx:8.0-dev
Loading