Skip to content

Commit

Permalink
Added php 8.2 and 8.3 images
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-lcm committed Jan 3, 2025
1 parent 8219d46 commit 1113f1e
Show file tree
Hide file tree
Showing 29 changed files with 1,013 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
- "8.1"
- "8.1-dev"
- "8.1-dev-node-20"
- "8.2"
- "8.2-dev"
- "8.3"
- "8.3-dev"
steps:
- name: Checkout Code
uses: actions/checkout@v1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
- "8.0-dev"
- "8.1"
- "8.1-dev"
- "8.2"
- "8.2-dev"
- "8,3"
- "8.3-dev"
steps:
- name: Checkout Code
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion 8.1-dev-node-20/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ commandTests:
command: "node"
args: ["--version"]
expectedOutput:
- v16.
- v20.
- name: "Yarn should be installed and functional"
command: "yarn"
args: ["--version"]
Expand Down
155 changes: 155 additions & 0 deletions 8.2-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
FROM php:8.2-apache

# common-php70
ENV DEBIAN_FRONTEND noninteractive
ENV APACHE_DOCROOT /var/www/html
ENV PATH=/var/www/vendor/bin:$PATH
ENV COMPOSER_MEMORY_LIMIT "-1"

RUN apt-get update && apt-get install -y --no-install-recommends \
# for bz2
bzip2 libbz2-dev \
# for ftp
libssl-dev \
# for gd
libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
# for intl
libicu-dev \
# for dom
libxml2-dev \
# for ldap
libldap2-dev \
# for mysql
mariadb-client \
# for ssh client only
openssh-client \
# For image optimization
jpegoptim \
optipng \
pngquant \
# php7.3 needs zlib1g-dev and libzip-dev for the zip extension
# https://github.com/docker-library/php/issues/61#issuecomment-468874705
zlib1g-dev \
libzip-dev \
# for git
git \
# for composer
unzip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN docker-php-ext-configure gd \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \
&& docker-php-ext-install -j$(nproc) \
bcmath \
bz2 \
calendar \
exif \
ftp \
gd \
gettext \
intl \
ldap \
mysqli \
opcache \
pcntl \
pdo_mysql \
shmop \
soap \
sockets \
sysvmsg \
sysvsem \
sysvshm \
zip \
&& pecl install redis apcu \
&& docker-php-ext-enable redis apcu

# Configure Apache:
RUN a2enmod rewrite headers expires \
&& sed -i "/DocumentRoot \/var\/www\/html/c\\\tDocumentRoot \$\{APACHE_DOCROOT\}" /etc/apache2/sites-enabled/000-default.conf \
# Preemptively add a user 1000, for use with $APACHE_RUN_USER on osx
&& adduser --uid 1000 --gecos 'My OSX User' --disabled-password osxuser

# Install Composer.

