From ea3ee1fdbf07e4d473d3ba8e8dcd6e0bfea8bfe7 Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Fri, 6 Dec 2024 12:23:59 +1300 Subject: [PATCH] Adding in PHP 8.4 images --- .github/workflows/release.yml | 2 +- README.md | 2 +- compose/build.yml | 12 +++ compose/php.yml | 51 +++++++++++++ php/php84-cron/Dockerfile | 9 +++ php/php84-cron/entrypoint.sh | 11 +++ php/php84-debug/Dockerfile | 16 ++++ php/php84/Dockerfile | 133 ++++++++++++++++++++++++++++++++++ php/php84/config/fpm.conf | 2 + php/php84/config/php.ini | 10 +++ 10 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 php/php84-cron/Dockerfile create mode 100644 php/php84-cron/entrypoint.sh create mode 100644 php/php84-debug/Dockerfile create mode 100644 php/php84/Dockerfile create mode 100644 php/php84/config/fpm.conf create mode 100644 php/php84/config/php.ini diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e465358a..4be9e222 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,7 +41,7 @@ jobs: strategy: fail-fast: false matrix: - version: [73, 74, 80, 81, 82, 83] + version: [73, 74, 80, 81, 82, 83, 84] with: version: ${{ matrix.version }} secrets: inherit diff --git a/README.md b/README.md index f3e13295..273b6a01 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Although this project started as a development environment for Totara Learn it c ### What You Get * [NGINX](https://nginx.org/) as a webserver * [Apache](https://httpd.apache.org/) as a webserver - * [PHP](http://php.net/) 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 to test for different versions + * [PHP](http://php.net/) 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 to test for different versions * [PostgreSQL](https://www.postgresql.org/) (9.3, 9.6, 10, 11, 12, 13, 14, 15, 16), * [MariaDB](https://mariadb.org/) (10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.11, 11.4), * [MySQL](https://www.mysql.com/) (5.7, 8.0, 8.4), diff --git a/compose/build.yml b/compose/build.yml index 6e544ddc..9e0861e8 100644 --- a/compose/build.yml +++ b/compose/build.yml @@ -165,3 +165,15 @@ services: php-8.3-debug: build: ./php/php83-debug + php-8.4: + build: + context: ./php/php84 + args: + TIME_ZONE: ${TIME_ZONE} + + php-8.4-cron: + build: ./php/php84-cron + + php-8.4-debug: + build: ./php/php84-debug + diff --git a/compose/php.yml b/compose/php.yml index 876102b6..585e4929 100644 --- a/compose/php.yml +++ b/compose/php.yml @@ -659,6 +659,57 @@ services: networks: - totara + + php-8.4: + image: totara/docker-dev-php84 + container_name: totara_php83 + working_dir: ${REMOTE_SRC} + environment: + CONTAINERNAME: php-8.4 + HIST_FILE: /root/.bash_history + DISABLE_AUTO_UPDATE: "true" # disables oh-my-zsh update message + volumes: + - ${LOCAL_SRC}:${REMOTE_SRC} + - totara-data:${REMOTE_DATA} + - bash-history:/root/.bash_history + - zsh-history:/root/.zsh_history + - ./shell:/root/custom_shell + depends_on: + - php-8.4-debug + networks: + - totara + + php-8.4-cron: + image: totara/docker-dev-php84-cron + container_name: totara_php84_cron + volumes: + - ${LOCAL_SRC}:${REMOTE_SRC} + - totara-data:${REMOTE_DATA} + - ./cron.d:/etc/cron.d + networks: + - totara + + php-8.4-debug: + image: totara/docker-dev-php84-debug + container_name: totara_php84_debug + working_dir: ${REMOTE_SRC} + environment: + CONTAINERNAME: php-8.4-debug + TZ: ${TIME_ZONE} + XDEBUG_CONFIG: client_host=${HOST_IP} + XDEBUG_SESSION: totara84 + PHP_IDE_CONFIG: serverName=totara84 + HIST_FILE: /root/.bash_history + DISABLE_AUTO_UPDATE: "true" # disables oh-my-zsh update message + volumes: + - ${LOCAL_SRC}:${REMOTE_SRC} + - totara-data:${REMOTE_DATA} + - bash-history:/root/.bash_history + - zsh-history:/root/.zsh_history + - ./shell:/root/custom_shell + networks: + - totara + volumes: totara-data: bash-history: diff --git a/php/php84-cron/Dockerfile b/php/php84-cron/Dockerfile new file mode 100644 index 00000000..593a7ac8 --- /dev/null +++ b/php/php84-cron/Dockerfile @@ -0,0 +1,9 @@ +FROM totara/docker-dev-php84:latest + +RUN apt-get update && apt-get install -y cron + +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +CMD ["/entrypoint.sh"] diff --git a/php/php84-cron/entrypoint.sh b/php/php84-cron/entrypoint.sh new file mode 100644 index 00000000..8eac7f87 --- /dev/null +++ b/php/php84-cron/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +if [ -e /etc/cron.d/*.cron ] +then + # Install new crontab using all .cron files + cat /etc/cron.d/*.cron | crontab - \ + && crontab -l \ + && cron -f +else + echo "No .cron files found in cron.d folder" +fi \ No newline at end of file diff --git a/php/php84-debug/Dockerfile b/php/php84-debug/Dockerfile new file mode 100644 index 00000000..71d2f6bd --- /dev/null +++ b/php/php84-debug/Dockerfile @@ -0,0 +1,16 @@ +FROM totara/docker-dev-php84:latest + +RUN pecl channel-update pecl.php.net && \ + pecl install -f xdebug-3.4.0 && docker-php-ext-enable xdebug.so && \ + pecl install -f pcov && docker-php-ext-enable pcov.so + +RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \ + && echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/xdebug.ini + +# Set some sensible defaults +RUN echo "pcov.enabled=1" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \ + && echo "pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \ + # The next line can be enabled (and applied with tbuild and tup of this container) to optimise memory usage \ + # Note that PHP's memory limit needs to be high enough. + #&& echo "pcov.initial.memory=1073741824" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini \ + && echo "pcov.initial.files=30000" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini diff --git a/php/php84/Dockerfile b/php/php84/Dockerfile new file mode 100644 index 00000000..2e6dfd05 --- /dev/null +++ b/php/php84/Dockerfile @@ -0,0 +1,133 @@ +FROM php:8.4-fpm-bullseye + +ARG TIME_ZONE=Pacific/Auckland + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + apt-transport-https \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libwebp-dev \ + libmcrypt-dev \ + libpng-dev \ + libxml2-dev \ + libicu-dev \ + libpq-dev \ + gnupg2 \ + nano \ + vim \ + wget \ + openssl \ + locales \ + tzdata \ + git \ + libzip-dev \ + libmemcached-dev \ + zip \ + netcat \ + bc \ + ghostscript \ + graphviz \ + aspell \ + libldap2-dev \ + libltdl-dev \ + libc-client-dev \ + libkrb5-dev \ + libssl-dev \ + && docker-php-ext-install -j$(nproc) \ + zip \ + intl \ + soap \ + opcache \ + pdo_pgsql \ + pdo_mysql \ + pgsql \ + mysqli \ + exif \ + ldap \ + && docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg \ + --with-webp \ + && docker-php-ext-install -j$(nproc) gd + +RUN git clone https://github.com/longxinH/xhprof.git ./xhprof \ + && cd xhprof \ + && git checkout v2.3.10 \ + && cd extension/ \ + && phpize \ + && ./configure \ + && make && make install + +RUN echo "extension=xhprof.so" >> /usr/local/etc/php/conf.d/xhprof.ini \ + && echo "xhprof.output_dir = /tmp/xhprof" >> /usr/local/etc/php/conf.d/xhprof.ini + +RUN pecl channel-update pecl.php.net && \ + pecl install -o -f redis \ + && rm -rf /tmp/pear \ + && docker-php-ext-enable redis + +RUN pecl channel-update pecl.php.net && \ + pecl install -o -f igbinary \ + && rm -rf /tmp/pear \ + && docker-php-ext-enable igbinary + +RUN pecl channel-update pecl.php.net && \ + pecl install -o -f memcached \ + && rm -rf /tmp/pear \ + && docker-php-ext-enable memcached + +RUN pecl channel-update pecl.php.net && \ + pecl install -o -f imap \ + && rm -rf /tmp/pear \ + && docker-php-ext-enable imap + +# we need en_US locales for MSSQL connection to work +# we need en_AU locales for behat to work +RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ + sed -i -e 's/# en_AU.UTF-8 UTF-8/en_AU.UTF-8 UTF-8/' /etc/locale.gen && \ + dpkg-reconfigure --frontend=noninteractive locales && \ + update-locale LANG=en_US.UTF-8 + +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +# install mssql extension +RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ + && curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list \ + && apt-get update && ACCEPT_EULA=Y apt-get install -y \ + msodbcsql18 \ + mssql-tools18 \ + unixodbc-dev + +RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \ + && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc + +# Workaround applied: https://github.com/microsoft/msphpsql/issues/1438#issuecomment-1444773949 +RUN pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system \ + && pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 || \ + apt-get install -y --allow-downgrades odbcinst=2.3.7 odbcinst1debian2=2.3.7 unixodbc=2.3.7 unixodbc-dev=2.3.7 && \ + pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 + +RUN docker-php-ext-enable sqlsrv.so && docker-php-ext-enable pdo_sqlsrv.so + +RUN ln -fs /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime \ + && dpkg-reconfigure --frontend noninteractive tzdata + +COPY config/php.ini /usr/local/etc/php/ +COPY config/fpm.conf /usr/local/etc/php-fpm.d/zz-totara.conf + +# Source each .sh file found in the /shell/ folder, always source the default_aliases.sh file first +RUN echo 'if [[ -e "/root/custom_shell/default-aliases.sh" ]]; then source "/root/custom_shell/default-aliases.sh"; fi' >> ~/.bashrc && \ + echo 'for f in /root/custom_shell/*.sh; do [[ "$f" != "/root/custom_shell/default-aliases.sh" && -e "$f" ]] && source "$f"; done;' >> ~/.bashrc + +# Have the option of using the oh my zsh shell. +RUN apt-get update && apt-get install -y zsh +RUN sh -c "$(curl https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" --unattended +RUN git clone https://github.com/romkatv/powerlevel10k ~/.oh-my-zsh/custom/themes/powerlevel10k +RUN git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions +RUN git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions +RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting +RUN echo 'setopt +o nomatch' > ~/.zshrc +RUN echo 'source ~/custom_shell/.zshrc' >> ~/.zshrc +RUN cat ~/.bashrc >> ~/.zshrc diff --git a/php/php84/config/fpm.conf b/php/php84/config/fpm.conf new file mode 100644 index 00000000..0376a90e --- /dev/null +++ b/php/php84/config/fpm.conf @@ -0,0 +1,2 @@ +[www] +pm.max_children = 50 \ No newline at end of file diff --git a/php/php84/config/php.ini b/php/php84/config/php.ini new file mode 100644 index 00000000..e6d8b53f --- /dev/null +++ b/php/php84/config/php.ini @@ -0,0 +1,10 @@ +log_errors = On +error_log = /dev/stderr +error_reporting = E_ALL & ~E_DEPRECATED +max_input_vars=5000 +date.timezone = Pacific/Auckland +memory_limit=256M +; necessary as Xdebug impacts performance that hard +max_execution_time=120 +post_max_size = 64M +upload_max_filesize = 64M