Skip to content

Commit

Permalink
build: Improve ddev-php-base and ddev-webserver image build (ddev#6672)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay authored Nov 5, 2024
1 parent 92cd790 commit a1ea2fc
Show file tree
Hide file tree
Showing 195 changed files with 155 additions and 8,462 deletions.
56 changes: 18 additions & 38 deletions containers/ddev-php-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### ---------------------------base--------------------------------------
### Build the base Debian image that will be used in every other image
FROM debian:bookworm-slim AS base
ARG TARGETPLATFORM
ARG BUILDPLATFORM

RUN ls -l $(which dpkg-split) && ls -l $(which dpkg-deb)
RUN for item in dpkg-split dpkg-deb; do \
Expand All @@ -27,6 +29,8 @@ RUN apt-get -qq install --no-install-recommends --no-install-suggests -y \
lsb-release \
procps \
wget
RUN url="https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${TARGETPLATFORM#linux/}"; wget ${url} -q -O /usr/bin/yq && chmod +x /usr/bin/yq
ADD generic-files /
#END base

### ---------------------------ddev-xdebug-build--------------------------------------
Expand Down Expand Up @@ -102,44 +106,21 @@ RUN npm install --unsafe-perm=true --global gulp-cli yarn
# Normal user needs to be able to write to php sessions
RUN set -eu -o pipefail && LATEST=$(curl -L --fail --silent "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | jq -r .tag_name) && curl --fail -sL https://raw.githubusercontent.com/nvm-sh/nvm/${LATEST}/install.sh -o /usr/local/bin/install_nvm.sh && chmod +x /usr/local/bin/install_nvm.sh

# The number of permutations of php packages available on each architecture because
# too much to handle, so has been codified here instead of in obscure logic
ARG php56_amd64="apcu bcmath bz2 curl cli common fpm gd imagick intl json ldap mbstring mcrypt memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip"
ARG php56_arm64="apcu bcmath bz2 curl cli common fpm gd imagick intl json ldap mbstring mcrypt mysql opcache pgsql readline soap sqlite3 uploadprogress xdebug xml xhprof xmlrpc zip"
ARG php70_amd64="apcu apcu-bc bcmath bz2 curl cli common fpm gd imagick intl json ldap mbstring mcrypt memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip"
ARG php70_arm64=$php70_amd64
ARG php71_amd64=$php70_amd64
ARG php71_arm64=$php70_arm64
ARG php72_amd64="apcu apcu-bc bcmath bz2 curl cli common fpm gd imagick intl json ldap mbstring memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip"
ARG php72_arm64=$php72_amd64
ARG php73_amd64=$php72_amd64
ARG php73_arm64=$php72_arm64
ARG php74_amd64="apcu apcu-bc bcmath bz2 curl cli common fpm gd imagick intl json ldap mbstring memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip"
ARG php74_arm64=$php74_amd64

# As of php8.0 json is now part of core package and xmlrpc has been removed from PECL
ARG php80_amd64="apcu bcmath bz2 curl cli common fpm gd imagick intl ldap mbstring memcached mysql opcache pgsql readline redis soap sqlite3 uploadprogress xdebug xhprof xml xmlrpc zip"
ARG php80_arm64=$php80_amd64

ARG php81_amd64=$php80_amd64
ARG php81_arm64=$php81_amd64
ARG php82_amd64=$php81_amd64
ARG php82_arm64=$php82_amd64
ARG php83_amd64=$php82_amd64
ARG php83_arm64=$php83_amd64
# TODO: Update 8.4 packages available as they mature, hopefully end up with same as previous
ARG php84_amd64="bcmath bz2 cli common curl fpm gd intl ldap mbstring mysql opcache pgsql readline soap sqlite3 xml zip"
ARG php84_arm64=$php84_amd64

RUN echo php84_arm64=${php84_arm64}
RUN for v in $PHP_VERSIONS; do \
echo "INSTALLING $v"; \
targetarch=${TARGETPLATFORM#linux/}; \
pkgvar=${v//.}_${targetarch}; \
pkgs=$(echo ${!pkgvar} | awk -v v="$v" ' BEGIN {RS=" "; } { printf "%s-%s ",v,$0 ; }' ); \
echo pkgs=$pkgs; \
[[ ${pkgs// } != "" ]] && (apt-get -qq install --no-install-recommends --no-install-suggests -y $pkgs || exit $?) \
# Loop through $PHP_VERSIONS, selecting packages for the target architecture.
RUN for v in ${PHP_VERSIONS}; do \
/usr/local/bin/install_php_extensions.sh "$v" "${TARGETPLATFORM#linux/}"; \
done
RUN update-alternatives --set php /usr/bin/php${PHP_DEFAULT_VERSION}
RUN mkdir -p /etc/nginx/sites-enabled /var/lock/apache2 /var/log/apache2 /var/run/apache2 /var/lib/apache2/module/enabled_by_admin /var/lib/apache2/module/disabled_by_admin && \
touch /var/log/php-fpm.log && \
chmod ugo+rw /var/log/php-fpm.log && \
chmod ugo+rwx /var/run && \
touch /var/log/nginx/access.log && \
touch /var/log/nginx/error.log && \
chmod -R ugo+rw /var/log/nginx/ && \
chmod ugo+rx /usr/local/bin/* && \
ln -sf /usr/sbin/php-fpm${PHP_DEFAULT_VERSION} /usr/sbin/php-fpm

### ---------------------------ddev-xdebug-build--------------------------------------
### The dates from /usr/lib/php/YYYYMMDD/ represent PHP API versions https://unix.stackexchange.com/a/591771
RUN apt-get -qq remove -y php8.0-xdebug php8.1-xdebug php8.2-xdebug
Expand All @@ -152,7 +133,6 @@ RUN apt-get -qq autoremove -y
RUN curl -L --fail -o /usr/local/bin/composer -sSL https://getcomposer.org/composer-stable.phar && chmod ugo+wx /usr/local/bin/composer
RUN curl -L --fail -sSL "https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar" -o /usr/local/bin/drush8 && chmod +x /usr/local/bin/drush8
RUN curl --fail -sSL -o /usr/local/bin/wp-cli -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x /usr/local/bin/wp-cli && ln -sf /usr/local/bin/wp-cli /usr/local/bin/wp
RUN url="https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${TARGETPLATFORM#linux/}"; wget ${url} -q -O /usr/bin/yq && chmod +x /usr/bin/yq
ADD ddev-php-files /
RUN apt-get -qq autoremove && apt-get -qq clean -y && rm -rf /var/lib/apt/lists/* /tmp/*
RUN ln -sf /usr/sbin/php-fpm${DDEV_PHP_VERSION} /usr/sbin/php-fpm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_autostart=1
xdebug.remote_port=9003
xdebug.max_nesting_level=512
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_autostart=1
xdebug.remote_port=9003
xdebug.max_nesting_level=512
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ xdebug.remote_enable=1
xdebug.remote_host=host.docker.internal
xdebug.remote_autostart=1
xdebug.remote_port=9003
xdebug.max_nesting_level=512
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
;user = nginx
;group = nginx

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand All @@ -33,7 +33,7 @@ group = www-data
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9003
listen = /run/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ xdebug.discover_client_host=1
xdebug.client_port=9003
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.max_nesting_level=1000
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
cgi.fix_pathinfo=1
cgi.fix_pathinfo=0
; File Uploads ;
file_uploads = On
upload_max_filesize = 100M
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
; --allow-to-run-as-root option to work.
; Default Values: The user is set to master process running user by default.
; If the group is not set, the user's group is used.
user = www-data
group = www-data
;user = www-data
;group = www-data

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a1ea2fc

Please sign in to comment.