diff --git a/.travis.yml b/.travis.yml index 56911826..d3c20d32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # if: tag IS blank @@ -40,173 +41,173 @@ jobs: - stage: "Build base PHP images" name: "php 5.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.2-fpm$PR_TAG 5.2/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.2-fpm$PR_TAG images/5.2/php - docker images - docker push $PACKAGE_REGISTRY/php:5.2-fpm$PR_TAG - name: "php 5.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.3-fpm$PR_TAG 5.3/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.3-fpm$PR_TAG images/5.3/php - docker images - docker push $PACKAGE_REGISTRY/php:5.3-fpm$PR_TAG - name: "php 5.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.4-fpm$PR_TAG 5.4/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.4-fpm$PR_TAG images/5.4/php - docker images - docker push $PACKAGE_REGISTRY/php:5.4-fpm$PR_TAG - name: "php 5.5" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.5-fpm$PR_TAG 5.5/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.5-fpm$PR_TAG images/5.5/php - docker images - docker push $PACKAGE_REGISTRY/php:5.5-fpm$PR_TAG - name: "php 5.6" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.6-fpm$PR_TAG 5.6/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:5.6-fpm$PR_TAG images/5.6/php - docker images - docker push $PACKAGE_REGISTRY/php:5.6-fpm$PR_TAG - name: "php 7.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.0-fpm$PR_TAG 7.0/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.0-fpm$PR_TAG images/7.0/php - docker images - docker push $PACKAGE_REGISTRY/php:7.0-fpm$PR_TAG - name: "php 7.1" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.1-fpm$PR_TAG 7.1/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.1-fpm$PR_TAG images/7.1/php - docker images - docker push $PACKAGE_REGISTRY/php:7.1-fpm$PR_TAG - name: "php 7.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.2-fpm$PR_TAG 7.2/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.2-fpm$PR_TAG images/7.2/php - docker images - docker push $PACKAGE_REGISTRY/php:7.2-fpm$PR_TAG - name: "php 7.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/php:latest$PR_TAG 7.3/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/php:latest$PR_TAG images/7.3/php - docker images - docker push $PACKAGE_REGISTRY/php:7.3-fpm$PR_TAG - docker push $PACKAGE_REGISTRY/php:latest$PR_TAG - name: "php 7.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.4-fpm$PR_TAG 7.4/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:7.4-fpm$PR_TAG images/7.4/php - docker images - docker push $PACKAGE_REGISTRY/php:7.4-fpm$PR_TAG - name: "php 8.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:8.0-fpm$PR_TAG 8.0/php + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php:8.0-fpm$PR_TAG images/8.0/php - docker images - docker push $PACKAGE_REGISTRY/php:8.0-fpm$PR_TAG - stage: "Build child images" name: "phpunit 5.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.2-fpm$PR_TAG 5.2/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.2-fpm$PR_TAG images/5.2/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:5.2-fpm$PR_TAG - name: "phpunit 5.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.3-fpm$PR_TAG 5.3/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.3-fpm$PR_TAG images/5.3/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:5.3-fpm$PR_TAG - name: "phpunit 5.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.4-fpm$PR_TAG 5.4/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.4-fpm$PR_TAG images/5.4/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:5.4-fpm$PR_TAG - name: "phpunit 5.5" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.5-fpm$PR_TAG 5.5/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.5-fpm$PR_TAG images/5.5/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:5.5-fpm$PR_TAG - name: "phpunit 5.6" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.6-fpm$PR_TAG 5.6/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:5.6-fpm$PR_TAG images/5.6/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:5.6-fpm$PR_TAG - name: "phpunit 7.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.0-fpm$PR_TAG 7.0/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.0-fpm$PR_TAG images/7.0/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:7.0-fpm$PR_TAG - name: "phpunit 7.1" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.1-fpm$PR_TAG 7.1/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.1-fpm$PR_TAG images/7.1/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:7.1-fpm$PR_TAG - name: "phpunit 7.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.2-fpm$PR_TAG 7.2/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.2-fpm$PR_TAG images/7.2/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:7.2-fpm$PR_TAG - name: "phpunit 7.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/phpunit:latest$PR_TAG 7.3/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/phpunit:latest$PR_TAG images/7.3/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:7.3-fpm$PR_TAG - docker push $PACKAGE_REGISTRY/phpunit:latest$PR_TAG - name: "phpunit 7.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.4-fpm$PR_TAG 7.4/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:7.4-fpm$PR_TAG images/7.4/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:7.4-fpm$PR_TAG - name: "phpunit 8.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:8.0-fpm$PR_TAG 8.0/phpunit + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:8.0-fpm$PR_TAG images/8.0/phpunit - docker images - docker push $PACKAGE_REGISTRY/phpunit:8.0-fpm$PR_TAG - name: "cli 5.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.2-fpm$PR_TAG 5.2/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.2-fpm$PR_TAG images/5.2/cli - docker images - docker push $PACKAGE_REGISTRY/cli:5.2-fpm$PR_TAG - name: "cli 5.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.3-fpm$PR_TAG 5.3/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.3-fpm$PR_TAG images/5.3/cli - docker images - docker push $PACKAGE_REGISTRY/cli:5.3-fpm$PR_TAG - name: "cli 5.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.4-fpm$PR_TAG 5.4/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.4-fpm$PR_TAG images/5.4/cli - docker images - docker push $PACKAGE_REGISTRY/cli:5.4-fpm$PR_TAG - name: "cli 5.5" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.5-fpm$PR_TAG 5.5/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.5-fpm$PR_TAG images/5.5/cli - docker images - docker push $PACKAGE_REGISTRY/cli:5.5-fpm$PR_TAG - name: "cli 5.6" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.6-fpm$PR_TAG 5.6/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:5.6-fpm$PR_TAG images/5.6/cli - docker images - docker push $PACKAGE_REGISTRY/cli:5.6-fpm$PR_TAG - name: "cli 7.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.0-fpm$PR_TAG 7.0/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.0-fpm$PR_TAG images/7.0/cli - docker images - docker push $PACKAGE_REGISTRY/cli:7.0-fpm$PR_TAG - name: "cli 7.1" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.1-fpm$PR_TAG 7.1/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.1-fpm$PR_TAG images/7.1/cli - docker images - docker push $PACKAGE_REGISTRY/cli:7.1-fpm$PR_TAG - name: "cli 7.2" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.2-fpm$PR_TAG 7.2/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.2-fpm$PR_TAG images/7.2/cli - docker images - docker push $PACKAGE_REGISTRY/cli:7.2-fpm$PR_TAG - name: "cli 7.3" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/cli:latest$PR_TAG 7.3/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.3-fpm$PR_TAG -t $PACKAGE_REGISTRY/cli:latest$PR_TAG images/7.3/cli - docker images - docker push $PACKAGE_REGISTRY/cli:7.3-fpm$PR_TAG - docker push $PACKAGE_REGISTRY/cli:latest$PR_TAG - name: "cli 7.4" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.4-fpm$PR_TAG 7.4/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:7.4-fpm$PR_TAG images/7.4/cli - docker images - docker push $PACKAGE_REGISTRY/cli:7.4-fpm$PR_TAG - name: "cli 8.0" script: - - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:8.0-fpm$PR_TAG 8.0/cli + - docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/cli:8.0-fpm$PR_TAG images/8.0/cli - docker images - docker push $PACKAGE_REGISTRY/cli:8.0-fpm$PR_TAG diff --git a/5.2/php/Dockerfile b/5.2/php/Dockerfile deleted file mode 100644 index c549052d..00000000 --- a/5.2/php/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM devilbox/php-fpm-5.2:latest - -WORKDIR /var/www - -########################################################################## -# -# WARNING: This file was generated by update.php. Do not edit it directly. -# -# - -ENV COMPOSER_ALLOW_SUPERUSER 1 -ENV COMPOSER_HOME /tmp - - - -COPY entrypoint.sh /entrypoint.sh - -RUN chmod +x /entrypoint.sh - -ENTRYPOINT [ "/entrypoint.sh" ] - -CMD [ "php-fpm" ] diff --git a/5.6/php/entrypoint.sh b/5.6/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/5.6/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/7.0/php/entrypoint.sh b/7.0/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/7.0/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/7.1/php/entrypoint.sh b/7.1/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/7.1/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/7.2/php/entrypoint.sh b/7.2/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/7.2/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/7.3/php/entrypoint.sh b/7.3/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/7.3/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/7.4/php/entrypoint.sh b/7.4/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/7.4/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/8.0/php/entrypoint.sh b/8.0/php/entrypoint.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/8.0/php/entrypoint.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/Dockerfile-php.template b/Dockerfile-php.template deleted file mode 100644 index 7fc8dfa6..00000000 --- a/Dockerfile-php.template +++ /dev/null @@ -1,18 +0,0 @@ -FROM %%BASE_NAME%% - -WORKDIR /var/www - -%%GENERATED_WARNING%% - -ENV COMPOSER_ALLOW_SUPERUSER 1 -ENV COMPOSER_HOME /tmp - -%%INSTALL_EXTENSIONS%% - -COPY entrypoint.sh /entrypoint.sh - -RUN chmod +x /entrypoint.sh - -ENTRYPOINT [ "/entrypoint.sh" ] - -CMD [ "php-fpm" ] diff --git a/config/php-fpm-php.conf b/config/php-fpm-php.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/config/php-fpm-php.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/entrypoint-php.sh b/entrypoint-php.sh deleted file mode 100644 index 51f8e5e0..00000000 --- a/entrypoint-php.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled -if [ "$LOCAL_PHP_XDEBUG" = true ]; then - docker-php-ext-enable xdebug - rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini -else - docker-php-ext-enable opcache - rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -fi - -# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled -if [ "$LOCAL_PHP_MEMCACHED" = true ]; then - docker-php-ext-enable memcached -else - rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini -fi - -# Execute CMD -exec "$@" diff --git a/5.4/php/entrypoint.sh b/entrypoint/common.sh similarity index 66% rename from 5.4/php/entrypoint.sh rename to entrypoint/common.sh index 51f8e5e0..b0df5979 100644 --- a/5.4/php/entrypoint.sh +++ b/entrypoint/common.sh @@ -17,5 +17,14 @@ else rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini fi -# Execute CMD -exec "$@" +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/entrypoint/entrypoint-cli.sh b/entrypoint/entrypoint-cli.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/entrypoint/entrypoint-cli.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/entrypoint/entrypoint-php.sh b/entrypoint/entrypoint-php.sh new file mode 100644 index 00000000..c3c3b23c --- /dev/null +++ b/entrypoint/entrypoint-php.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/entrypoint/entrypoint-phpunit.sh b/entrypoint/entrypoint-phpunit.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/entrypoint/entrypoint-phpunit.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.2/cli/Dockerfile b/images/5.2/cli/Dockerfile similarity index 66% rename from 5.2/cli/Dockerfile rename to images/5.2/cli/Dockerfile index 3a452826..ef088a6b 100644 --- a/5.2/cli/Dockerfile +++ b/images/5.2/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:5.2-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -14,4 +15,4 @@ ENTRYPOINT [ "echo", "WP-CLI is not available for PHP 5.2-fpm.\nCommand was not WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/5.2/cli/entrypoint.sh b/images/5.2/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/5.2/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/images/5.2/php/Dockerfile b/images/5.2/php/Dockerfile new file mode 100644 index 00000000..f7048bbd --- /dev/null +++ b/images/5.2/php/Dockerfile @@ -0,0 +1,33 @@ +FROM devilbox/php-fpm-5.2:latest + +WORKDIR /var/www + +########################################################################## +# +# WARNING: This file was generated by update.php. +# +# You can find the relevant template in the `/templates` folder. +# + +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + +# install the PHP extensions we need +RUN set -ex; \ + \ + apt-get update; \ + \ + apt-get install -y --no-install-recommends sudo; + +COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf + +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php + +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD [ "php-fpm" ] diff --git a/5.5/php/entrypoint.sh b/images/5.2/php/common.sh similarity index 66% rename from 5.5/php/entrypoint.sh rename to images/5.2/php/common.sh index 51f8e5e0..b0df5979 100644 --- a/5.5/php/entrypoint.sh +++ b/images/5.2/php/common.sh @@ -17,5 +17,14 @@ else rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini fi -# Execute CMD -exec "$@" +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/5.2/php/entrypoint.sh b/images/5.2/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/5.2/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/5.2/php/php-fpm.conf b/images/5.2/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/5.2/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/5.2/phpunit/Dockerfile b/images/5.2/phpunit/Dockerfile similarity index 59% rename from 5.2/phpunit/Dockerfile rename to images/5.2/phpunit/Dockerfile index fd126d67..8016508a 100644 --- a/5.2/phpunit/Dockerfile +++ b/images/5.2/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:5.2-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-3.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/5.2/phpunit/entrypoint.sh b/images/5.2/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/5.2/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.3/cli/Dockerfile b/images/5.3/cli/Dockerfile similarity index 68% rename from 5.3/cli/Dockerfile rename to images/5.3/cli/Dockerfile index 996b66d1..4c36441a 100644 --- a/5.3/cli/Dockerfile +++ b/images/5.3/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:5.3-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/5.3/cli/entrypoint.sh b/images/5.3/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/5.3/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.3/php/Dockerfile b/images/5.3/php/Dockerfile similarity index 73% rename from 5.3/php/Dockerfile rename to images/5.3/php/Dockerfile index bdbd441f..d4b17873 100644 --- a/5.3/php/Dockerfile +++ b/images/5.3/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends unzip; \ + apt-get install -y --no-install-recommends unzip sudo; \ \ curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ @@ -34,8 +35,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/5.2/php/entrypoint.sh b/images/5.3/php/common.sh similarity index 66% rename from 5.2/php/entrypoint.sh rename to images/5.3/php/common.sh index 51f8e5e0..b0df5979 100644 --- a/5.2/php/entrypoint.sh +++ b/images/5.3/php/common.sh @@ -17,5 +17,14 @@ else rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini fi -# Execute CMD -exec "$@" +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/5.3/php/entrypoint.sh b/images/5.3/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/5.3/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/5.3/php/php-fpm.conf b/images/5.3/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/5.3/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/5.3/phpunit/Dockerfile b/images/5.3/phpunit/Dockerfile similarity index 59% rename from 5.3/phpunit/Dockerfile rename to images/5.3/phpunit/Dockerfile index 0d3a0d21..01a5c440 100644 --- a/5.3/phpunit/Dockerfile +++ b/images/5.3/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:5.3-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-4.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/5.3/phpunit/entrypoint.sh b/images/5.3/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/5.3/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.4/cli/Dockerfile b/images/5.4/cli/Dockerfile similarity index 68% rename from 5.4/cli/Dockerfile rename to images/5.4/cli/Dockerfile index 5873d3a1..3172791f 100644 --- a/5.4/cli/Dockerfile +++ b/images/5.4/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:5.4-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/5.4/cli/entrypoint.sh b/images/5.4/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/5.4/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.4/php/Dockerfile b/images/5.4/php/Dockerfile similarity index 80% rename from 5.4/php/Dockerfile rename to images/5.4/php/Dockerfile index fb5dae31..3c90925f 100644 --- a/5.4/php/Dockerfile +++ b/images/5.4/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libicu-dev libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libicu-dev libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/5.3/php/entrypoint.sh b/images/5.4/php/common.sh similarity index 66% rename from 5.3/php/entrypoint.sh rename to images/5.4/php/common.sh index 51f8e5e0..b0df5979 100644 --- a/5.3/php/entrypoint.sh +++ b/images/5.4/php/common.sh @@ -17,5 +17,14 @@ else rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini fi -# Execute CMD -exec "$@" +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/5.4/php/entrypoint.sh b/images/5.4/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/5.4/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/5.4/php/php-fpm.conf b/images/5.4/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/5.4/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/5.4/phpunit/Dockerfile b/images/5.4/phpunit/Dockerfile similarity index 59% rename from 5.4/phpunit/Dockerfile rename to images/5.4/phpunit/Dockerfile index 44589e73..d4eb96c2 100644 --- a/5.4/phpunit/Dockerfile +++ b/images/5.4/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:5.4-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-4.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/5.4/phpunit/entrypoint.sh b/images/5.4/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/5.4/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.5/cli/Dockerfile b/images/5.5/cli/Dockerfile similarity index 68% rename from 5.5/cli/Dockerfile rename to images/5.5/cli/Dockerfile index cd957739..727cd20f 100644 --- a/5.5/cli/Dockerfile +++ b/images/5.5/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:5.5-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/5.5/cli/entrypoint.sh b/images/5.5/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/5.5/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.5/php/Dockerfile b/images/5.5/php/Dockerfile similarity index 80% rename from 5.5/php/Dockerfile rename to images/5.5/php/Dockerfile index afb0a4f5..1aa01779 100644 --- a/5.5/php/Dockerfile +++ b/images/5.5/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libicu-dev libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libicu-dev libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/5.5/php/common.sh b/images/5.5/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/5.5/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/5.5/php/entrypoint.sh b/images/5.5/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/5.5/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/5.5/php/php-fpm.conf b/images/5.5/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/5.5/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/5.5/phpunit/Dockerfile b/images/5.5/phpunit/Dockerfile similarity index 59% rename from 5.5/phpunit/Dockerfile rename to images/5.5/phpunit/Dockerfile index 7957624f..78ff1fd4 100644 --- a/5.5/phpunit/Dockerfile +++ b/images/5.5/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:5.5-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-4.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/5.5/phpunit/entrypoint.sh b/images/5.5/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/5.5/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.6/cli/Dockerfile b/images/5.6/cli/Dockerfile similarity index 69% rename from 5.6/cli/Dockerfile rename to images/5.6/cli/Dockerfile index aa20edd8..e7ce762d 100644 --- a/5.6/cli/Dockerfile +++ b/images/5.6/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:5.6-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/5.6/cli/entrypoint.sh b/images/5.6/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/5.6/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/5.6/php/Dockerfile b/images/5.6/php/Dockerfile similarity index 80% rename from 5.6/php/Dockerfile rename to images/5.6/php/Dockerfile index 722c27a9..6af5c318 100644 --- a/5.6/php/Dockerfile +++ b/images/5.6/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/5.6/php/common.sh b/images/5.6/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/5.6/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/5.6/php/entrypoint.sh b/images/5.6/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/5.6/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/5.6/php/php-fpm.conf b/images/5.6/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/5.6/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/5.6/phpunit/Dockerfile b/images/5.6/phpunit/Dockerfile similarity index 59% rename from 5.6/phpunit/Dockerfile rename to images/5.6/phpunit/Dockerfile index 182ef8f6..b1117d08 100644 --- a/5.6/phpunit/Dockerfile +++ b/images/5.6/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:5.6-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-5.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/5.6/phpunit/entrypoint.sh b/images/5.6/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/5.6/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.0/cli/Dockerfile b/images/7.0/cli/Dockerfile similarity index 69% rename from 7.0/cli/Dockerfile rename to images/7.0/cli/Dockerfile index 2db8a094..258ec2fc 100644 --- a/7.0/cli/Dockerfile +++ b/images/7.0/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:7.0-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/7.0/cli/entrypoint.sh b/images/7.0/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/7.0/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.0/php/Dockerfile b/images/7.0/php/Dockerfile similarity index 80% rename from 7.0/php/Dockerfile rename to images/7.0/php/Dockerfile index 7cf55d9f..50f1262b 100644 --- a/7.0/php/Dockerfile +++ b/images/7.0/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/7.0/php/common.sh b/images/7.0/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/7.0/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/7.0/php/entrypoint.sh b/images/7.0/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/7.0/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/7.0/php/php-fpm.conf b/images/7.0/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/7.0/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/7.0/phpunit/Dockerfile b/images/7.0/phpunit/Dockerfile similarity index 59% rename from 7.0/phpunit/Dockerfile rename to images/7.0/phpunit/Dockerfile index 127f90a8..92d8ccb3 100644 --- a/7.0/phpunit/Dockerfile +++ b/images/7.0/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:7.0-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-6.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/7.0/phpunit/entrypoint.sh b/images/7.0/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/7.0/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.1/cli/Dockerfile b/images/7.1/cli/Dockerfile similarity index 69% rename from 7.1/cli/Dockerfile rename to images/7.1/cli/Dockerfile index aa228c5d..ee76afc7 100644 --- a/7.1/cli/Dockerfile +++ b/images/7.1/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:7.1-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/7.1/cli/entrypoint.sh b/images/7.1/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/7.1/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.1/php/Dockerfile b/images/7.1/php/Dockerfile similarity index 80% rename from 7.1/php/Dockerfile rename to images/7.1/php/Dockerfile index 8851c74f..a4ead5ad 100644 --- a/7.1/php/Dockerfile +++ b/images/7.1/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/7.1/php/common.sh b/images/7.1/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/7.1/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/7.1/php/entrypoint.sh b/images/7.1/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/7.1/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/7.1/php/php-fpm.conf b/images/7.1/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/7.1/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/7.1/phpunit/Dockerfile b/images/7.1/phpunit/Dockerfile similarity index 59% rename from 7.1/phpunit/Dockerfile rename to images/7.1/phpunit/Dockerfile index 87f7c1b2..7831b6a2 100644 --- a/7.1/phpunit/Dockerfile +++ b/images/7.1/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:7.1-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-7.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/7.1/phpunit/entrypoint.sh b/images/7.1/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/7.1/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.2/cli/Dockerfile b/images/7.2/cli/Dockerfile similarity index 69% rename from 7.2/cli/Dockerfile rename to images/7.2/cli/Dockerfile index 6e3c4d31..14203c0f 100644 --- a/7.2/cli/Dockerfile +++ b/images/7.2/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:7.2-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/7.2/cli/entrypoint.sh b/images/7.2/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/7.2/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.2/php/Dockerfile b/images/7.2/php/Dockerfile similarity index 80% rename from 7.2/php/Dockerfile rename to images/7.2/php/Dockerfile index 74904ce9..2fed70a3 100644 --- a/7.2/php/Dockerfile +++ b/images/7.2/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/7.2/php/common.sh b/images/7.2/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/7.2/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/7.2/php/entrypoint.sh b/images/7.2/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/7.2/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/7.2/php/php-fpm.conf b/images/7.2/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/7.2/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/7.2/phpunit/Dockerfile b/images/7.2/phpunit/Dockerfile similarity index 59% rename from 7.2/phpunit/Dockerfile rename to images/7.2/phpunit/Dockerfile index f2076170..4acd2d84 100644 --- a/7.2/phpunit/Dockerfile +++ b/images/7.2/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:7.2-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-7.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/7.2/phpunit/entrypoint.sh b/images/7.2/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/7.2/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.3/cli/Dockerfile b/images/7.3/cli/Dockerfile similarity index 69% rename from 7.3/cli/Dockerfile rename to images/7.3/cli/Dockerfile index 1a59ff1f..798c6818 100644 --- a/7.3/cli/Dockerfile +++ b/images/7.3/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:7.3-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/7.3/cli/entrypoint.sh b/images/7.3/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/7.3/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.3/php/Dockerfile b/images/7.3/php/Dockerfile similarity index 80% rename from 7.3/php/Dockerfile rename to images/7.3/php/Dockerfile index f87fd133..bcea1b03 100644 --- a/7.3/php/Dockerfile +++ b/images/7.3/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/7.3/php/common.sh b/images/7.3/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/7.3/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/7.3/php/entrypoint.sh b/images/7.3/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/7.3/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/7.3/php/php-fpm.conf b/images/7.3/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/7.3/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/7.3/phpunit/Dockerfile b/images/7.3/phpunit/Dockerfile similarity index 59% rename from 7.3/phpunit/Dockerfile rename to images/7.3/phpunit/Dockerfile index 2eb1aeba..8eea3b0f 100644 --- a/7.3/phpunit/Dockerfile +++ b/images/7.3/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:7.3-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-7.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/7.3/phpunit/entrypoint.sh b/images/7.3/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/7.3/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.4/cli/Dockerfile b/images/7.4/cli/Dockerfile similarity index 69% rename from 7.4/cli/Dockerfile rename to images/7.4/cli/Dockerfile index 78ebaadd..19304206 100644 --- a/7.4/cli/Dockerfile +++ b/images/7.4/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:7.4-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/7.4/cli/entrypoint.sh b/images/7.4/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/7.4/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/7.4/php/Dockerfile b/images/7.4/php/Dockerfile similarity index 80% rename from 7.4/php/Dockerfile rename to images/7.4/php/Dockerfile index 81a348ea..d8417b4d 100644 --- a/7.4/php/Dockerfile +++ b/images/7.4/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip libmagickwand-dev ghostscript libonig-dev locales sudo; \ sed -i 's/^# *\(\(ru_RU\|fr_FR\|de_DE\|es_ES\|ja_JP\).UTF-8\)/\1/' /etc/locale.gen; \ locale-gen; \ \ @@ -45,8 +46,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/7.4/php/common.sh b/images/7.4/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/7.4/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/7.4/php/entrypoint.sh b/images/7.4/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/7.4/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/7.4/php/php-fpm.conf b/images/7.4/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/7.4/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/7.4/phpunit/Dockerfile b/images/7.4/phpunit/Dockerfile similarity index 59% rename from 7.4/phpunit/Dockerfile rename to images/7.4/phpunit/Dockerfile index c9dc2a26..a988c591 100644 --- a/7.4/phpunit/Dockerfile +++ b/images/7.4/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:7.4-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-7.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/7.4/phpunit/entrypoint.sh b/images/7.4/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/7.4/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/8.0/cli/Dockerfile b/images/8.0/cli/Dockerfile similarity index 69% rename from 8.0/cli/Dockerfile rename to images/8.0/cli/Dockerfile index 0411270d..7e02b699 100644 --- a/8.0/cli/Dockerfile +++ b/images/8.0/cli/Dockerfile @@ -4,8 +4,9 @@ FROM $PACKAGE_REGISTRY/php:8.0-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # @@ -27,9 +28,13 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/images/8.0/cli/entrypoint.sh b/images/8.0/cli/entrypoint.sh new file mode 100644 index 00000000..e4fac52d --- /dev/null +++ b/images/8.0/cli/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source /common.sh + +# first arg is `-f` or `--some-option` +if [ "${1#-}" != "$1" ]; then + set -- wp "$@" +fi + +# if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead +if sudo -u wp_php wp --path=/dev/null help "$1" > /dev/null 2>&1; then + set -- wp "$@" +fi + +# Execute CMD +sudo -u wp_php "$@" diff --git a/8.0/php/Dockerfile b/images/8.0/php/Dockerfile similarity index 74% rename from 8.0/php/Dockerfile rename to images/8.0/php/Dockerfile index 0b09e309..887a89e4 100644 --- a/8.0/php/Dockerfile +++ b/images/8.0/php/Dockerfile @@ -4,8 +4,9 @@ WORKDIR /var/www ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # ENV COMPOSER_ALLOW_SUPERUSER 1 @@ -16,7 +17,7 @@ RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends unzip; \ + apt-get install -y --no-install-recommends unzip sudo; \ \ docker-php-ext-install mysqli; \ \ @@ -36,8 +37,13 @@ RUN set -ex; \ rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf -RUN chmod +x /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/images/8.0/php/common.sh b/images/8.0/php/common.sh new file mode 100644 index 00000000..b0df5979 --- /dev/null +++ b/images/8.0/php/common.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +# If LOCAL_PHP_XDEBUG=true xdebug extension will be enabled +if [ "$LOCAL_PHP_XDEBUG" = true ]; then + docker-php-ext-enable xdebug + rm -f /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +else + docker-php-ext-enable opcache + rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +fi + +# If LOCAL_PHP_MEMCACHED=true memcached extension will be enabled +if [ "$LOCAL_PHP_MEMCACHED" = true ]; then + docker-php-ext-enable memcached +else + rm -f /usr/local/etc/php/conf.d/docker-php-ext-memcached.ini +fi + +### Change UID/GID +WP_PHP_UID="${PHP_FPM_UID-1000}" +WP_PHP_GID="${PHP_FPM_GID-1000}" + +if [ "$WP_PHP_UID" != "`id -u wp_php`" ]; then + usermod -o -u "${WP_PHP_UID}" "wp_php" +fi + +if [ "$WP_PHP_GID" != "`id -g wp_php`" ]; then + groupmod -o -g "${WP_PHP_GID}" "wp_php" +fi diff --git a/images/8.0/php/entrypoint.sh b/images/8.0/php/entrypoint.sh new file mode 100755 index 00000000..c3c3b23c --- /dev/null +++ b/images/8.0/php/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +source /common.sh + +# Execute CMD +exec "$@" diff --git a/images/8.0/php/php-fpm.conf b/images/8.0/php/php-fpm.conf new file mode 100644 index 00000000..fe69bdae --- /dev/null +++ b/images/8.0/php/php-fpm.conf @@ -0,0 +1,3 @@ +[www] +user = wp_php +group = wp_php \ No newline at end of file diff --git a/8.0/phpunit/Dockerfile b/images/8.0/phpunit/Dockerfile similarity index 59% rename from 8.0/phpunit/Dockerfile rename to images/8.0/phpunit/Dockerfile index ecdaf154..7409fe72 100644 --- a/8.0/phpunit/Dockerfile +++ b/images/8.0/phpunit/Dockerfile @@ -4,12 +4,19 @@ FROM $PACKAGE_REGISTRY/php:8.0-fpm$PR_TAG ########################################################################## # -# WARNING: This file was generated by update.php. Do not edit it directly. +# WARNING: This file was generated by update.php. # +# You can find the relevant template in the `/templates` folder. # RUN curl -sL https://phar.phpunit.de/phpunit-7.phar > /usr/local/bin/phpunit && chmod +x /usr/local/bin/phpunit WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/images/8.0/phpunit/entrypoint.sh b/images/8.0/phpunit/entrypoint.sh new file mode 100644 index 00000000..cfe29e05 --- /dev/null +++ b/images/8.0/phpunit/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +source /common.sh + +chown -R wp_php:wp_php /var/www/${LOCAL_DIR-src}/wp-content/uploads + +# Execute CMD +sudo -u wp_php "$@" diff --git a/.travis.yml-template b/templates/.travis.yml-template similarity index 100% rename from .travis.yml-template rename to templates/.travis.yml-template diff --git a/Dockerfile-cli.template b/templates/Dockerfile-cli.template similarity index 82% rename from Dockerfile-cli.template rename to templates/Dockerfile-cli.template index 04ac9b34..8ff5f468 100644 --- a/Dockerfile-cli.template +++ b/templates/Dockerfile-cli.template @@ -23,7 +23,11 @@ RUN set -ex; \ \ wp --allow-root --version; -ENTRYPOINT [ "/usr/local/bin/wp", "--allow-root" ] +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] %%/NEW_PHP%% %%OLD_PHP%% @@ -32,4 +36,4 @@ ENTRYPOINT [ "echo", "WP-CLI is not available for PHP %%VERSION_TAG%%.\nCommand WORKDIR /var/www -CMD [ "shell" ] +CMD [ "wp", "shell" ] diff --git a/templates/Dockerfile-php.template b/templates/Dockerfile-php.template new file mode 100644 index 00000000..0c0e158f --- /dev/null +++ b/templates/Dockerfile-php.template @@ -0,0 +1,23 @@ +FROM %%BASE_NAME%% + +WORKDIR /var/www + +%%GENERATED_WARNING%% + +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + +%%INSTALL_EXTENSIONS%% + +COPY entrypoint.sh /entrypoint.sh +COPY common.sh /common.sh +COPY php-fpm.conf /usr/local/etc/php-fpm.d/zz-wordpress.conf + +RUN chmod +x /entrypoint.sh && \ + chmod +x /common.sh && \ + groupadd -g 1000 -r wp_php && \ + useradd -u 1000 -s /bin/bash -g wp_php wp_php + +ENTRYPOINT [ "/entrypoint.sh" ] + +CMD [ "php-fpm" ] diff --git a/Dockerfile-phpunit.template b/templates/Dockerfile-phpunit.template similarity index 74% rename from Dockerfile-phpunit.template rename to templates/Dockerfile-phpunit.template index ac72b836..1cf4db31 100644 --- a/Dockerfile-phpunit.template +++ b/templates/Dockerfile-phpunit.template @@ -8,4 +8,10 @@ RUN curl -sL https://phar.phpunit.de/phpunit-%%PHPUNIT_VERSION%%.phar > /usr/loc WORKDIR /var/www +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT [ "/entrypoint.sh" ] + CMD /usr/local/bin/phpunit diff --git a/update.php b/update.php index aaf34ce7..50f51944 100644 --- a/update.php +++ b/update.php @@ -26,7 +26,7 @@ '5.2' => array( 'php' => array( 'base_name' => 'devilbox/php-fpm-5.2:latest', - 'apt' => array(), + 'apt' => array( 'sudo' ), 'extensions' => array(), 'pecl_extensions' => array(), 'composer' => false, @@ -37,7 +37,7 @@ '5.3' => array( 'php' => array( 'base_name' => 'devilbox/php-fpm-5.3:latest', - 'apt' => array( 'unzip' ), + 'apt' => array( 'unzip', 'sudo' ), 'extensions' => array(), 'pecl_extensions' => array(), 'composer' => true, @@ -51,7 +51,7 @@ '5.4' => array( 'php' => array( 'base_name' => 'php:5.4-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libicu-dev', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libicu-dev', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.4.1', 'memcached-2.2.0', 'imagick-3.4.4' ), 'composer' => true, @@ -65,7 +65,7 @@ '5.5' => array( 'php' => array( 'base_name' => 'php:5.5-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libicu-dev', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libicu-dev', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.5.5', 'memcached-2.2.0', 'imagick-3.4.4' ), 'composer' => true, @@ -79,7 +79,7 @@ '5.6' => array( 'php' => array( 'base_name' => 'php:5.6-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.5.5', 'memcached-2.2.0', 'imagick-3.4.4' ), 'composer' => true, @@ -93,7 +93,7 @@ '7.0' => array( 'php' => array( 'base_name' => 'php:7.0-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3', 'imagick' ), 'composer' => true, @@ -107,7 +107,7 @@ '7.1' => array( 'php' => array( 'base_name' => 'php:7.1-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3', 'imagick' ), 'composer' => true, @@ -121,7 +121,7 @@ '7.2' => array( 'php' => array( 'base_name' => 'php:7.2-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3', 'imagick' ), 'composer' => true, @@ -135,7 +135,7 @@ '7.3' => array( 'php' => array( 'base_name' => 'php:7.3-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3', 'imagick' ), 'composer' => true, @@ -149,7 +149,7 @@ '7.4' => array( 'php' => array( 'base_name' => 'php:7.4-rc-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip', 'libmagickwand-dev', 'ghostscript', 'libonig-dev', 'locales', 'sudo' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip', 'exif', 'intl', 'mbstring' ), 'pecl_extensions' => array( 'xdebug-2.8.0beta1', 'memcached-3.1.3', 'imagick' ), 'composer' => true, @@ -163,7 +163,7 @@ '8.0' => array( 'php' => array( 'base_name' => 'devilbox/php-fpm-8.0:latest', - 'apt' => array( 'unzip' ), + 'apt' => array( 'unzip', 'sudo' ), 'extensions' => array( 'mysqli' ), 'pecl_extensions' => array(), 'composer' => true, @@ -180,16 +180,17 @@ $generated_warning = << file_get_contents( 'Dockerfile-php.template' ), - 'phpunit' => file_get_contents( 'Dockerfile-phpunit.template' ), - 'cli' => file_get_contents( 'Dockerfile-cli.template' ), + 'php' => file_get_contents( 'templates/Dockerfile-php.template' ), + 'phpunit' => file_get_contents( 'templates/Dockerfile-phpunit.template' ), + 'cli' => file_get_contents( 'templates/Dockerfile-cli.template' ), ); $build_cmds = array( @@ -207,7 +208,7 @@ foreach ( $images as $image => $config ) { echo str_pad( $image, 10, '.' ); - echo shell_exec( "mkdir -p $version/$image" ); + echo shell_exec( "mkdir -p images/$version/$image" ); $dockerfile = $templates[ $image ]; @@ -287,6 +288,8 @@ $dockerfile = str_replace( '%%INSTALL_EXTENSIONS%%', $install_extensions, $dockerfile ); } + copy( "entrypoint/common.sh", "images/$version/$image/common.sh" ); + } elseif ( $image === 'phpunit' ) { // Replace tags inside the PHPUnit Dockerfile template. $dockerfile = str_replace( '%%PHPUNIT_VERSION%%', $config, $dockerfile ); @@ -306,13 +309,18 @@ $dockerfile = preg_replace( '/%%[^%]+%%/', '', $dockerfile ); // Write the real Dockerfile. - $fh = fopen( "$version/$image/Dockerfile", 'w' ); + $fh = fopen( "images/$version/$image/Dockerfile", 'w' ); fwrite( $fh, $dockerfile ); fclose( $fh ); // Copy the entrypoint script, if it exists. - if ( file_exists( "entrypoint-$image.sh" ) ) { - copy( "entrypoint-$image.sh", "$version/$image/entrypoint.sh" ); + if ( file_exists( "entrypoint/entrypoint-$image.sh" ) ) { + copy( "entrypoint/entrypoint-$image.sh", "images/$version/$image/entrypoint.sh" ); + } + + // Copy the PHP-FPM configuration, if it exists. + if ( file_exists( "config/php-fpm-$image.conf" ) ) { + copy( "config/php-fpm-$image.conf", "images/$version/$image/php-fpm.conf" ); } // Generate the build and push commands for this image/version. @@ -323,7 +331,7 @@ } $build_cmd_list = array( "$image $version", - "$build_cmd $version/$image", + "$build_cmd images/$version/$image", 'docker images', "docker push \$PACKAGE_REGISTRY/$image:$version-fpm\$PR_TAG", ); @@ -337,7 +345,7 @@ } // Load the .travis.yml template. - $travis_template = file_get_contents( '.travis.yml-template' ); + $travis_template = file_get_contents( 'templates/.travis.yml-template' ); $travis_template = str_replace( '%%GENERATED_WARNING%%', $generated_warning, $travis_template ); // Generate the YML-formatted list of build commands for each of the images.