Skip to content

Commit

Permalink
feat: add images for php 8.1 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusDadalto committed Aug 7, 2022
1 parent 17ed19b commit 8d25097
Show file tree
Hide file tree
Showing 18 changed files with 618 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
DOCKER_TAG_NAME: ${{ github.head_ref || github.ref_name }}
strategy:
matrix:
php: [7.2, 7.3, 7.4]
php: [7.2, 7.3, 7.4, 8.1]
kind: [fpm-alpine, cli-alpine]
include:
# Note that this is not parallelizable, there are dependencies
Expand Down
9 changes: 9 additions & 0 deletions compose/php/8.1/8.1-dolphin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3"

services:
magento2:
image: graycore/magento-php:8.1-fpm-alpine-dolphin-v6.0.0-alpha.2
environment:
XDEBUG_CLIENT_PORT: "9003"
XDEBUG_CLIENT_HOST: "localhost"
XDEBUG_MODE: "debug"
8 changes: 8 additions & 0 deletions compose/php/8.1/8.1-xdebug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"

services:
magento2:
image: graycore/magento-php:8.1-fpm-alpine-develop-xdebug
environment:
XDEBUG_CLIENT_PORT: "9003"
XDEBUG_CLIENT_HOST: "host.docker.internal"
5 changes: 5 additions & 0 deletions compose/php/8.1/8.1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version : '3'

services:
magento2:
image: graycore/magento-php:8.1-fpm-alpine-develop
6 changes: 6 additions & 0 deletions compose/php/8.1/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version : '3'

services:
magento2:
build: php/8.1/fpm-alpine-dolphin
image: graycore/magento-php:build
41 changes: 41 additions & 0 deletions php/8.1/cli-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM php:8.1-cli-alpine

LABEL maintainer="damien@graycore.io"

RUN apk add --no-cache \
gzip \
freetype-dev \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libxslt-dev \
lsof \
curl-dev \
libzip-dev \
libsodium-dev \
mysql-client \
procps

# https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html#required-php-extensions
# This layer must be run as one, not two - See: https://github.com/docker-library/php/issues/855
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-install \
bcmath \
gd \
intl \
opcache \
pdo_mysql \
soap \
xsl \
zip \
sockets

RUN curl -sS https://getcomposer.org/installer | \
php -- --install-dir=/usr/local/bin --filename=composer && \
composer self-update

COPY conf/php.ini /usr/local/etc/php/

RUN chmod 775 /var/www/html && chown root:root /var/www/html

WORKDIR /var/www/html
84 changes: 84 additions & 0 deletions php/8.1/cli-alpine/conf/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stock PHP Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user.
; Value "stderr" sends the errors to stderr instead of stdout.
display_errors = Off

; The display of errors which occur during PHP's startup sequence are handled
; separately from display_errors.
display_startup_errors = Off

; Besides displaying errors, PHP can also log errors to locations such as a
; server-specific log, STDERR, or a location specified by the error_log
; directive found below.
log_errors = On

; This directive informs PHP of which errors, warnings and notices you would like
; it to take action for.
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

; This sets the maximum amount of memory in bytes that a script is allowed to allocate.
; This helps prevent poorly written scripts for eating up all available memory on a server.
; Note that to have no memory limit, set this directive to -1.
memory_limit = 4G

; This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.
; This helps prevent poorly written scripts from tying up the server.
; The default setting is 30. When running PHP from the command line the default setting is 0.
max_execution_time = 30

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
max_input_time = 30

; The maximum size of an uploaded file. When an integer is used, the value is measured in bytes.
; Shorthand notation may also be used.
upload_max_filesize = 20M

; Sets max size of post data allowed. This setting also affects file upload. To upload large files,
; this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be
; larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation may also be used.
post_max_size = 20M

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OPcache Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Determines if Zend OPCache is enabled
opcache.enable = 1

; The maximum number of keys (and therefore scripts) in the OPcache hash table.
; The actual value used will be the first number in the set of prime numbers { 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 }
; that is greater than or equal to the configured value. The minimum value is 200.
; The maximum value is 1000000. Values outside of this range are clamped to the permissible range.
;
; After running some tests on Magento 2 instances, the typical file count is around 30000. We use double, just in case.
opcache.max_accelerated_files = 65407

; When enabled, the opcode cache will be checked for whether a file has already been cached when file_exists(), is_file() and is_readable() are called.
; This may increase performance in applications that check the existence and readability of PHP scripts, but risks returning stale data if opcache.validate_timestamps is disabled.
opcache.enable_file_override = 1

;The amount of memory used to store interned strings, in megabytes.
opcache.interned_strings_buffer = 32

; The size of the shared memory storage used by OPcache, in megabytes. The minimum permissible value is "8", which is enforced if a smaller value is set.
opcache.memory_consumption = 200

; How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.
; This configuration directive is ignored if opcache.validate_timestamps is disabled.