ARG COMPOSER_VERSION=2.3.10
RUN COMPOSER_SHA384=$(curl https://composer.github.io/installer.sig) \
&& curl -fsSL -o composer-setup.php https://getcomposer.org/installer \
&& echo "$COMPOSER_SHA384 composer-setup.php" | sha384sum -c - \
&& php composer-setup.php --version=$COMPOSER_VERSION --install-dir=/usr/local/bin --filename=composer

# Install Dockerize.
ARG DOCKERIZE_VERSION=v0.6.1
ARG DOCKERIZE_SHA256=1fa29cd41a5854fd5423e242f3ea9737a50a8c3bcf852c9e62b9eb02c6ccd370
RUN curl -fsSOL https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& echo "$DOCKERIZE_SHA256 dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz" | sha256sum -c - \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

# Install Drush Launcher. Whereas previously we installed Drush globally, we no longer do,
# since it's expected that D8 sites will include their own copy of Drush, and Drush 9+ is
# incompatible with Drupal < 8.
# @todo: Is the launcher even needed? We add /var/www/vendor/bin on the global path.
ARG DRUSH_LAUNCHER_VERSION=0.6.0
ARG DRUSH_LAUNCHER_SHA256=c3f32a800a2f18470b0010cd71c49e49ef5c087f8131eecfe9b686dc1f3f3d4e
RUN curl -fsSOL https://github.com/drush-ops/drush-launcher/releases/download/$DRUSH_LAUNCHER_VERSION/drush.phar \
&& echo "$DRUSH_LAUNCHER_SHA256 drush.phar" | sha256sum -c - \
&& mv drush.phar /usr/bin/drush && chmod +x /usr/bin/drush

# Pre-trust Github host certificates.
RUN ssh-keyscan github.com >> /etc/ssh/ssh_known_hosts

ADD templates /templates
ADD scripts/* /usr/local/bin/

# /common-php70

# NodeJS + Yarn
ARG NODE_MAJOR_VERSION=22
RUN apt-get update \
&& apt-get install -y apt-transport-https lsb-release gnupg > /dev/null 2>&1 \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& curl -sL "https://deb.nodesource.com/setup_$NODE_MAJOR_VERSION.x" | bash \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
# Force apt to use the deb.nodesource repository
&& echo "Package: nodejs\nPin: origin deb.nodesource.com\nPin-priority: 1000" > /etc/apt/preferences.d/99-nodejs \
&& apt-get install -y nodejs \
&& apt-get install -y --no-install-recommends yarn \
\
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# XDebug
# TODO: Remove xdebug next time it causes problems. It is a lot of effort
# to maintain, and no one is actually using it.
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo "xdebug.mode=debug" > $PHP_INI_DIR/conf.d/xdebug.ini


# Blackfire Probe. Note: We do not install Blackfire CLI. You will
# need that in order to trigger Blackfire tests. The probe just instruments
# things on the server side.
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz

# Terminus.
ARG TERMINUS_VERSION=3.0.7
ARG TERMINUS_SHA256="f8fd66afb825ba2314a3c1d9a0b0e7e3dedbe687668613bd511ff6b41c4c6516"
RUN curl -fsSOL https://github.com/pantheon-systems/terminus/releases/download/$TERMINUS_VERSION/terminus.phar \
&& echo "$TERMINUS_SHA256 terminus.phar" | sha256sum -c - \
&& mv terminus.phar /usr/local/bin/terminus \
&& chmod +x /usr/local/bin/terminus

# Gulp-cli.
RUN npm i --no-cache -g gulp-cli

# ImageMagick
RUN apt-get update \
&& apt-get install -y imagemagick > /dev/null 2>&1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

3 changes: 3 additions & 0 deletions 8.2-dev/scripts/check-apache-mem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'
28 changes: 28 additions & 0 deletions 8.2-dev/scripts/docker-php-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -e

# Write overrides to PHP and Apache. This is incompatible with starting the container
# with any user other than root, but that's not advised for the PHP Apache container
# anyway.

# PHP 7.3 is the first version that uses Xdebug 3; it's easier to check
# the php version in here than the Xdebug version
php_at_least_7_3=$(php -r 'echo version_compare(PHP_VERSION, "7.3") >= 0;')

PHP_AT_LEAST_7_3=$php_at_least_7_3 dockerize \
-template /templates/php.overrides.tmpl:$PHP_INI_DIR/conf.d/99-runtime.ini \
-template /templates/mpm_prefork.conf.tmpl:/etc/apache2/mods-enabled/mpm_prefork.conf

# Toggle XDebug completely on and off at runtime
# Enable Xdebug by setting XDEBUG_ENABLE=1.
if [ -z "$XDEBUG_ENABLE" ] || [ "$XDEBUG_ENABLE" -eq "0" ]; then
rm -f $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini
else
docker-php-ext-enable xdebug
fi

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
exec "$@"
8 changes: 8 additions & 0 deletions 8.2-dev/templates/mpm_prefork.conf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Allow overriding some settings to control performance.
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers {{ default .Env.APACHE_REQUEST_WORKERS "150" }}
MaxConnectionsPerChild 5000
</IfModule>
23 changes: 23 additions & 0 deletions 8.2-dev/templates/php.overrides.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Set a reasonable max upload size
upload_max_filesize = 128M
post_max_size = 128M

; These settings can be overridden at runtime by the presence of environment
; variables.
date.timezone={{ default .Env.TZ "UTC" }}
{{ if .Env.PHP_MEMORY_LIMIT }}memory_limit={{ .Env.PHP_MEMORY_LIMIT }}{{ end }}
{{ if .Env.SENDMAIL_PATH }}sendmail_path={{ .Env.SENDMAIL_PATH }}{{ end }}

; XDebug can be conditionally triggered.
{{ if .Env.XDEBUG_ENABLE }}
{{ if .Env.PHP_AT_LEAST_7_3 }}
xdebug.client_host={{ default .Env.XDEBUG_REMOTE_HOST "host.docker.internal" }}
xdebug.idekey={{ default .Env.XDEBUG_IDEKEY "PHPSTORM" }}
xdebug.start_with_request={{ default .Env.XDEBUG_START_WITH_REQUEST "yes" }}
{{ else }}
xdebug.remote_host={{ default .Env.XDEBUG_REMOTE_HOST "host.docker.internal" }}
xdebug.idekey={{ default .Env.XDEBUG_IDEKEY "PHPSTORM" }}
xdebug.remote_enable={{ default .Env.XDEBUG_REMOTE_ENABLE "On" }}
xdebug.remote_autostart={{ default .Env.XDEBUG_REMOTE_AUTOSTART "On" }}
{{ end }}
{{ end }}
80 changes: 80 additions & 0 deletions 8.2-dev/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
schemaVersion: "2.0.0"
commandTests:
- name: "php should be configurable by environment variables"
setup: [["docker-php-entrypoint"]]
envVars:
- {key: PHP_MEMORY_LIMIT, value: 512M }
- {key: SENDMAIL_PATH, value: /bin/true }
- {key: TZ, value: America/New_York }
command: "php"
args: ["-i"]
expectedOutput:
- memory_limit => 512M => 512M
- sendmail_path => /bin/true => /bin/true
- date.timezone => America/New_York => America/New_York
- name: "php should use have default values"
setup: [["docker-php-entrypoint"]]
command: "php"
args: ["-i"]
expectedOutput:
- memory_limit => 128M => 128M
- sendmail_path => (?:\/usr\/sbin\/sendmail)? -t -i\s*=> (?:\/usr\/sbin\/sendmail)? -t -i
- date.timezone => UTC => UTC
- name: "Composer should work"
command: composer
args: ["diagnose"]
- name: "Drush should be launchable"
command: drush
args: ["--drush-launcher-version"]
expectedOutput:
- "Drush Launcher Version: 0.6.0"

- name: "Blackfire agent should be present and configured"
command: "php"
args: ["-i"]
expectedOutput:
- Blackfire => enabled
- blackfire.agent_socket => tcp://blackfire:8707 => tcp://blackfire:8707
- name: "XDebug should be installed and disabled by default"
command: "php"
args: ["-m"]
setup: [["docker-php-entrypoint"]]
excludedOutput:
- Xdebug
- name: "XDebug should be enableable using a simple environment variable"
command: "php"
args: ["-m"]
setup: [["docker-php-entrypoint"]]
envVars:
- {key: XDEBUG_ENABLE, value: True }
expectedOutput:
- Xdebug
- name: "XDebug should be configurable by using environment variables"
command: "php"
args: ["-i"]
setup: [["docker-php-entrypoint"]]
envVars:
- {key: XDEBUG_ENABLE, value: True }
- {key: XDEBUG_REMOTE_HOST, value: foo.bar}
- {key: XDEBUG_IDEKEY, value: foobar}

- {key: XDEBUG_START_WITH_REQUEST, value: "yes"}

expectedOutput:
- xdebug.idekey => foobar => foobar

- xdebug.start_with_request => yes => yes
- xdebug.client_host => foo.bar => foo.bar

- name: "NodeJS Should be installed and in the correct version"
command: "node"
args: ["--version"]
expectedOutput:
- v22.
- name: "Yarn should be installed and functional"
command: "yarn"
args: ["--version"]
- name: "Terminus should be installed and functional"
command: "terminus"
args: ["self:info"]

Loading

0 comments on commit 1113f1e

Please sign in to comment.