diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a06be5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: ci + +on: + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + variant: + - 7.4 + - 7.4-alpine + - 8.0 + platform: + - linux/amd64 + # - linux/arm64 + exclude: + - props: + Dockerfile: Dockerfile-7.4-alpine + - platform: linux/arm64 + env: + TEST_MATCH: PHP Version ${{ matrix.props.version }} + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Detect host configuration + run: | + # NOTE: Docker host configuration determines the networking target for integration testing + v=$(mount | grep "/run/docker.sock") + TARGET_HOST= + + if [ -n "$v" ]; then + echo "Injected docker socket detected" + TARGET_HOST="host.docker.internal" + elif [ -S /var/run/docker.sock ]; then + TARGET_HOST="localhost" + else + echo "No Docker socket detected, fail" + exit 1 + fi + echo "TARGET_HOST=${TARGET_HOST}" >> $GITHUB_ENV + - + # Build and execute in multiple configurations: vanilla, with env overrides, with TLS enabled + name: Build and test + run: | + # NOTE: docker qemu and buildx setup actions create a black hole for build cache layers, avoid unless pushing externally + # Setup multi-arch platforms, noop if already installed for builder + docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 + + TARGET_PLATFORM=${{ matrix.platform }} + PHP_VARIANT=${{ matrix.variant }} + PLATFORM=${TARGET_PLATFORM} PHP_VARIANT=${PHP_VARIANT} ./test.sh $TARGET_HOST diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5299420 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,72 @@ +name: publish + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + env: + IMAGE_BASE: behance/docker-php + strategy: + matrix: + # Variant distributions all have semantic versions + PHP version + suffix (ex. 3.2.1-alpine) + props: + - Dockerfile: Dockerfile-7.4-alpine + version: "7.4" + suffix: alpine + platforms: linux/amd64 + - Dockerfile: Dockerfile-7.4 + version: "7.4" + platforms: linux/amd64,linux/arm64 + - Dockerfile: Dockerfile-8.0 + version: "8.0" + platforms: linux/amd64,linux/arm64 + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Add tag suffix if one exists + if: matrix.props.suffix + run: | + echo TAG_SUFFIX="-${{ matrix.props.suffix }}" >> $GITHUB_ENV + - + name: Docker meta + id: meta + if: github.event_name != 'pull_request' + uses: docker/metadata-action@v3 + with: + images: ${{ env.IMAGE_BASE }} + tags: | + type=raw,priority=100,value=${{ matrix.props.version }} + type=semver,priority=200,prefix=${{ matrix.props.version }}-,pattern={{major}} + type=semver,priority=300,prefix=${{ matrix.props.version }}-,pattern={{major}}.{{minor}} + type=semver,priority=400,prefix=${{ matrix.props.version }}-,pattern={{major}}.{{minor}}.{{patch}} + flavor: | + latest=auto + suffix=${{ env.TAG_SUFFIX }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build + push + uses: docker/build-push-action@v2 + with: + context: . + platforms: ${{ matrix.props.platforms }} + file: ${{ matrix.props.Dockerfile }} + tags: ${{ steps.meta.outputs.tags }} + push: ${{ github.event_name != 'pull_request' }} diff --git a/.travis.yml b/.travis.yml index d5d2422..17565a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ sudo: required env: - - PHP_VARIANT=7.0 - - PHP_VARIANT=7.1 - - PHP_VARIANT=7.2 - - PHP_VARIANT=7.3 - - PHP_VARIANT=7.3-alpine - - PHP_VARIANT=7.4 - - PHP_VARIANT=8.0 + global: + - GOSS_INSTALL_PATH="./" + jobs: + - PHP_VARIANT=7.4-alpine + - PHP_VARIANT=7.4 + - PHP_VARIANT=8.0 services: - docker diff --git a/Dockerfile-7.0 b/Dockerfile-7.0 deleted file mode 100644 index 31f9845..0000000 --- a/Dockerfile-7.0 +++ /dev/null @@ -1,160 +0,0 @@ -FROM behance/docker-nginx:8.10 -LABEL maintainers="Behance Team " - -# Set TERM to suppress warning messages. -ENV CONF_PHPFPM=/etc/php/7.0/fpm/php-fpm.conf \ - CONF_PHPMODS=/etc/php/7.0/mods-available \ - CONF_FPMPOOL=/etc/php/7.0/fpm/pool.d/www.conf \ - CONF_FPMOVERRIDES=/etc/php/7.0/fpm/conf.d/overrides.user.ini \ - APP_ROOT=/app \ - SERVER_WORKER_CONNECTIONS=3072 \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \ - PHP_FPM_MAX_CHILDREN=4096 \ - PHP_FPM_START_SERVERS=20 \ - PHP_FPM_MAX_REQUESTS=1024 \ - PHP_FPM_MIN_SPARE_SERVERS=5 \ - PHP_FPM_MAX_SPARE_SERVERS=128 \ - PHP_FPM_MEMORY_LIMIT=256M \ - PHP_FPM_MAX_EXECUTION_TIME=60 \ - PHP_FPM_UPLOAD_MAX_FILESIZE=1M \ - PHP_OPCACHE_MEMORY_CONSUMPTION=128 \ - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ - PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \ - PHP_OPCACHE_ENABLE_CLI=1 \ - PHP_ENGINE_VERSION=20151012 \ - CFG_APP_DEBUG=1 - -# - Update security packages, only -RUN /bin/bash -e /security_updates.sh && \ - apt-get install -yqq --no-install-recommends \ - gpg-agent \ - git \ - curl \ - wget \ - software-properties-common \ - locales \ - && \ - locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ - add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ - # Ensure PHP 5.5 + 5.6 + 7.1 don't accidentally get added by PPA - apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.0 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.1-cli \ - php7.1-common \ - php7.1-json \ - php7.2-cli \ - php7.2-common \ - php7.2-json \ - php7.3-cli \ - php7.3-common \ - php7.3-json \ - php7.4-cli \ - php7.4-common \ - php7.4-json \ - && \ - apt-get -yqq install \ - php7.0 \ - php7.0-apcu \ - php7.0-bcmath \ - php7.0-bz2 \ - php7.0-curl \ - php7.0-fpm \ - php7.0-gd \ - php7.0-intl \ - php7.0-json \ - php7.0-mbstring \ - php7.0-mcrypt \ - php7.0-memcache \ - php7.0-pgsql \ - php7.0-xdebug \ - php7.0-xml \ - php7.0-yaml \ - php7.0-zip \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ - # Order of operations issue is preventing this from being installed in alphabetical order - php7.0-mysql \ - # below required to compile non-packaged extensions - php7.0-dev \ - pkg-config \ - libmemcached-dev \ - pkg-config \ - zlib1g-dev \ - && \ - pecl-install \ - igbinary \ - memcached \ - msgpack \ - redis \ - && \ - apt-get remove --purge -yq \ - php7.0-dev \ - pkg-config \ - build-essential \ - cpp \ - cpp-7 \ - gcc \ - && \ - /bin/bash /clean.sh \ - && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ - # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder - cd /usr/lib/php && \ - ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh - -# Overlay the root filesystem from this repo -COPY ./container/root / - -# - Hack: share startup scripts between variant versions by symlinking -RUN ln -s /usr/sbin/php-fpm7.0 /usr/sbin/php-fpm && \ - # Override default ini values for both CLI + FPM - phpenmod overrides && \ - # Enable NewRelic via Ubuntu symlinks, but disable via extension command in file. Allows cross-variant startup scripts to function. - phpenmod newrelic && \ - # Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh - -RUN goss -g /tests/php-fpm/7.0.goss.yaml validate && \ - /aufs_hack.sh - diff --git a/Dockerfile-7.1 b/Dockerfile-7.1 deleted file mode 100644 index 957d5f1..0000000 --- a/Dockerfile-7.1 +++ /dev/null @@ -1,162 +0,0 @@ -FROM behance/docker-nginx:8.10 -LABEL maintainers="Behance Team " - -# Set TERM to suppress warning messages. -ENV CONF_PHPFPM=/etc/php/7.1/fpm/php-fpm.conf \ - CONF_PHPMODS=/etc/php/7.1/mods-available \ - CONF_FPMPOOL=/etc/php/7.1/fpm/pool.d/www.conf \ - CONF_FPMOVERRIDES=/etc/php/7.1/fpm/conf.d/overrides.user.ini \ - APP_ROOT=/app \ - SERVER_WORKER_CONNECTIONS=3072 \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \ - PHP_FPM_MAX_CHILDREN=4096 \ - PHP_FPM_START_SERVERS=20 \ - PHP_FPM_MAX_REQUESTS=1024 \ - PHP_FPM_MIN_SPARE_SERVERS=5 \ - PHP_FPM_MAX_SPARE_SERVERS=128 \ - PHP_FPM_MEMORY_LIMIT=256M \ - PHP_FPM_MAX_EXECUTION_TIME=60 \ - PHP_FPM_UPLOAD_MAX_FILESIZE=1M \ - PHP_OPCACHE_MEMORY_CONSUMPTION=128 \ - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ - PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \ - PHP_OPCACHE_ENABLE_CLI=1 \ - PHP_ENGINE_VERSION=20160303 \ - CFG_APP_DEBUG=1 - -# - Update security packages, only -RUN /bin/bash -e /security_updates.sh && \ - apt-get install -yqq --no-install-recommends \ - gpg-agent \ - git \ - curl \ - wget \ - software-properties-common \ - locales \ - && \ - locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ - add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ - # Ensure PHP 5.5 + 5.6 + 7.0 don't accidentally get added by PPA - apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.1 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.0-cli \ - php7.0-common \ - php7.0-json \ - php7.2-cli \ - php7.2-common \ - php7.2-json \ - php7.3-cli \ - php7.3-common \ - php7.3-json \ - php7.4-cli \ - php7.4-common \ - php7.4-json \ - && \ - apt-get -yqq install \ - php7.1 \ - php7.1-apcu \ - php7.1-bcmath \ - php7.1-bz2 \ - php7.1-curl \ - php7.1-fpm \ - php7.1-gd \ - php7.1-intl \ - php7.1-json \ - php7.1-mbstring \ - php7.1-memcache \ - php7.1-mcrypt \ - php7.1-mysql \ - php7.1-pgsql \ - php7.1-xdebug \ - php7.1-xml \ - php7.1-yaml \ - php7.1-zip \ - php-xdebug \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ - # below required to compile non-packaged extensions - php7.1-dev \ - pkg-config \ - libmemcached-dev \ - pkg-config \ - zlib1g-dev \ - && \ - pecl-install \ - igbinary \ - memcached \ - msgpack \ - redis \ - && \ - apt-get remove --purge -yq \ - php7.1-dev \ - pkg-config \ - build-essential \ - cpp \ - cpp-7 \ - gcc \ - && \ - /bin/bash /clean.sh \ - && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ - # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder - cd /usr/lib/php && \ - ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh - -# Overlay the root filesystem from this repo -COPY ./container/root / - -# - Make additional hacks to migrate files/config from 7.0 --> 7.1 folder -RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ - cp /etc/php/7.0/fpm/conf.d/overrides.user.ini $CONF_FPMOVERRIDES && \ - # Hack: share startup scripts between variant versions by symlinking \ - ln -s /usr/sbin/php-fpm7.1 /usr/sbin/php-fpm && \ - # Override default ini values for both CLI + FPM \ - phpenmod overrides && \ - # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. - phpenmod newrelic && \ - # - Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh - -RUN goss -g /tests/php-fpm/7.1.goss.yaml validate && \ - /aufs_hack.sh diff --git a/Dockerfile-7.2 b/Dockerfile-7.2 deleted file mode 100644 index 2a3e522..0000000 --- a/Dockerfile-7.2 +++ /dev/null @@ -1,160 +0,0 @@ -FROM behance/docker-nginx:8.10 -LABEL maintainers="Behance Team " - -# Set TERM to suppress warning messages. -ENV CONF_PHPFPM=/etc/php/7.2/fpm/php-fpm.conf \ - CONF_PHPMODS=/etc/php/7.2/mods-available \ - CONF_FPMPOOL=/etc/php/7.2/fpm/pool.d/www.conf \ - CONF_FPMOVERRIDES=/etc/php/7.2/fpm/conf.d/overrides.user.ini \ - APP_ROOT=/app \ - SERVER_WORKER_CONNECTIONS=3072 \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \ - PHP_FPM_MAX_CHILDREN=4096 \ - PHP_FPM_START_SERVERS=20 \ - PHP_FPM_MAX_REQUESTS=1024 \ - PHP_FPM_MIN_SPARE_SERVERS=5 \ - PHP_FPM_MAX_SPARE_SERVERS=128 \ - PHP_FPM_MEMORY_LIMIT=256M \ - PHP_FPM_MAX_EXECUTION_TIME=60 \ - PHP_FPM_UPLOAD_MAX_FILESIZE=1M \ - PHP_OPCACHE_MEMORY_CONSUMPTION=128 \ - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ - PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \ - PHP_OPCACHE_ENABLE_CLI=1 \ - PHP_ENGINE_VERSION=20170718 \ - CFG_APP_DEBUG=1 - -# - Update security packages, only -RUN /bin/bash -e /security_updates.sh && \ - apt-get install -yqq --no-install-recommends \ - gpg-agent \ - git \ - curl \ - wget \ - software-properties-common \ - locales \ - && \ - locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ - add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ - # Ensure PHP 5.5 + 5.6 + 7.1 don't accidentally get added by PPA - apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.2 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.0-cli \ - php7.0-common \ - php7.0-json \ - php7.1-cli \ - php7.1-common \ - php7.1-json \ - php7.3-cli \ - php7.3-common \ - php7.3-json \ - php7.4-cli \ - php7.4-common \ - php7.4-json \ - && \ - apt-get -yqq install \ - php7.2 \ - php7.2-apcu \ - php7.2-bcmath \ - php7.2-bz2 \ - php7.2-curl \ - php7.2-fpm \ - php7.2-gd \ - php7.2-intl \ - php7.2-json \ - php7.2-mbstring \ - php7.2-memcache \ - php7.2-mysql \ - php7.2-pgsql \ - php7.2-xdebug \ - php7.2-xml \ - php7.2-yaml \ - php7.2-zip \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ - # below required to compile non-packaged extensions - php7.2-dev \ - pkg-config \ - libmemcached-dev \ - pkg-config \ - zlib1g-dev \ - && \ - pecl-install \ - igbinary \ - memcached \ - msgpack \ - redis \ - && \ - apt-get remove --purge -yq \ - php7.2-dev \ - pkg-config \ - build-essential \ - cpp \ - cpp-7 \ - gcc \ - && \ - /bin/bash /clean.sh \ - && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ - # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder - cd /usr/lib/php && \ - ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh - -# Overlay the root filesystem from this repo -COPY ./container/root / - -# - Make additional hacks to migrate files/config from 7.0 --> 7.2 folder -RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ - cp /etc/php/7.0/fpm/conf.d/overrides.user.ini $CONF_FPMOVERRIDES && \ - # Hack: share startup scripts between variant versions by symlinking \ - ln -s /usr/sbin/php-fpm7.2 /usr/sbin/php-fpm && \ - # Override default ini values for both CLI + FPM \ - phpenmod overrides && \ - # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. - phpenmod newrelic && \ - # - Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh - -RUN goss -g /tests/php-fpm/7.2.goss.yaml validate && \ - /aufs_hack.sh diff --git a/Dockerfile-7.3 b/Dockerfile-7.3 deleted file mode 100644 index f5ed32a..0000000 --- a/Dockerfile-7.3 +++ /dev/null @@ -1,165 +0,0 @@ -FROM behance/docker-nginx:8.10 -LABEL maintainers="Behance Team " - -# Set TERM to suppress warning messages. -ENV CONF_PHPFPM=/etc/php/7.3/fpm/php-fpm.conf \ - CONF_PHPMODS=/etc/php/7.3/mods-available \ - CONF_FPMPOOL=/etc/php/7.3/fpm/pool.d/www.conf \ - CONF_FPMOVERRIDES=/etc/php/7.3/fpm/conf.d/overrides.user.ini \ - APP_ROOT=/app \ - SERVER_WORKER_CONNECTIONS=3072 \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_CLIENT_HEADER_BUFFER_SIZE=1k \ - SERVER_CLIENT_BODY_BUFFER_SIZE=128k \ - SERVER_LARGE_CLIENT_HEADER_BUFFERS="4 256k" \ - PHP_FPM_MAX_CHILDREN=4096 \ - PHP_FPM_START_SERVERS=20 \ - PHP_FPM_MAX_REQUESTS=1024 \ - PHP_FPM_MIN_SPARE_SERVERS=5 \ - PHP_FPM_MAX_SPARE_SERVERS=128 \ - PHP_FPM_MEMORY_LIMIT=256M \ - PHP_FPM_MAX_EXECUTION_TIME=60 \ - PHP_FPM_UPLOAD_MAX_FILESIZE=1M \ - PHP_OPCACHE_MEMORY_CONSUMPTION=128 \ - PHP_OPCACHE_INTERNED_STRINGS_BUFFER=16 \ - PHP_OPCACHE_MAX_WASTED_PERCENTAGE=5 \ - PHP_OPCACHE_ENABLE_CLI=1 \ - PHP_ENGINE_VERSION=20180731 \ - CFG_APP_DEBUG=1 - -# - Update security packages, only -RUN /bin/bash -e /security_updates.sh && \ - apt-get install -yqq --no-install-recommends \ - gpg-agent \ - git \ - curl \ - wget \ - software-properties-common \ - locales \ - && \ - locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ - add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ - # Ensure PHP 5.5 + 5.6 + 7.1 don't accidentally get added by PPA - apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.3 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.0-cli \ - php7.0-common \ - php7.0-json \ - php7.1-cli \ - php7.1-common \ - php7.1-json \ - php7.2-cli \ - php7.2-common \ - php7.2-json \ - php7.4-cli \ - php7.4-common \ - php7.4-json \ - && \ - apt-get -yqq install \ - php7.3 \ - php7.3-apcu \ - php7.3-bcmath \ - php7.3-bz2 \ - php7.3-curl \ - php7.3-fpm \ - php7.3-gd \ - php7.3-intl \ - php7.3-json \ - php7.3-mbstring \ - php7.3-memcache \ - php7.3-mysql \ - php7.3-pgsql \ - php7.3-xdebug \ - php7.3-xml \ - php7.3-yaml \ - php7.3-zip \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ - # below required to compile non-packaged extensions - php7.3-dev \ - pkg-config \ - libmemcached-dev \ - pkg-config \ - zlib1g-dev \ - && \ - pecl-install \ - igbinary \ - memcached \ - msgpack \ - redis \ - && \ - apt-get remove --purge -yq \ - php7.3-dev \ - pkg-config \ - build-essential \ - cpp \ - cpp-7 \ - gcc \ - && \ - /bin/bash /clean.sh \ - && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ - # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder - cd /usr/lib/php && \ - ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh - -# Overlay the root filesystem from this repo -COPY ./container/root / - -# - Make additional hacks to migrate files/config from 7.0 --> 7.3 folder -RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ - cp /etc/php/7.0/fpm/conf.d/overrides.user.ini $CONF_FPMOVERRIDES && \ - # Hack: share startup scripts between variant versions by symlinking \ - ln -s /usr/sbin/php-fpm7.3 /usr/sbin/php-fpm && \ - # Override default ini values for both CLI + FPM \ - phpenmod overrides && \ - # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. - phpenmod newrelic && \ - # Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh && \ - # Add new 7.3+ conf - sed -i "s/;decorate_workers_output.*/decorate_workers_output = no/" $CONF_FPMPOOL - -# HACK: workaround for https://github.com/aelsabbahy/goss/issues/392 -# Run the child and parent test configs separately -RUN goss -g /tests/php-fpm/base.goss.yaml validate && \ - goss -g /tests/php-fpm/7.3.goss.yaml validate && \ - /aufs_hack.sh diff --git a/Dockerfile-7.4 b/Dockerfile-7.4 index a3444f8..94eed84 100644 --- a/Dockerfile-7.4 +++ b/Dockerfile-7.4 @@ -1,4 +1,4 @@ -FROM behance/docker-nginx:8.10 +FROM behance/docker-nginx:9.0 LABEL maintainers="Behance Team " # Set TERM to suppress warning messages. @@ -27,7 +27,14 @@ ENV CONF_PHPFPM=/etc/php/7.4/fpm/php-fpm.conf \ PHP_ENGINE_VERSION=20190902 \ CFG_APP_DEBUG=1 -# - Update security packages, only +COPY ./scripts/ /scripts/ + +# - Update security packages +# - Add PHP and support packages +# - Install NewRelic +# - Compile extensions +# - Enable/disable default extensions +# - Cleanup RUN /bin/bash -e /security_updates.sh && \ apt-get install -yqq --no-install-recommends \ gpg-agent \ @@ -39,45 +46,14 @@ RUN /bin/bash -e /security_updates.sh && \ && \ locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ + apt-get update -q && \ # Ensure old versions of PHP don't accidentally get added by PPA maintainers apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.4 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.0-cli \ - php7.0-common \ - php7.0-json \ - php7.1-cli \ - php7.1-common \ - php7.1-json \ - php7.2-cli \ - php7.2-common \ - php7.2-json \ - php7.3-cli \ - php7.3-common \ - php7.3-json \ + apache2 \ + apache2-bin \ + libapache2-mod-php7.4 \ + manpages \ + manpages-dev \ && \ apt-get -yqq install \ php7.4 \ @@ -97,52 +73,57 @@ RUN apt-get update -q && \ php7.4-xml \ php7.4-yaml \ php7.4-zip \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ # below required to compile non-packaged extensions php7.4-dev \ pkg-config \ libmemcached-dev \ - pkg-config \ zlib1g-dev \ + libssl-dev \ + libpcre3-dev \ + golang \ && \ - pecl-install \ + /bin/bash -e /scripts/install-newrelic-ubuntu.sh && \ + /bin/bash -e /scripts/install-composer.sh && \ + /scripts/pecl-install.sh \ igbinary \ memcached \ msgpack \ redis \ && \ + phpenmod \ + memcached \ + igbinary \ + msgpack \ + && \ + phpdismod \ + pdo_pgsql \ + pgsql \ + redis \ + yaml \ + xdebug \ + && \ apt-get remove --purge -yq \ - php7.4-dev \ - pkg-config \ build-essential \ cpp \ cpp-7 \ gcc \ + golang \ + libpcre3-dev \ + libssl-dev \ + locales \ + patch \ + php7.4-dev \ + pkg-config \ + software-properties-common \ + wget \ && \ /bin/bash /clean.sh \ - && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ - # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder + # Remove extra extensions installed via packages for other versions of PHP, leaving only the active engine folder cd /usr/lib/php && \ ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - rm -rf /usr/lib/php/7.3 && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh + cd / -# Overlay the root filesystem from this repo +# # Overlay the root filesystem from this repo COPY ./container/root / # - Make additional hacks to migrate files/config from 7.0 --> 7.4 folder @@ -155,9 +136,8 @@ RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. phpenmod newrelic && \ # Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh && \ - # New 7.3+ specific configuration - sed -i "s/;decorate_workers_output.*/decorate_workers_output = no/" $CONF_FPMPOOL + /bin/bash -e /scripts/prep-php.sh + # HACK: workaround for https://github.com/aelsabbahy/goss/issues/392 # Run the child and parent test configs separately instead of leveraging inheritance diff --git a/Dockerfile-7.3-alpine b/Dockerfile-7.4-alpine similarity index 70% rename from Dockerfile-7.3-alpine rename to Dockerfile-7.4-alpine index 6a277f7..97a6e7c 100644 --- a/Dockerfile-7.3-alpine +++ b/Dockerfile-7.4-alpine @@ -1,4 +1,4 @@ -FROM behance/docker-nginx:8.10-alpine +FROM behance/docker-nginx:9.0-alpine LABEL maintainers="Behance Team " # Set TERM to suppress warning messages. @@ -27,6 +27,14 @@ ENV CONF_PHPFPM=/etc/php7/php-fpm.conf \ PHP_ENGINE_VERSION=20180731 \ CFG_APP_DEBUG=1 +COPY ./scripts /scripts + +# - Update packages +# - Add PHP and support packages +# - Install NewRelic +# - Compile extensions +# - Enable/disable default extensions +# - Cleanup RUN apk update && \ apk add --no-cache \ git \ @@ -79,41 +87,11 @@ RUN apk update && \ php7-xsl \ php7-zip \ php7-zlib \ - && \ - # Disable xdebug by default \ - sed -i 's/zend_extension\s\?=/;zend_extension =/' $CONF_PHPMODS/xdebug.ini && \ - # Disable postgres by default \ - sed -i 's/extension/;extension/' $CONF_PHPMODS/01_pdo_pgsql.ini && \ - sed -i 's/extension/;extension/' $CONF_PHPMODS/00_pgsql.ini && \ - /bin/bash -e /clean.sh - -# Locate and install latest Alpine-compatible NewRelic, seed with variables to be replaced -# Requires PHP to already be installed -RUN NEWRELIC_MUSL_PATH=$(curl -s https://download.newrelic.com/php_agent/release/ | grep 'linux-musl.tar.gz' | cut -d '"' -f2) && \ - NEWRELIC_PATH="https://download.newrelic.com${NEWRELIC_MUSL_PATH}" && \ - curl -L ${NEWRELIC_PATH} -o ./root/newrelic-musl.tar.gz && \ - cd /root && \ - gzip -dc newrelic-musl.tar.gz | tar xf - && \ - rm newrelic-musl.tar.gz && \ - NEWRELIC_DIRECTORY=/root/$(basename $(find . -maxdepth 1 -type d -name newrelic\*)) && \ - cd $NEWRELIC_DIRECTORY && \ - echo "\n" | ./newrelic-install install && \ - chown root:root $NEWRELIC_DIRECTORY/agent/x64/newrelic-${PHP_ENGINE_VERSION}.so && \ - mv $NEWRELIC_DIRECTORY/agent/x64/newrelic-${PHP_ENGINE_VERSION}.so /usr/lib/php7/modules/newrelic.so && \ - rm -rf $NEWRELIC_DIRECTORY/agent/x64 && \ - # Fix permissions on extracted folder \ - chown -R $NOT_ROOT_USER:$NOT_ROOT_USER * && \ - /bin/bash -e /clean.sh - -RUN curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer - -RUN apk update && \ - apk add --no-cache \ - yaml-dev \ - zlib-dev \ - libmemcached-dev \ - cyrus-sasl-dev \ + # below required to compile non-packaged extensions + yaml-dev \ + zlib-dev \ + libmemcached-dev \ + cyrus-sasl-dev \ && \ apk add --no-cache --virtual .phpize_deps \ autoconf file g++ gcc libc-dev make pkgconf re2c php7-dev php7-pear \ @@ -129,8 +107,16 @@ RUN apk update && \ echo "extension=msgpack.so" > $CONF_PHPMODS/msgpack.ini && \ pecl install memcached && \ echo "extension=memcached.so" > $CONF_PHPMODS/memcached.ini && \ - rm -rf /usr/share/php7 && \ + # Disable xdebug by default \ + sed -i 's/zend_extension\s\?=/;zend_extension =/' $CONF_PHPMODS/50_xdebug.ini && \ + # Disable postgres by default \ + sed -i 's/extension/;extension/' $CONF_PHPMODS/01_pdo_pgsql.ini && \ + sed -i 's/extension/;extension/' $CONF_PHPMODS/00_pgsql.ini \ + && \ + /bin/bash -e /scripts/install-newrelic-alpine.sh && \ + /bin/bash -e /scripts/install-composer.sh && \ apk del .phpize_deps && \ + # rm -rf /usr/share/php7 && \ /bin/bash -e /clean.sh # Overlay the root filesystem from this repo @@ -142,7 +128,10 @@ RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ # - Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants chown $NOT_ROOT_USER:$NOT_ROOT_USER /var/log/php7 && \ ln -s /usr/sbin/php-fpm7 /usr/sbin/php-fpm && \ - /bin/bash -e prep-php.sh + /bin/bash -e /scripts/prep-php.sh -RUN goss -g /tests/php-fpm/7.3-alpine.goss.yaml validate && \ +# HACK: workaround for https://github.com/aelsabbahy/goss/issues/392 +# Run the child and parent test configs separately instead of leveraging inheritance +RUN goss -g /tests/php-fpm/7.4-alpine.goss.yaml validate && \ + goss -g /tests/php-fpm/base.goss.yaml validate && \ /aufs_hack.sh diff --git a/Dockerfile-8.0 b/Dockerfile-8.0 index 0cb3c5b..cd91224 100644 --- a/Dockerfile-8.0 +++ b/Dockerfile-8.0 @@ -1,4 +1,4 @@ -FROM behance/docker-nginx:8.9 +FROM behance/docker-nginx:9.0 LABEL maintainers="Behance Team " # Set TERM to suppress warning messages. @@ -27,7 +27,14 @@ ENV CONF_PHPFPM=/etc/php/8.0/fpm/php-fpm.conf \ PHP_ENGINE_VERSION=20200930 \ CFG_APP_DEBUG=1 -# - Update security packages, only +COPY ./scripts/ /scripts/ + +# - Update security packages +# - Add PHP and support packages +# - Install NewRelic +# - Compile extensions +# - Enable/disable default extensions +# - Cleanup RUN /bin/bash -e /security_updates.sh && \ apt-get install -yqq --no-install-recommends \ gpg-agent \ @@ -39,50 +46,16 @@ RUN /bin/bash -e /security_updates.sh && \ && \ locale-gen en_US.UTF-8 && export LANG=en_US.UTF-8 && \ add-apt-repository ppa:ondrej/php -y && \ - echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ - wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ - # Prevent newrelic install from prompting for input \ - echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections && \ - echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections && \ - # Perform cleanup \ - apt-get remove --purge -yq \ - patch \ - software-properties-common \ - locales \ - wget \ - && \ - /bin/bash /clean.sh - -# Add PHP and support packages -COPY container/root/usr/local/bin/pecl-install /usr/local/bin -RUN apt-get update -q && \ + apt-get update -q && \ # Ensure old versions of PHP don't accidentally get added by PPA maintainers apt-mark hold \ - manpages \ - manpages-dev \ - apache2 \ - apache2-bin \ - libapache2-mod-php7.4 \ - php5.6-cli \ - php5.6-common \ - php5.6-json \ - php7.0-cli \ - php7.0-common \ - php7.0-json \ - php7.1-cli \ - php7.1-common \ - php7.1-json \ - php7.2-cli \ - php7.2-common \ - php7.2-json \ - php7.3-cli \ - php7.3-common \ - php7.3-json \ - php7.4-cli \ - php7.4-common \ - php7.4-json - -RUN apt-get -yqq install \ + manpages \ + manpages-dev \ + apache2 \ + apache2-bin \ + libapache2-mod-php8.0 \ + && \ + apt-get -yqq install \ php8.0 \ php8.0-apcu \ php8.0-bcmath \ @@ -101,30 +74,49 @@ RUN apt-get -yqq install \ php8.0-xml \ php8.0-yaml \ php8.0-zip \ - newrelic-php5 \ - newrelic-php5-common \ - newrelic-daemon \ + # below required to compile non-packaged extensions + php8.0-dev \ + pkg-config \ + libmemcached-dev \ + zlib1g-dev \ + libssl-dev \ + libpcre3-dev \ + golang \ && \ - /bin/bash /clean.sh \ + /bin/bash -e /scripts/install-newrelic-ubuntu.sh && \ + /bin/bash -e /scripts/install-composer.sh && \ + phpenmod \ + memcached \ + igbinary \ + msgpack \ + && \ + phpdismod \ + pdo_pgsql \ + pgsql \ + redis \ + yaml \ + xdebug \ && \ - phpenmod memcached && \ - phpenmod igbinary && \ - phpenmod msgpack && \ - phpdismod pdo_pgsql && \ - phpdismod pgsql && \ - phpdismod redis && \ - phpdismod yaml && \ - phpdismod xdebug && \ + apt-get remove --purge -yq \ + build-essential \ + cpp \ + cpp-7 \ + gcc \ + golang \ + libpcre3-dev \ + libssl-dev \ + locales \ + patch \ + php8.0-dev \ + pkg-config \ + software-properties-common \ + wget \ + && \ + /bin/bash /clean.sh \ # Remove extra extensions installed via packages for other versions of PHP, leaving the active engine folder cd /usr/lib/php && \ ls -d */ | grep '[0-9]\{8\}' | grep -v ${PHP_ENGINE_VERSION} | xargs rm -rf && \ - rm -rf /usr/lib/php/7.4 && \ - # Remove unused agents for other PHP versions - cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ - cd / && \ - curl -sS https://getcomposer.org/installer | php && \ - mv composer.phar /usr/local/bin/composer && \ - /bin/bash /clean.sh + cd / # Overlay the root filesystem from this repo COPY ./container/root / @@ -139,9 +131,7 @@ RUN cp /etc/php/7.0/mods-available/* $CONF_PHPMODS && \ # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. phpenmod newrelic && \ # Run standard set of tweaks to ensure runs performant, reliably, and consistent between variants - /bin/bash -e /prep-php.sh && \ - # New 7.3+ specific configuration - sed -i "s/;decorate_workers_output.*/decorate_workers_output = no/" $CONF_FPMPOOL + /bin/bash -e /scripts/prep-php.sh # HACK: workaround for https://github.com/aelsabbahy/goss/issues/392 # Run the child and parent test configs separately instead of leveraging inheritance diff --git a/README.md b/README.md index 93e5e48..1bbf6ac 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,7 @@ Available on [Docker Hub](https://hub.docker.com/r/behance/docker-php/). ### Quick-start -- `docker run behance/docker-php:7.0 "php" "-v"` -- `docker run behance/docker-php:7.1 "php" "-v"` -- `docker run behance/docker-php:7.2 "php" "-v"` -- `docker run behance/docker-php:7.3-alpine "php" "-v"` -- `docker run behance/docker-php:7.3" "php" "-v"` +- `docker run behance/docker-php:7.4-alpine "php" "-v"` - `docker run behance/docker-php:7.4" "php" "-v"` - `docker run behance/docker-php:8.0" "php" "-v"` @@ -29,7 +25,7 @@ Adding startup logic, [basic](https://github.com/behance/docker-base#startuprunt - `PHP_MAJOR.PHP_MINOR`, required. Engine versions of PHP. ex. `docker-php:8.0` - `(Major.Minor.Patch)`, optional. Semantically versioned container provisioning code. ex. `docker-php:7.4-13.4.0`. -- `(-variant)`, optional. Alpine variants are slim versions of the container. ex. `docker-php:7.3-alpine`. +- `(-variant)`, optional. Alpine variants are slim versions of the container. ex. `docker-php:7.4-alpine`. ### Includes --- @@ -44,7 +40,6 @@ Adding startup logic, [basic](https://github.com/behance/docker-base#startuprunt For extension customization, including enabling and disabling defaults, see [here](https://github.com/behance/docker-php#downstream-configuration) `^` - not available on `-alpine` variant -`*` - not available on `7.2+` `~` - disabled by default - apcu @@ -63,7 +58,6 @@ For extension customization, including enabling and disabling defaults, see [her - intl - json - mbstring - - mcrypt * - memcache ^ - memcached - msgpack @@ -87,7 +81,7 @@ For extension customization, including enabling and disabling defaults, see [her - sysvsem - sysvshm - tokenizer - - xdebug ~,* + - xdebug ~ - xml - xmlreader - xmlwriter @@ -211,15 +205,36 @@ PHP_FPM_LOG_BUFFERING | PHP_FPM_LOG_BUFFERING=no | yes | PHP 7.3+ only [docs](ht ### Testing --- -- Requires `bash`, `docker`, `docker-compose`, and `dgoss` +- Requires `bash`, `docker`, and `dgoss` ([link](https://github.com/aelsabbahy/goss/blob/master/extras/dgoss/README.md)) To test locally, run `PHP_VARIANT=8.0 ./test.sh {docker engine IP}`. This will: -- Build a single container `PHP_VARIANT` (7.0, 7.1, 7.2, 7.3, 7.3-alpine, 7.4, 8.0) +- Build a single container `PHP_VARIANT` (ex. 7.4-alpine, 7.4, 8.0) - Leverages [Goss](https://goss.rocks) to confirm package, config, and extension installation - Validates a large file upload - Boots container with specific NewRelic configuration overrides -The test matrix is run automatically per pull request on Travis CI. +### Release Management +Github actions provide the machinery for testing (ci.yaml) and producing tags distributed through Docker Hub (publish.yaml). Testing will confirm that `nginx` is able to serve content in various configurations, but also that it can terminate TLS with self-signed certificates. Once a tested and approved PR is merged, simply cutting a new semantically-versioned tag will generate the a matrix of tagged builds. See Container tag scheme above. + +Platform support is available for multiple architectures: +- `linux/amd64`: Ubuntu and Alpine variants +- `linux/arm64`: Ubuntu variants-only + +To add new variant based on a new Dockerfile, add an entry to `matrix.props` within `./github/workflows` YAML files. + +### Github Actions: Simulation + +docker-nginx uses Github Actions for CI/CD. Simulated workflows can be achieved locally with `act`. All commands must be executes from repository root. + +Pre-reqs: tested on Mac +1. [Docker Desktop](https://www.docker.com/products/docker-desktop) +1. [act](https://github.com/nektos/act) + +Pull request simulation: executes successfully, but only on ARM devices (ex. Apple M1). ARM emulation through QEMU on X64 machines does not implement the full kernel functionality required by nginx at this time. +- `act pull_request` + +Publish simulation: executes, but fails (intentionally) without credentials +- `act` diff --git a/container/root/tests/php-fpm/7.0.goss.yaml b/container/root/tests/php-fpm/7.0.goss.yaml deleted file mode 100644 index 0a83643..0000000 --- a/container/root/tests/php-fpm/7.0.goss.yaml +++ /dev/null @@ -1,17 +0,0 @@ -gossfile: - base.goss.yaml: {} - -command: - # IMPORTANT: confirm the major/minor version of PHP itself - php -r 'echo PHP_MAJOR_VERSION;': - exit-status: 0 - stdout: [7] - php -r 'echo PHP_MINOR_VERSION;': - exit-status: 0 - stdout: [0] - php-fpm7.0 -v: - exit-status: 0 - stdout: [PHP 7.0] - # Not common to all variants, test in supported children - php -m | grep -i memcache: - exit-status: 0 diff --git a/container/root/tests/php-fpm/7.1.goss.yaml b/container/root/tests/php-fpm/7.1.goss.yaml deleted file mode 100644 index 24fe5e1..0000000 --- a/container/root/tests/php-fpm/7.1.goss.yaml +++ /dev/null @@ -1,17 +0,0 @@ -gossfile: - base.goss.yaml: {} - -command: - # IMPORTANT: confirm the major/minor version of PHP itself - php -r 'echo PHP_MAJOR_VERSION;': - exit-status: 0 - stdout: [7] - php -r 'echo PHP_MINOR_VERSION;': - exit-status: 0 - stdout: [1] - php-fpm7.1 -v: - exit-status: 0 - stdout: [PHP 7.1] - # Not common to all variants, test in supported children - php -m | grep -i memcache: - exit-status: 0 diff --git a/container/root/tests/php-fpm/7.2.goss.yaml b/container/root/tests/php-fpm/7.2.goss.yaml deleted file mode 100644 index c04eb8f..0000000 --- a/container/root/tests/php-fpm/7.2.goss.yaml +++ /dev/null @@ -1,17 +0,0 @@ -gossfile: - base.goss.yaml: {} - -command: - # IMPORTANT: confirm the major/minor version of PHP itself - php -r 'echo PHP_MAJOR_VERSION;': - exit-status: 0 - stdout: [7] - php -r 'echo PHP_MINOR_VERSION;': - exit-status: 0 - stdout: [2] - php-fpm7.2 -v: - exit-status: 0 - stdout: [PHP 7.2] - # Not common to all variants, test in supported children - php -m | grep -i memcache: - exit-status: 0 diff --git a/container/root/tests/php-fpm/7.3.goss.yaml b/container/root/tests/php-fpm/7.3.goss.yaml deleted file mode 100644 index 1dcfd64..0000000 --- a/container/root/tests/php-fpm/7.3.goss.yaml +++ /dev/null @@ -1,29 +0,0 @@ - -# Extended file tests will be overridden/ignored from parent -# Note: Other variants may not include extended file tests, are not susceptible -# @see https://github.com/aelsabbahy/goss/issues/392 - -# gossfile: -# base.goss.yaml: {} - -command: - # IMPORTANT: confirm the major/minor version of PHP itself - php -r 'echo PHP_MAJOR_VERSION;': - exit-status: 0 - stdout: [7] - php -r 'echo PHP_MINOR_VERSION;': - exit-status: 0 - stdout: [3] - php-fpm -v: - exit-status: 0 - stdout: [PHP 7.3] - # Not common to all variants, test in supported children - php -m | grep -i memcache: - exit-status: 0 - -# Using workaround commands until https://github.com/aelsabbahy/goss/issues/392 is solved -file: - {{ .Env.CONF_FPMPOOL }}: - exists: true - contains: - - '/^decorate_workers_output = no/' diff --git a/container/root/tests/php-fpm/7.3-alpine.goss.yaml b/container/root/tests/php-fpm/7.4-alpine.goss.yaml similarity index 89% rename from container/root/tests/php-fpm/7.3-alpine.goss.yaml rename to container/root/tests/php-fpm/7.4-alpine.goss.yaml index b143750..3b83916 100644 --- a/container/root/tests/php-fpm/7.3-alpine.goss.yaml +++ b/container/root/tests/php-fpm/7.4-alpine.goss.yaml @@ -8,10 +8,10 @@ command: stdout: [7] php -r 'echo PHP_MINOR_VERSION;': exit-status: 0 - stdout: [3] + stdout: [4] php-fpm7 -m: exit-status: 0 stderr: ['!/./'] php-fpm7 -v: exit-status: 0 - stdout: [PHP 7.3] + stdout: [PHP 7.4] diff --git a/container/root/tests/php-fpm/7.4.goss.yaml b/container/root/tests/php-fpm/7.4.goss.yaml index ee83d05..b8969df 100644 --- a/container/root/tests/php-fpm/7.4.goss.yaml +++ b/container/root/tests/php-fpm/7.4.goss.yaml @@ -20,10 +20,3 @@ command: # Not common to all variants, test in supported children php -m | grep -i memcache: exit-status: 0 - -# Using workaround commands until https://github.com/aelsabbahy/goss/issues/392 is solved -file: - {{ .Env.CONF_FPMPOOL }}: - exists: true - contains: - - '/^decorate_workers_output = no/' diff --git a/container/root/tests/php-fpm/8.0.goss.yaml b/container/root/tests/php-fpm/8.0.goss.yaml index 79b904f..786d49f 100644 --- a/container/root/tests/php-fpm/8.0.goss.yaml +++ b/container/root/tests/php-fpm/8.0.goss.yaml @@ -20,10 +20,3 @@ command: # Not common to all variants, test in supported children php -m | grep -i memcache: exit-status: 0 - -# Using workaround commands until https://github.com/aelsabbahy/goss/issues/392 is solved -file: - {{ .Env.CONF_FPMPOOL }}: - exists: true - contains: - - '/^decorate_workers_output = no/' diff --git a/container/root/tests/php-fpm/base.goss.yaml b/container/root/tests/php-fpm/base.goss.yaml index 023c61d..2a950b1 100644 --- a/container/root/tests/php-fpm/base.goss.yaml +++ b/container/root/tests/php-fpm/base.goss.yaml @@ -158,7 +158,12 @@ command: php -n -d zend_extension=xdebug.so --ri xdebug: exit-status: 0 stderr: ['!/./'] - + composer about: + exit-status: 0 + stdout: ['/Composer - Dependency Manager for PHP/'] + newrelic-daemon -v: + exit-status: 0 + stdout: ['/New Relic daemon/'] file: {{ .Env.CONF_FPMPOOL }}: exists: true @@ -179,6 +184,7 @@ file: - '/^request_terminate_timeout = \${PHP_FPM_MAX_EXECUTION_TIME}/' - '/^rlimit_files = 40000/' - '/^rlimit_core = unlimited/' + - '/^decorate_workers_output = no/' {{ .Env.CONF_PHPMODS }}/newrelic.ini: exists: true contains: @@ -204,4 +210,4 @@ file: - '/^opcache.file_cache=\${PHP_OPCACHE_FILE_CACHE}/' - '/^opcache.enable_cli=\${PHP_OPCACHE_ENABLE_CLI}/' - '/^opcache.preload_user=\${NOT_ROOT_USER}/' - - '/^opcache.preload=\${PHP_OPCACHE_PRELOAD}/' \ No newline at end of file + - '/^opcache.preload=\${PHP_OPCACHE_PRELOAD}/' diff --git a/runtime-tests/newrelic/7.0/goss.yaml b/runtime-tests/newrelic/7.0/goss.yaml deleted file mode 100644 index 599b143..0000000 --- a/runtime-tests/newrelic/7.0/goss.yaml +++ /dev/null @@ -1,11 +0,0 @@ -file: - /etc/php/7.0/mods-available/newrelic.ini: - exists: true - mode: "0644" - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/^newrelic.transaction_tracer.enabled = true/' - - '/^newrelic.distributed_tracing_enabled = true/' - - '/^newrelic.loglevel = \"verbosedebug\"/' - - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - - '/^newrelic.special=debug_autorum/' diff --git a/runtime-tests/newrelic/7.1/goss.yaml b/runtime-tests/newrelic/7.1/goss.yaml deleted file mode 100644 index 0803258..0000000 --- a/runtime-tests/newrelic/7.1/goss.yaml +++ /dev/null @@ -1,11 +0,0 @@ -file: - /etc/php/7.1/mods-available/newrelic.ini: - exists: true - mode: "0644" - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/^newrelic.transaction_tracer.enabled = true/' - - '/^newrelic.distributed_tracing_enabled = true/' - - '/^newrelic.loglevel = \"verbosedebug\"/' - - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - - '/^newrelic.special=debug_autorum/' diff --git a/runtime-tests/newrelic/7.2/goss.yaml b/runtime-tests/newrelic/7.2/goss.yaml deleted file mode 100644 index d02e082..0000000 --- a/runtime-tests/newrelic/7.2/goss.yaml +++ /dev/null @@ -1,11 +0,0 @@ -file: - /etc/php/7.2/mods-available/newrelic.ini: - exists: true - mode: "0644" - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/^newrelic.transaction_tracer.enabled = true/' - - '/^newrelic.distributed_tracing_enabled = true/' - - '/^newrelic.loglevel = \"verbosedebug\"/' - - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - - '/^newrelic.special=debug_autorum/' diff --git a/runtime-tests/newrelic/7.3/goss.yaml b/runtime-tests/newrelic/7.3/goss.yaml deleted file mode 100644 index 29b4b5c..0000000 --- a/runtime-tests/newrelic/7.3/goss.yaml +++ /dev/null @@ -1,11 +0,0 @@ -file: - /etc/php/7.3/mods-available/newrelic.ini: - exists: true - mode: "0644" - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/^newrelic.transaction_tracer.enabled = true/' - - '/^newrelic.distributed_tracing_enabled = true/' - - '/^newrelic.loglevel = \"verbosedebug\"/' - - '/^newrelic.daemon.loglevel = \"verbosedebug\"/' - - '/^newrelic.special=debug_autorum/' diff --git a/runtime-tests/newrelic/7.3-alpine/goss.yaml b/runtime-tests/newrelic/7.4-alpine/goss.yaml similarity index 100% rename from runtime-tests/newrelic/7.3-alpine/goss.yaml rename to runtime-tests/newrelic/7.4-alpine/goss.yaml diff --git a/runtime-tests/startup/7.0/goss.yaml b/runtime-tests/startup/7.0/goss.yaml deleted file mode 100644 index 3d3337e..0000000 --- a/runtime-tests/startup/7.0/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/legacy filtered stdout/' diff --git a/runtime-tests/startup/7.1/goss.yaml b/runtime-tests/startup/7.1/goss.yaml deleted file mode 100644 index 3d3337e..0000000 --- a/runtime-tests/startup/7.1/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/legacy filtered stdout/' diff --git a/runtime-tests/startup/7.2/goss.yaml b/runtime-tests/startup/7.2/goss.yaml deleted file mode 100644 index 3d3337e..0000000 --- a/runtime-tests/startup/7.2/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/legacy filtered stdout/' diff --git a/runtime-tests/startup/7.3/goss.yaml b/runtime-tests/startup/7.3/goss.yaml deleted file mode 100644 index 7c10162..0000000 --- a/runtime-tests/startup/7.3/goss.yaml +++ /dev/null @@ -1,6 +0,0 @@ -file: - /goss/docker_output.log: - exists: true - filetype: file # file, symlink, directory - contains: # Check file content for these patterns - - '/launching...$/' diff --git a/runtime-tests/startup/7.3-alpine/goss.yaml b/runtime-tests/startup/7.4-alpine/goss.yaml similarity index 100% rename from runtime-tests/startup/7.3-alpine/goss.yaml rename to runtime-tests/startup/7.4-alpine/goss.yaml diff --git a/scripts/install-composer.sh b/scripts/install-composer.sh new file mode 100644 index 0000000..1a3e0c4 --- /dev/null +++ b/scripts/install-composer.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php + +mv composer.phar /usr/local/bin/composer + +exit $RESULT diff --git a/scripts/install-newrelic-alpine.sh b/scripts/install-newrelic-alpine.sh new file mode 100644 index 0000000..0cd223d --- /dev/null +++ b/scripts/install-newrelic-alpine.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +ARCH=$(archstring --x64 x64 --arm64 arm64) + +if [[ "$ARCH" == "x64" ]]; then + # Locate and install latest Alpine-compatible NewRelic, seed with variables to be replaced + # Requires PHP to already be installed + NEWRELIC_MUSL_PATH=$(curl -s https://download.newrelic.com/php_agent/release/ | grep 'linux-musl.tar.gz' | cut -d '"' -f2) + NEWRELIC_PATH="https://download.newrelic.com${NEWRELIC_MUSL_PATH}" + curl -L ${NEWRELIC_PATH} -o ./root/newrelic-musl.tar.gz + cd /root + gzip -dc newrelic-musl.tar.gz | tar xf - + rm newrelic-musl.tar.gz + NEWRELIC_DIRECTORY=/root/$(basename $(find . -maxdepth 1 -type d -name newrelic\*)) + cd $NEWRELIC_DIRECTORY + echo "\n" | ./newrelic-install install + chown root:root $NEWRELIC_DIRECTORY/agent/x64/newrelic-${PHP_ENGINE_VERSION}.so + mv $NEWRELIC_DIRECTORY/agent/x64/newrelic-${PHP_ENGINE_VERSION}.so /usr/lib/php7/modules/newrelic.so + rm -rf $NEWRELIC_DIRECTORY/agent/x64 + # Fix permissions on extracted folder + chown -R $NOT_ROOT_USER:$NOT_ROOT_USER * + exit 0 +fi + +echo "[newrelic] arm64 detected, compiling from source: NOT CURRENTLY WORKING" +cd /root +git clone https://github.com/newrelic/newrelic-php-agent +cd newrelic-php-agent + +# Assumes apt cache is available, build-essential and phpXX-dev packages are already installed +apk add --no-cache --virtual .newrelic_deps \ + openssl-dev \ + pcre-dev \ + zlib-dev \ + zlib-static \ + curl-dev \ + automake \ + libtool \ + make + +make all +make agent-install +mv bin/daemon /usr/bin/newrelic-daemon + +mkdir -p /var/log/newrelic +chmod 777 /var/log/newrelic +cp agent/scripts/newrelic.ini.template "${CONF_PHPMODS}"/newrelic.ini + +# Cleanup script-specific packages +apk del .newrelic_deps + +# Delete compilation directory, no longer needed +rm -rf /root/newrelic-php-agent diff --git a/scripts/install-newrelic-ubuntu.sh b/scripts/install-newrelic-ubuntu.sh new file mode 100644 index 0000000..bafb008 --- /dev/null +++ b/scripts/install-newrelic-ubuntu.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +ARCH=$(archstring --x64 x64 --arm64 arm64) + +if [[ "$ARCH" == "x64" ]]; then + echo "[newrelic] x64 detected, installing pre-built packages" + + echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list + wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - + + # Prevent newrelic install from prompting for input + echo newrelic-php5 newrelic-php5/application-name string "REPLACE_NEWRELIC_APP" | debconf-set-selections + echo newrelic-php5 newrelic-php5/license-key string "REPLACE_NEWRELIC_LICENSE" | debconf-set-selections + + apt-get update + apt-get install -yqq \ + newrelic-php5 \ + newrelic-php5-common \ + newrelic-daemon + + # Removes unused agents for other PHP versions + cd /usr/lib/newrelic-php5/agent/x64 && ls | grep -v newrelic-${PHP_ENGINE_VERSION}.so | xargs rm && \ + exit 0 +fi + +echo "[newrelic] arm64 detected, compiling from source" +cd /root +git clone https://github.com/newrelic/newrelic-php-agent +cd newrelic-php-agent + +make all +make agent-install +mv bin/daemon /usr/bin/newrelic-daemon + +mkdir -p /var/log/newrelic +chmod 777 /var/log/newrelic +cp agent/scripts/newrelic.ini.template "${CONF_PHPMODS}"/newrelic.ini + +# Delete compilation directory, no longer needed +rm -rf /root/newrelic-php-agent diff --git a/container/root/usr/local/bin/pecl-install b/scripts/pecl-install.sh similarity index 100% rename from container/root/usr/local/bin/pecl-install rename to scripts/pecl-install.sh diff --git a/container/root/prep-php.sh b/scripts/prep-php.sh similarity index 96% rename from container/root/prep-php.sh rename to scripts/prep-php.sh index 8abc884..51a8caa 100644 --- a/container/root/prep-php.sh +++ b/scripts/prep-php.sh @@ -45,6 +45,9 @@ sed -i "s/^;rlimit_files =.*/rlimit_files = 40000/" $CONF_FPMPOOL # - Set max core size rlimit for the master process. sed -i "s/^;rlimit_core =.*/rlimit_core = unlimited/" $CONF_FPMPOOL +# - When logging to stdout, don't wrap the message in any way +sed -i "s/;decorate_workers_output.*/decorate_workers_output = no/" $CONF_FPMPOOL + # - Allow NewRelic to be partially configured by environment variables, set sane defaults # Enable NewRelic via Ubuntu symlinks, but disable in file. Cross-variant startup script uncomments with env vars. diff --git a/test.sh b/test.sh index 19cedcc..e7d8f23 100755 --- a/test.sh +++ b/test.sh @@ -12,7 +12,7 @@ set -o pipefail #----------------------------------------------------------------------- MACHINE=$1 -CONTAINER_PORT=8080 +INTERNAL_PORT=8080 PREFIX="==>" if [ -z "$1" ]; then @@ -32,67 +32,77 @@ DOCKERFILE_NAME="Dockerfile-${PHP_VARIANT}" # Removes suffix for -alpine variant if it has one PHP_VERSION=${PHP_VARIANT%"-alpine"} -DATE=`date '+%H-%M-%S'` -DOCKER_TAG="${PHP_VERSION}-${DATE}" -DOCKER_NAME="${VARIANT_NAME}-${DATE}" +TEST_STRING="PHP Version ${PHP_VERSION}." +PLATFORM="${PLATFORM:=linux/amd64}" + +# Since containers may or may not be against the same docker engine, create a matrix-unique tag name for outputs +TAG_NAME="docker-php-${VARIANT_NAME}-${PLATFORM}" +# Formats as lowercase +TAG_NAME=$(echo $TAG_NAME | tr '[:upper:]' '[:lower:]') +# Removes slashes +TAG_NAME=$(echo $TAG_NAME | sed 's/\///') + + +echo "${PREFIX} Variant ${VARIANT_NAME}" +echo "${PREFIX} PHP Version: ${PHP_VERSION}" +echo "${PREFIX} Dockerfile: ${DOCKERFILE_NAME}" +echo "${PREFIX} Tag ${TAG_NAME}" +echo "${PREFIX} Platform: ${PLATFORM}" + +printf "${PREFIX} Building container\n" + +docker buildx build --platform $PLATFORM --iidfile $TAG_NAME -t $TAG_NAME -f $DOCKERFILE_NAME . + +# NOTE: multi-arch builds may not be accessible by docker tag, instead target by ID +BUILD_SHA=$(cat ./$TAG_NAME) + +# Remove sha256: from tag identifier +BUILD_SHA=$(echo $BUILD_SHA | sed 's/sha256\://') + +printf "${PREFIX} Running container in background\n" +CONTAINER_ID=$(docker run --rm --platform $PLATFORM --env-file ./.test.env -p $INTERNAL_PORT -d $BUILD_SHA) +CONTAINER_PORT=$(docker inspect --format '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' $CONTAINER_ID) # ==> Cleanup routine -# CI environments are ephemeral, but local -# environments are not +# CI environments may be ephemeral, but local environments are not function finish { echo "${PREFIX} Cleaning up ephemeral resources, safe to ignore any failures" # Stop the container if it is running - docker kill $DOCKER_NAME 2>&1 > /dev/null + docker kill $CONTAINER_ID 2>&1 > /dev/null # Remove the tag if it exists - docker rmi -f $DOCKER_TAG 2>&1 > /dev/null + docker rmi -f $BUILD_SHA 2>&1 > /dev/null + rm ./$TAG_NAME } trap finish EXIT - -echo "${PREFIX} Building out variant ${VARIANT_NAME}" -echo "${PREFIX} PHP Version: ${PHP_VERSION}" -echo "${PREFIX} Dockerfile: ${DOCKERFILE_NAME}, using temporary tag ${DOCKER_TAG}" - -printf "${PREFIX} Building the container\n" -docker build -t $DOCKER_TAG -f $DOCKERFILE_NAME . - -printf "${PREFIX} Running container in background\n" -docker run \ - --name=$DOCKER_NAME \ - --env-file=./.test.env \ - -p "${CONTAINER_PORT}:${CONTAINER_PORT}" \ - -d \ - -t "${DOCKER_TAG}:latest" - printf "${PREFIX} Waiting for container to boot\n" sleep 5 echo "${PREFIX} Check default response, including PHP version identification" -curl "${MACHINE}:${CONTAINER_PORT}" | grep "PHP Version ${PHP_VERSION}." +curl "${MACHINE}:${CONTAINER_PORT}" | grep "${TEST_STRING}" echo "${PREFIX} Create a random file to upload" dd if=/dev/zero of=tmp.txt count=100000 bs=1024 echo "${PREFIX} Send uploaded file" curl --form upload=@tmp.txt "${MACHINE}:${CONTAINER_PORT}" \ - | grep "PHP Version ${PHP_VERSION}." > /dev/null + | grep "${TEST_STRING}" > /dev/null echo "${PREFIX} Perform startup tests" GOSS_PATH=goss \ GOSS_SLEEP=5 \ GOSS_FILES_PATH="runtime-tests/startup/${PHP_VARIANT}/" \ -./dgoss run \ - "${DOCKER_TAG}:latest" +"${GOSS_INSTALL_PATH}dgoss" run --rm $BUILD_SHA echo "${PREFIX} Perform NewRelic runtime tests" GOSS_PATH=goss \ GOSS_FILES_PATH="runtime-tests/newrelic/${PHP_VARIANT}/" \ -./dgoss run \ +"${GOSS_INSTALL_PATH}dgoss" run \ -e REPLACE_NEWRELIC_APP="abcdefg" \ -e REPLACE_NEWRELIC_LICENSE="hijklmno" \ -e NEWRELIC_TRACING_ENABLED="true" \ -e NEWRELIC_LOGLEVEL="verbosedebug" \ -e NEWRELIC_SPECIAL="debug_autorum" \ - "${DOCKER_TAG}:latest" + $BUILD_SHA