; If enabled, OPcache will check for updated scripts every opcache.revalidate_freq seconds. When this directive is disabled, you must reset OPcache manually via opcache_reset(),
; opcache_invalidate() or by restarting the Web server for changes to the filesystem to take effect.
;
; Since we're using a dockerized environment, we're assuming that the final environment is immutable, and therefore validating timestamps
; is unnecessary.
opcache.validate_timestamps = 0

; If disabled, all documentation comments will be discarded from the opcode cache to reduce the size of the optimised code.
; Disabling this configuration directive may break applications and frameworks that rely on comment parsing for annotations,
; including Doctrine, Zend Framework 2, PHPUnit, and Magento 2.
opcache.save_comments = 1
14 changes: 14 additions & 0 deletions php/8.1/fpm-alpine-develop-xdebug/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM graycore/magento-php:8.1-fpm-alpine-develop

LABEL maintainer="damien@graycore.io"

USER root:root

RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del pcre-dev ${PHPIZE_DEPS}

COPY conf/php.ini /usr/local/etc/php/

USER app:app
53 changes: 53 additions & 0 deletions php/8.1/fpm-alpine-develop-xdebug/conf/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stock PHP Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; This sets the maximum amount of memory in bytes that a script is allowed to allocate.
; This helps prevent poorly written scripts for eating up all available memory on a server.
; Note that to have no memory limit, set this directive to -1.
memory_limit = 4G

; This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.
; This helps prevent poorly written scripts from tying up the server.
; The default setting is 30. When running PHP from the command line the default setting is 0.
max_execution_time = 30

date.timezone = UTC

; The maximum size of an uploaded file. When an integer is used, the value is measured in bytes.
; Shorthand notation may also be used.
upload_max_filesize = 20M

; Sets max size of post data allowed. This setting also affects file upload. To upload large files,
; this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be
; larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation may also be used.
post_max_size = 20M

; Whether to transparently compress pages. If this option is set to "On" in php.ini or the Apache configuration,
; pages are compressed if the browser sends an "Accept-Encoding: gzip" or "deflate" header.
; "Content-Encoding: gzip" (respectively "deflate") and "Vary: Accept-Encoding" headers are added to the output.
zlib.output_compression = On

display_errors = stderr
error_log = /dev/stderr
display_startup_errors = On
log_errors = On

; Where the sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail.
; configure does an honest attempt of locating this one for you and set a default,
; but if it fails, you can set it here.
sendmail_path = ${PHP_SENDMAIL_PATH}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Xdebug Settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Selects the host where the debug client is running, you can either use a host name, IP address, or 'unix:///path/to/sock'
; for a Unix domain socket. This setting is ignored if xdebug.remote_connect_back is enabled.
xdebug.client_host = ${XDEBUG_CLIENT_HOST}

; The port to which Xdebug tries to connect on the remote host. Port 9003 is the default for both Xdebug and the Command
; Line Debug Client. As many clients use this port number, it is best to leave this setting unchanged.
xdebug.client_port= ${XDEBUG_CLIENT_PORT}


xdebug.mode = ${XDEBUG_MODE}
41 changes: 41 additions & 0 deletions php/8.1/fpm-alpine-develop/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM graycore/magento-php:8.1-fpm-alpine

LABEL maintainer="damien@graycore.io"

# Blackfire
ENV current_os=alpine
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/$current_os/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

RUN apk add --no-cache \
patch

COPY conf/php.ini /usr/local/etc/php/

ENV MAGENTO_USER=app
ENV MAGENTO_USER_UID=1000
ENV MAGENTO_USER_GID=1000

RUN addgroup --gid "$MAGENTO_USER_GID" "$MAGENTO_USER" && adduser \
--disabled-password \
--gecos "" \
--no-create-home \
--ingroup "$MAGENTO_USER" \
--uid "$MAGENTO_USER_UID" \
-h /var/www \
-s /bin/bash "$MAGENTO_USER"

RUN mkdir -p /var/www/html

RUN chown app:app /var/www/html

USER app:app

VOLUME /var/www/html

WORKDIR /var/www/html
17 changes: 17 additions & 0 deletions php/8.1/fpm-alpine-develop/conf/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
memory_limit = 4G
max_execution_time = 30
zlib.output_compression = On

date.timezone = UTC
upload_max_filesize = 20M
post_max_size = 20M

display_errors = stderr
error_log = /dev/stderr
display_startup_errors = On
log_errors = On

; Where the sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail.
; configure does an honest attempt of locating this one for you and set a default,
; but if it fails, you can set it here.
sendmail_path = ${PHP_SENDMAIL_PATH}
25 changes: 25 additions & 0 deletions php/8.1/fpm-alpine-dolphin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM graycore/magento-php:8.1-fpm-alpine

# Blackfire
ENV current_os=alpine
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/$current_os/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

RUN apk add --no-cache \
openssh patch gnupg git pcre-dev ${PHPIZE_DEPS} \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& apk del pcre-dev ${PHPIZE_DEPS}

COPY conf/php.ini /usr/local/etc/php/

COPY bin /root/

RUN mkdir -p /var/www/html

WORKDIR /var/www/html
Loading

0 comments on commit 8d25097

Please sign in to comment.