Skip to content

refs #000: install ftp extension. #79

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

Merged
merged 5 commits into from
Jan 16, 2025
Merged
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: 3 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tag: [8-3-2, 8-2-3, 8-1-16, 8-1-10]
tag: [8-4-2, 8-3-15, 8-3-2, 8-2-3, 8-1-16, 8-1-10]
flavour: ["", "-rootless"]
steps:
- uses: actions/checkout@v4
Expand All @@ -36,6 +36,8 @@ jobs:
matrix:
tag:
[
8.4.2-fpm-alpine3.21,
8.3.15-fpm-alpine3.21,
8.3.2-fpm-alpine3.18,
8.2.3-fpm-alpine3.16,
8.1.16-fpm-alpine3.16,
Expand Down
6 changes: 4 additions & 2 deletions 8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ ENV XDEBUG_VERSION 3.3.1
ENV MEMCACHE_VERSION 3.2.0
ENV PHPREDIS_VERSION 5.3.7
RUN export XDEBUG_DEPS="linux-headers" && \
export PHP_EXTRA_DEPS="libxml2-dev icu-dev libmemcached-dev cyrus-sasl-dev libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev libzip-dev oniguruma-dev libwebp-dev ldb-dev libldap openldap-dev" && \
export PHP_EXTRA_DEPS="libxml2-dev icu-dev libmemcached-dev cyrus-sasl-dev libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev libzip-dev oniguruma-dev libwebp-dev ldb-dev libldap openldap-dev openssl-dev" && \
apk update && \
apk add ${PHP_EXTRA_DEPS} ${PHPIZE_DEPS} ${XDEBUG_DEPS} gettext && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include && \
docker-php-ext-configure ldap && \
docker-php-ext-install bcmath gd intl mbstring pcntl pdo pdo_mysql soap zip ldap && \
export OPENSSL_LIBS="-L/usr -lssl -lcrypto -lz" && export OPENSSL_CFLAGS="-I/usr/include" && \
docker-php-ext-configure ftp --with-openssl-dir=/usr/include/ && \
docker-php-ext-install bcmath gd intl mbstring pcntl pdo pdo_mysql soap zip ldap ftp && \
pecl install xdebug-${XDEBUG_VERSION} && \
pecl install redis-${PHPREDIS_VERSION} && \
pecl install igbinary memcached-${MEMCACHE_VERSION} --disable-memcached-sasl && \
Expand Down
128 changes: 128 additions & 0 deletions 8.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
ARG PHPVER

FROM golang:1.22.0-alpine3.18 as mailhog

# Install mailhog.
ENV MAILHOG_VERSION 1.0.1
RUN apk add git && \
go install github.com/mailhog/MailHog@v${MAILHOG_VERSION} && \
mv /go/bin/MailHog /go/mailhog

FROM php:$PHPVER as dist

# Build target arch passed by BuildKit
ARG TARGETARCH

# Pass inexistent UUID (e.g.: 1001) to enhance the container security
ARG user=root

# Default php configurations values.
ENV PHP_MEMORY_LIMIT 64M
ENV PHP_TIMEZONE=Europe/Rome
ENV PHP_REALPATH_CACHE_SIZE 2M
ENV PHP_UPLOAD_MAX_FILE_SIZE 32M
ENV PHP_POST_MAX_SIZE 32M
ENV PHP_MAX_EXECUTION_TIME 30
ENV BLACKFIRE_HOST=${BLACKFIRE_HOST:-blackfire}
ENV BLACKFIRE_PORT=${BLACKFIRE_PORT:-8307}
ENV PHP_EXPOSE_PHP 0

# FPM Configurations.
ENV PHP_FPM_PM_TYPE dynamic
ENV PHP_FPM_MAX_CHILDREN 5
ENV PHP_FPM_START_SERVERS 2
ENV PHP_FPM_MIN_SPARE_SERVERS 1
ENV PHP_FPM_MAX_SPARE_SERVERS 3
ENV PHP_FPM_PM_STATUS_PATH /status

ENV XDEBUG_VERSION 3.4.1
ENV MEMCACHE_VERSION 3.3.0
ENV PHPREDIS_VERSION 6.1.0
RUN export XDEBUG_DEPS="linux-headers" && \
export PHP_EXTRA_DEPS="libxml2-dev icu-dev libmemcached-dev cyrus-sasl-dev libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev libzip-dev oniguruma-dev libwebp-dev ldb-dev libldap openldap-dev openssl-dev" && \
apk update && \
apk add ${PHP_EXTRA_DEPS} ${PHPIZE_DEPS} ${XDEBUG_DEPS} gettext && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-webp=/usr/include && \
docker-php-ext-configure ldap && \
docker-php-ext-configure ftp && \
docker-php-ext-install bcmath gd intl mbstring pcntl pdo pdo_mysql soap zip ldap ftp && \
pecl install xdebug-${XDEBUG_VERSION} && \
pecl install redis-${PHPREDIS_VERSION} && \
pecl install igbinary memcached-${MEMCACHE_VERSION} --disable-memcached-sasl && \
apk del ${PHPIZE_DEPS} ${XDEBUG_DEPS} && \
rm -rf /var/cache/apk/*

# Install APCu.
ENV APCU_VERSION 5.1.24
RUN apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS && \
pecl install apcu-${APCU_VERSION} && \
apk del .phpize-deps-configure

# Install blackfire client.
ENV BLACKFIRE_CLIENT_VERSION 2.8.1
RUN mkdir -p /tmp/blackfire && \
curl -A "Docker" -L https://packages.blackfire.io/binaries/blackfire/${BLACKFIRE_CLIENT_VERSION}/blackfire-linux_${TARGETARCH}.tar.gz | tar zxp -C /tmp/blackfire && \
mv /tmp/blackfire/blackfire /usr/bin/blackfire && \
rm -Rf /tmp/blackfire

# Install blackfire probe.
RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& architecture=$(uname -m) \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/alpine/$architecture/$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_HOST}:${BLACKFIRE_PORT}\nblackfire.apm_enabled=\${BLACKFIRE_APM_ENABLED}\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz

# Copy mailhog from golang image.
COPY --from=mailhog /go/mailhog /usr/local/bin/mailhog
RUN chmod +x /usr/local/bin/mailhog

# Configure entrypoint.
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

# Configure PHP.
COPY conf/*.ini /usr/local/etc/php/conf.d/
COPY conf.disabled /usr/local/etc/php/conf.disabled
COPY fpm-conf-templates/ /templates/

# Make folders writable for the root group
RUN chmod 775 /usr/local/etc/php && \
chmod 775 /usr/local/etc/php/conf.d && \
chmod 775 /usr/local/etc/php-fpm.d && \
chmod 775 /templates

# Go to target user
USER $user

ENTRYPOINT [ "/docker-entrypoint.sh" ]
CMD ["php-fpm"]

FROM dist as dev

# Build target arch passed by BuildKit
ARG TARGETARCH

# Pass inexistent UUID (e.g.: 1001) to enhance the container security
ARG user=root

ARG COMPOSER_VERSION

USER root

ENV COMPOSER_MEMORY_LIMIT -1
ENV COMPOSER_HOME /composer-libs

RUN apk add --no-cache patch rsync git

RUN mkdir $COMPOSER_HOME \
&& chmod -R 775 $COMPOSER_HOME \
&& curl -L -o /usr/local/bin/composer https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
&& chmod +x /usr/local/bin/composer \
&& echo "PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '" >> /etc/profile \
&& echo "export TERM=xterm" >> /etc/profile

# Go to target user
USER $user
1 change: 1 addition & 0 deletions 8.4/conf.disabled/apcu.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=apcu.so
1 change: 1 addition & 0 deletions 8.4/conf.disabled/mailhog.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sendmail_path="/usr/local/bin/mailhog sendmail --smtp-addr='${MAILHOG_HOST}:${MAILHOG_PORT}' docker@spark.loc"
2 changes: 2 additions & 0 deletions 8.4/conf.disabled/memcached.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extension=igbinary.so
extension=memcached.so
1 change: 1 addition & 0 deletions 8.4/conf.disabled/redis.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=redis.so
4 changes: 4 additions & 0 deletions 8.4/conf.disabled/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
zend_extension=xdebug.so
xdebug.start_with_request=yes
xdebug.client_host=${XDEBUG_REMOTE_HOST}
xdebug.mode=develop
9 changes: 9 additions & 0 deletions 8.4/conf/docker.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
realpath_cache_size=${PHP_REALPATH_CACHE_SIZE}
memory_limit=${PHP_MEMORY_LIMIT}
date.timezone=${PHP_TIMEZONE}
upload_max_filesize=${PHP_UPLOAD_MAX_FILE_SIZE}
post_max_size=${PHP_POST_MAX_SIZE}
max_execution_time=${PHP_MAX_EXECUTION_TIME}
max_input_vars=${PHP_MAX_INPUT_VARS}
display_errors=${PHP_DISPLAY_ERRORS}
display_startup_errors=${PHP_DISPLAY_STARTUP_ERRORS}
1 change: 1 addition & 0 deletions 8.4/conf/expose.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
expose_php="${PHP_EXPOSE_PHP}"
9 changes: 9 additions & 0 deletions 8.4/conf/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
zend_extension=opcache.so
opcache.enable=${PHP_OPCACHE_ENABLE}
opcache.enable_cli=0
opcache.memory_consumption=${PHP_OPCACHE_MEMORY}
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=100000
opcache.use_cwd=1
opcache.fast_shutdown=1
opcache.revalidate_freq=0
67 changes: 67 additions & 0 deletions 8.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/sh
export PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-"128M"}"
export PHP_TIMEZONE="${PHP_TIMEZONE:-"Europe/Rome"}"
export PHP_OPCACHE_ENABLE="${PHP_OPCACHE_ENABLE:-1}"
export PHP_OPCACHE_MEMORY="${PHP_OPCACHE_MEMORY:-64}"
export PHP_MAX_INPUT_VARS="${PHP_MAX_INPUT_VARS:-3000}"
export PHP_DISPLAY_ERRORS="${PHP_DISPLAY_ERRORS:-0}"
export PHP_DISPLAY_STARTUP_ERRORS="${PHP_DISPLAY_STARTUP_ERRORS:-0}"

# Services.
export MAILHOG_ENABLE="${MAILHOG_ENABLE:-0}"
export MEMCACHED_ENABLE="${MEMCACHED_ENABLE:-0}"
export REDIS_ENABLE="${REDIS_ENABLE:-0}"
export XDEBUG_ENABLE="${XDEBUG_ENABLE:-0}"
export LDAP_ENABLE="${LDAP_ENABLE:-0}"

# Services configurations.
export MAILHOG_HOST="${MAILHOG_HOST:-"mail"}"
export MAILHOG_PORT="${MAILHOG_PORT:-1025}"
export APCU_ENABLE="${APCU_ENABLE:-1}"

# Blackfire configurations.
export BLACKFIRE_APM_ENABLED="${BLACKFIRE_APM_ENABLED:-0}"

if [ "${MEMCACHED_ENABLE}" = "1" ]; then
cp /usr/local/etc/php/conf.disabled/memcached.ini /usr/local/etc/php/conf.d/memcached.ini
else
rm -f /usr/local/etc/php/conf.d/memcached.ini || true
fi

if [ "${REDIS_ENABLE}" = "1" ]; then
cp /usr/local/etc/php/conf.disabled/redis.ini /usr/local/etc/php/conf.d/redis.ini
else
rm -f /usr/local/etc/php/conf.d/redis.ini || true
fi

if [ "${MAILHOG_ENABLE}" = "1" ]; then
cp /usr/local/etc/php/conf.disabled/mailhog.ini /usr/local/etc/php/conf.d/mailhog.ini
else
rm -f /usr/local/etc/php/conf.d/mailhog.ini || true
fi

if [ "${XDEBUG_ENABLE}" = "1" ]; then
cp /usr/local/etc/php/conf.disabled/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
else
rm -f /usr/local/etc/php/conf.d/xdebug.ini || true
fi

if [ "${LDAP_ENABLE}" = "0" ]; then
rm -f /usr/local/etc/php/conf.d/docker-php-ext-ldap.ini || true
fi

if [ "${APCU_ENABLE}" = "1" ]; then
cp /usr/local/etc/php/conf.disabled/apcu.ini /usr/local/etc/php/conf.d/apcu.ini
else
rm -f /usr/local/etc/php/conf.d/apcu.ini || true
fi

# php-fpm template env subst.
envsubst </templates/zz2-docker-custom.conf >/usr/local/etc/php-fpm.d/zz2-docker-custom.conf

# If the environment is not local, we enable structured logging.
if [ "${ENV:-}" != "loc" ]; then
envsubst </templates/zz3-structured-logs.conf >/usr/local/etc/php-fpm.d/zz3-structured-logs.conf
fi

exec "$@"
8 changes: 8 additions & 0 deletions 8.4/fpm-conf-templates/zz2-docker-custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[www]
pm = ${PHP_FPM_PM_TYPE}
pm.max_children = ${PHP_FPM_MAX_CHILDREN}
pm.start_servers = ${PHP_FPM_START_SERVERS}
pm.min_spare_servers = ${PHP_FPM_MIN_SPARE_SERVERS}
pm.max_spare_servers = ${PHP_FPM_MAX_SPARE_SERVERS}
pm.status_path = ${PHP_FPM_PM_STATUS_PATH}
access.format = '%{REMOTE_ADDR}e - %{WEBSERVER_REQUEST_ID}e - %t - %s "%m %r%Q%q" %{REQUEST_URI}e'
2 changes: 2 additions & 0 deletions 8.4/fpm-conf-templates/zz3-structured-logs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[www]
access.format = '{"requestId": "%{WEBSERVER_REQUEST_ID}e", "status": %s, "time": "%t", "requestMethod": "%m", "requestUrl": "%r%Q%q", "requestUri": "%{REQUEST_URI}e", "remoteAddr": "%{REMOTE_ADDR}e", "http_x_forwarded_for": "%{X_FORWARDED_FOR}e", "proxy_add_x_forwarded_for": "%{ADD_X_FORWARDED_FOR}e"}';
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ build-8-3-2: build-template
build-8-3-2-rootless: PHPVER=8.3.2-fpm-alpine3.18
build-8-3-2-rootless: build-rootless-template

build-8-3-15: PHPVER=8.3.15-fpm-alpine3.21
build-8-3-15: build-template

build-8-3-15-rootless: PHPVER=8.3.15-fpm-alpine3.21
build-8-3-15-rootless: build-rootless-template

build-8-4-2: PHPVER=8.4.2-fpm-alpine3.21
build-8-4-2: build-template

build-8-4-2-rootless: PHPVER=8.4.2-fpm-alpine3.21
build-8-4-2-rootless: build-rootless-template

build-template: guessing-folder build-test-image
docker buildx build \
--load \
Expand Down
2 changes: 1 addition & 1 deletion scripts/guess_folder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
set -u

# This script returns the base folder for the desired PHP version.
# It tryes to find the corresponding folder in the filesystem, using this precedence:
# It tries to find the corresponding folder in the filesystem, using this precedence:
# 1. full version name (e.g.: 7.4.29-fpm-alpine3.15)
# 2. full semver version (e.g.: 7.4.9)
# 3. major.minor (e.g.: 7.4)
Expand Down
Loading