diff --git a/Makefile b/Makefile index 224f2ce7..07695f71 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,80 @@ SHELL := /bin/bash layer ?= * +cpu ?= x86 resolve_php_versions = $(or $(php_versions),`jq -r '.php | join(" ")' ${1}/config.json`) +makefile_path = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +get_cpu_types = `jq -r '.cpu | join(" ")' ${makefile_path}${1}/config.json` +resolve_cpu_types = $(or $(cpu),`jq -r '.cpu | join(" ")' ${makefile_path}${1}/config.json`) resolve_tags = `./new-docker-tags.php $(DOCKER_TAG)` BREF_VERSION = 2 define build_docker_image - docker build -t bref/${1}-php-${2} --build-arg PHP_VERSION=${2} --build-arg BREF_VERSION=${BREF_VERSION} ${DOCKER_BUILD_FLAGS} ${1} + docker build -t bref/${1}-${4}php-${2} --build-arg CPU_PREFIX=${3} --build-arg PHP_VERSION=${2} --build-arg BREF_VERSION=${BREF_VERSION} ${DOCKER_BUILD_FLAGS} ${1} endef docker-images: if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi set -e; \ for dir in layers/${layer}; do \ - for php_version in $(call resolve_php_versions,$${dir}); do \ - echo "###############################################"; \ - echo "###############################################"; \ - echo "### Building $${dir} PHP$${php_version}"; \ - echo "###"; \ - $(call build_docker_image,$${dir},$${php_version}) ; \ - echo ""; \ + for cpu_type in $(call resolve_cpu_types,$${dir}); do \ + if [ "${layer}" = "*" ] && [[ "$(call get_cpu_types,$${dir})" != *"$${cpu_type}"* ]]; then \ + echo "###############################################"; \ + echo "️! Skip - $${dir} no $${cpu_type} support"; \ + echo ""; \ + break ; \ + fi; \ + for php_version in $(call resolve_php_versions,$${dir}); do \ + if [[ "$${cpu_type}" = "arm" ]] ; then \ + cpu_prefix="arm-"; \ + docker_prefix="arm-"; \ + archive_prefix="arm-"; \ + else \ + cpu_prefix=""; \ + docker_prefix=""; \ + archive_prefix=""; \ + fi; \ + echo "###############################################"; \ + echo "###############################################"; \ + echo "### Building $${dir} CPU: $${cpu_type} PHP: $${php_version} "; \ + echo "###"; \ + $(call build_docker_image,$${dir},$${php_version},$${cpu_prefix},$${docker_prefix}) ; \ + echo ""; \ + done \ done \ - done + done; test: docker-images if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi set -e; \ for dir in layers/${layer}; do \ - for php_version in $(call resolve_php_versions,$${dir}); do \ - echo "###############################################"; \ - echo "###############################################"; \ - echo "### Testing $${dir} PHP$${php_version}"; \ - echo "###"; \ - docker build --build-arg PHP_VERSION=$${php_version} --build-arg TARGET_IMAGE=$${dir}-php-$${php_version} -t bref/test-$${dir}-$${php_version} tests ; \ - docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${php_version} /opt/bin/php /var/task/test.php ; \ - if docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${php_version} /opt/bin/php -v 2>&1 >/dev/null | grep -q 'Unable\|Warning'; then exit 1; fi ; \ - echo ""; \ - echo " - Test passed"; \ - echo ""; \ + for cpu_type in $(call resolve_cpu_types,$${dir}); do \ + if [ "${layer}" = "*" ] && [[ "$(call get_cpu_types,$${dir})" != *"$${cpu_type}"* ]]; then \ + echo "###############################################"; \ + echo "️! Skip - $${dir} no $${cpu_type} support"; \ + echo ""; \ + break ; \ + fi; \ + for php_version in $(call resolve_php_versions,$${dir}); do \ + if [[ "$${cpu_type}" = "arm" ]] ; then \ + cpu_prefix="arm-"; \ + docker_prefix="arm-"; \ + archive_prefix="arm-"; \ + else \ + cpu_prefix=""; \ + docker_prefix=""; \ + archive_prefix=""; \ + fi; \ + echo "###############################################"; \ + echo "###############################################"; \ + echo "### Testing $${dir} CPU: $${cpu_type} PHP: $${php_version} "; \ + echo "###"; \ + docker build --build-arg CPU_PREFIX=$${cpu_prefix} --build-arg PHP_VERSION=$${php_version} --build-arg BREF_VERSION=${BREF_VERSION} --build-arg TARGET_IMAGE=$${dir}-$${docker_prefix}php-$${php_version} -t bref/test-$${dir}-$${cpu_prefix}$${php_version} tests ; \ + docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${cpu_prefix}$${php_version} /opt/bin/php /var/task/test.php ; \ + if docker run --entrypoint= --rm -v $$(pwd)/$${dir}:/var/task bref/test-$${dir}-$${cpu_prefix}$${php_version} /opt/bin/php -v 2>&1 >/dev/null | grep -q 'Unable\|Warning'; then exit 1; fi ; \ + echo ""; \ + echo " - Test passed"; \ + echo ""; \ + done \ done \ done; @@ -44,24 +82,41 @@ test: docker-images layers: docker-images if [ "${layer}" != "*" ]; then test -d layers/${layer}; fi PWD=pwd - rm -rf export/layer-${layer}.zip || true + rm -rf export/${archive_prefix}layer-${layer}.zip || true mkdir -p export/tmp set -e; \ for dir in layers/${layer}; do \ - for php_version in $(call resolve_php_versions,${PWD}/$${dir}); do \ - echo "###############################################"; \ - echo "###############################################"; \ - echo "### Exporting $${dir} PHP$${php_version}"; \ - echo "###"; \ - cd ${PWD} ; rm -rf export/tmp/${layer} || true ; cd export/tmp ; \ - CID=$$(docker create --entrypoint=scratch bref/$${dir}-php-$${php_version}) ; \ - docker cp $${CID}:/opt . ; \ - docker rm $${CID} ; \ - cd ./opt ; \ - zip --quiet -X --recurse-paths ../../`echo "$${dir}-php-$${php_version}" | sed -e "s/layers\//layer-/g"`.zip . ; \ - echo ""; \ + for cpu_type in $(call resolve_cpu_types,$${dir}); do \ + if [ "${layer}" = "*" ] && [[ "$(call get_cpu_types,$${dir})" != *"$${cpu_type}"* ]]; then \ + echo "###############################################"; \ + echo "️! Skip - $${dir} no $${cpu_type} support"; \ + echo ""; \ + break ; \ + fi; \ + for php_version in $(call resolve_php_versions,${PWD}/$${dir}); do \ + if [[ "$${cpu_type}" = "arm" ]] ; then \ + cpu_prefix="arm-"; \ + docker_prefix="arm-"; \ + archive_prefix="arm-"; \ + else \ + cpu_prefix=""; \ + docker_prefix=""; \ + archive_prefix=""; \ + fi; \ + echo "###############################################"; \ + echo "###############################################"; \ + echo "### Exporting $${dir} CPU: $${cpu_type} PHP: $${php_version} "; \ + echo "###"; \ + cd ${PWD} ; rm -rf export/tmp/${layer} || true ; cd export/tmp ; \ + CID=$$(docker create --entrypoint=scratch bref/$${dir}-$${docker_prefix}php-$${php_version}) ; \ + docker cp $${CID}:/opt . ; \ + docker rm $${CID} ; \ + cd ./opt ; \ + zip --quiet -X --recurse-paths ../../`echo "$${dir}-$${archive_prefix}php-$${php_version}" | sed -e "s/layers\//layer-/g"`.zip . ; \ + echo ""; \ + done \ done \ - done + done; rm -rf export/tmp clean: @@ -74,28 +129,45 @@ publish: layers # Publish docker images publish-docker-images: docker-images for dir in layers/${layer}; do \ - for php_version in $(call resolve_php_versions,$${dir}); do \ - echo "###############################################"; \ - echo "###############################################"; \ - echo "### Publishing $${dir} PHP$${php_version}"; \ - echo "###"; \ - privateImage="bref/$${dir}-php-$${php_version}"; \ - publicImage=$${privateImage/layers\//extra-}; \ - echo "Image name: $$publicImage"; \ - echo ""; \ - echo "docker push $$publicImage:latest"; \ - docker tag $$privateImage:latest $$publicImage:latest; \ - docker push $$publicImage:latest; \ - if (test $(DOCKER_TAG)); then \ - echo "Pushing tagged images"; \ - for tag in $(call resolve_tags); do \ - echo ""; \ - echo "docker push $$publicImage:$${tag}"; \ - docker tag $$privateImage:latest $$publicImage:$${tag}; \ - docker push $$publicImage:$${tag}; \ - done; \ + for cpu_type in $(call resolve_cpu_types,$${dir}); do \ + if [ "${layer}" = "*" ] && [[ "$(call get_cpu_types,$${dir})" != *"$${cpu_type}"* ]]; then \ + echo "###############################################"; \ + echo "️! Skip - $${dir} no $${cpu_type} support"; \ + echo ""; \ + break ; \ fi; \ - echo ""; \ + for php_version in $(call resolve_php_versions,$${dir}); do \ + if [[ "$${cpu_type}" = "arm" ]] ; then \ + cpu_prefix="arm-"; \ + docker_prefix="arm-"; \ + archive_prefix="arm-"; \ + else \ + cpu_prefix=""; \ + docker_prefix=""; \ + archive_prefix=""; \ + fi; \ + echo "###############################################"; \ + echo "###############################################"; \ + echo "### Publishing $${dir} CPU: $${cpu_type} PHP: $${php_version} "; \ + echo "###"; \ + privateImage="bref/$${dir}-$${docker_prefix}php-$${php_version}"; \ + publicImage=$${privateImage/layers\//extra-}; \ + echo "Image name: $$publicImage"; \ + echo ""; \ + echo "docker push $$publicImage:latest"; \ + docker tag $$privateImage:latest $$publicImage:latest; \ + docker push $$publicImage:latest; \ + if (test $(DOCKER_TAG)); then \ + echo "Pushing tagged images"; \ + for tag in $(call resolve_tags); do \ + echo ""; \ + echo "docker push $$publicImage:$${tag}"; \ + docker tag $$privateImage:latest $$publicImage:$${tag}; \ + docker push $$publicImage:$${tag}; \ + done; \ + fi; \ + echo ""; \ + done \ done \ - done + done; diff --git a/layers/amqp/Dockerfile b/layers/amqp/Dockerfile index 711a4dba..9f94c73d 100644 --- a/layers/amqp/Dockerfile +++ b/layers/amqp/Dockerfile @@ -1,25 +1,26 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext -ARG PHP_VERSION +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LIBRABBITMQ_BUILD_DIR=${BUILD_DIR}/librabbitmq RUN set -xe; \ mkdir -p ${LIBRABBITMQ_BUILD_DIR}; \ - # Download and upack the source code - curl -Ls https://github.com/alanxz/rabbitmq-c/archive/v0.9.0.tar.gz \ + # Download and unpack the source code + curl -Ls https://github.com/alanxz/rabbitmq-c/archive/refs/tags/v0.13.0.tar.gz \ | tar xzC ${LIBRABBITMQ_BUILD_DIR} # Move into the unpackaged code directory -WORKDIR ${LIBRABBITMQ_BUILD_DIR}/rabbitmq-c-0.9.0/ +WORKDIR ${LIBRABBITMQ_BUILD_DIR}/rabbitmq-c-0.13.0/ # Install RUN set -xe; \ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} . && \ cmake --build . --target install -RUN if [[ "$PHP_VERSION" = "80" ]] ; then pecl install amqp-1.11.0beta ; else pecl install amqp ; fi +#RUN if [[ "$PHP_VERSION" = "80" ]] ; then pecl install amqp-1.11.0beta ; else pecl install amqp ; fi +RUN pecl install amqp RUN cp `php-config --extension-dir`/amqp.so /tmp/amqp.so RUN echo 'extension=amqp.so' > /tmp/ext.ini diff --git a/layers/amqp/config.json b/layers/amqp/config.json index a5a35316..9a323d9b 100644 --- a/layers/amqp/config.json +++ b/layers/amqp/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/amqp/test.php b/layers/amqp/test.php index 2a507e9f..c1be1315 100644 --- a/layers/amqp/test.php +++ b/layers/amqp/test.php @@ -1,7 +1,7 @@ /dev/null RUN cp `php-config --extension-dir`/grpc.so /tmp/grpc.so diff --git a/layers/grpc/config.json b/layers/grpc/config.json index a5a35316..9a323d9b 100644 --- a/layers/grpc/config.json +++ b/layers/grpc/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/igbinary/Dockerfile b/layers/igbinary/Dockerfile index ec735e07..d8f80a80 100644 --- a/layers/igbinary/Dockerfile +++ b/layers/igbinary/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install igbinary RUN cp `php-config --extension-dir`/igbinary.so /tmp/igbinary.so diff --git a/layers/igbinary/config.json b/layers/igbinary/config.json index a5a35316..9a323d9b 100644 --- a/layers/igbinary/config.json +++ b/layers/igbinary/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/imagick/Dockerfile b/layers/imagick/Dockerfile index bc12eb56..80cfcd78 100644 --- a/layers/imagick/Dockerfile +++ b/layers/imagick/Dockerfile @@ -1,7 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext -ARG PHP_VERSION +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext # Prepare environment ENV IMAGICK_BUILD_DIR=${BUILD_DIR}/imagick diff --git a/layers/imagick/config.json b/layers/imagick/config.json index a5a35316..9a323d9b 100644 --- a/layers/imagick/config.json +++ b/layers/imagick/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/imap/Dockerfile b/layers/imap/Dockerfile index c5deed2f..e260b116 100644 --- a/layers/imap/Dockerfile +++ b/layers/imap/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN LD_LIBRARY_PATH=/lib:/lib64 yum -y install amazon-linux-extras RUN LD_LIBRARY_PATH=/lib:/lib64 amazon-linux-extras install epel -y diff --git a/layers/imap/config.json b/layers/imap/config.json index 1cb68767..9a323d9b 100644 --- a/layers/imap/config.json +++ b/layers/imap/config.json @@ -1,6 +1,11 @@ { "php": [ + "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/ldap/Dockerfile b/layers/ldap/Dockerfile index 58f23f8a..3cbf83b4 100644 --- a/layers/ldap/Dockerfile +++ b/layers/ldap/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib64:$LD_LIBRARY_PATH diff --git a/layers/ldap/config.json b/layers/ldap/config.json index a5a35316..9a323d9b 100644 --- a/layers/ldap/config.json +++ b/layers/ldap/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/mailparse/Dockerfile b/layers/mailparse/Dockerfile index f2961563..b58d922c 100644 --- a/layers/mailparse/Dockerfile +++ b/layers/mailparse/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib64:$LD_LIBRARY_PATH RUN yum install -y re2c diff --git a/layers/mailparse/config.json b/layers/mailparse/config.json index a5a35316..9a323d9b 100644 --- a/layers/mailparse/config.json +++ b/layers/mailparse/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/maxminddb/Dockerfile b/layers/maxminddb/Dockerfile index f79f856d..745bb8a6 100644 --- a/layers/maxminddb/Dockerfile +++ b/layers/maxminddb/Dockerfile @@ -1,7 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext -ARG PHP_VERSION +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext # Install libmaxminddb ENV LIBMAXMINDDB_BUILD_DIR=${BUILD_DIR}/libmaxminddb diff --git a/layers/maxminddb/config.json b/layers/maxminddb/config.json index a5a35316..9a323d9b 100644 --- a/layers/maxminddb/config.json +++ b/layers/maxminddb/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/memcache/Dockerfile b/layers/memcache/Dockerfile index 884f40d8..31a54c5d 100644 --- a/layers/memcache/Dockerfile +++ b/layers/memcache/Dockerfile @@ -1,7 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext -ARG PHP_VERSION +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LIBMEMCACHED_BUILD_DIR=${BUILD_DIR}/libmemcached diff --git a/layers/memcache/config.json b/layers/memcache/config.json index d293785a..9a323d9b 100644 --- a/layers/memcache/config.json +++ b/layers/memcache/config.json @@ -1,5 +1,11 @@ { "php": [ - "80" + "80", + "81", + "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/memcached/Dockerfile b/layers/memcached/Dockerfile index 433cf8e9..9501a27a 100644 --- a/layers/memcached/Dockerfile +++ b/layers/memcached/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LIBMEMCACHED_BUILD_DIR=${BUILD_DIR}/libmemcached diff --git a/layers/memcached/config.json b/layers/memcached/config.json index a5a35316..9a323d9b 100644 --- a/layers/memcached/config.json +++ b/layers/memcached/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/mongodb/Dockerfile b/layers/mongodb/Dockerfile index 28c58648..6b35059d 100644 --- a/layers/mongodb/Dockerfile +++ b/layers/mongodb/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install --force mongodb RUN cp `php-config --extension-dir`/mongodb.so /tmp/mongodb.so diff --git a/layers/mongodb/config.json b/layers/mongodb/config.json index a5a35316..9a323d9b 100644 --- a/layers/mongodb/config.json +++ b/layers/mongodb/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/msgpack/Dockerfile b/layers/msgpack/Dockerfile index 95fad4be..6041bcdd 100644 --- a/layers/msgpack/Dockerfile +++ b/layers/msgpack/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install msgpack RUN cp `php-config --extension-dir`/msgpack.so /tmp/msgpack.so diff --git a/layers/msgpack/config.json b/layers/msgpack/config.json index a5a35316..9a323d9b 100644 --- a/layers/msgpack/config.json +++ b/layers/msgpack/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/newrelic/Dockerfile b/layers/newrelic/Dockerfile index 99c3ea29..bf8ba221 100644 --- a/layers/newrelic/Dockerfile +++ b/layers/newrelic/Dockerfile @@ -1,29 +1,45 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext -# Build the New Relic Agent - install silently -ARG NEWRELIC_VERSION=10.7.0.319 -RUN \ - curl -L https://download.newrelic.com/php_agent/archive/${NEWRELIC_VERSION}/newrelic-php5-${NEWRELIC_VERSION}-linux.tar.gz | tar -C /tmp -zx && \ - export NR_INSTALL_USE_CP_NOT_LN=1 && \ - export NR_INSTALL_SILENT=1 && \ - /tmp/newrelic-php5-*/newrelic-install install && \ - rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* +ARG NEWRELIC_VERSION=10.9.0.324 -# newrelic.so will be installed to `php-config --extension-dir`/newrelic.so -# In this core image newrelic.ini will be placed but not exist in the scatch layer -# ${INSTALL_DIR}/etc/php/php.ini /tmp/php.ini - php.ini will contain the needed config and extension ref +ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib64:$LD_LIBRARY_PATH +ENV RELIC_BUILD_DIR=${BUILD_DIR}/relic +RUN mkdir -p ${RELIC_BUILD_DIR} +WORKDIR ${RELIC_BUILD_DIR} -# Copy the newrelic.so and php.ini file to the tmp folder +RUN yum update -y && \ + yum install -y git \ + amazon-linux-extras \ + libcurl-devel \ + openssl-devel \ + openssl-static \ + pcre-devel \ + pcre-static \ + zlib-devel \ + zlib-static -RUN cp `php -i | grep extension_dir | sed 's/^.*=> \(.*\)$/\1/' | head -1`/newrelic.so /tmp/newrelic.so -RUN echo 'extension=newrelic.so' > /tmp/newrelic.ini +RUN amazon-linux-extras install -y epel +RUN amazon-linux-extras install -y golang1.11 -# Build the final image from the scratch image that contain files you want to export +RUN git clone https://github.com/newrelic/newrelic-php-agent.git . \ + && git reset --hard v${NEWRELIC_VERSION} + +RUN make \ + && make agent-install + +RUN cp `php-config --extension-dir`/newrelic.so /tmp/newrelic.so +RUN echo 'extension=newrelic.so' > /tmp/ext.ini + +RUN php /bref/lib-copy/copy-dependencies.php /tmp/newrelic.so /tmp/extension-libs + +## Build the final image from the scratch image that contain files you want to export FROM scratch # Copy the two key files to the correct location for the empty layer. # newrelic.so should become a layered extension. COPY --from=ext /tmp/newrelic.so /opt/bref/extensions/newrelic.so -COPY --from=ext /tmp/newrelic.ini /opt/bref/etc/php/conf.d/ext-newrelic.ini +COPY --from=ext /tmp/ext.ini /opt/bref/etc/php/conf.d/ext-newrelic.ini +COPY --from=ext /tmp/extension-libs /opt/lib diff --git a/layers/newrelic/config.json b/layers/newrelic/config.json index a5a35316..9a323d9b 100644 --- a/layers/newrelic/config.json +++ b/layers/newrelic/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/newrelic/test.php b/layers/newrelic/test.php index 052019c3..392c3b29 100644 --- a/layers/newrelic/test.php +++ b/layers/newrelic/test.php @@ -1,7 +1,7 @@ /tmp/ext.ini - RUN php /bref/lib-copy/copy-dependencies.php /tmp/oci8.so /tmp/extension-libs - # Build the final image from the scratch image that contain files you want to export FROM scratch diff --git a/layers/oci8/config.json b/layers/oci8/config.json index a5a35316..9a323d9b 100644 --- a/layers/oci8/config.json +++ b/layers/oci8/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/oci8/install.sh b/layers/oci8/install.sh new file mode 100644 index 00000000..2c93bcfb --- /dev/null +++ b/layers/oci8/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +arch=$(arch | sed s/_/-/g) +php_version=$(php-config --version | cut -c -3) + +if [[ $arch = "aarch64" ]]; then + # Download client + curl -o oci-basic.zip https://download.oracle.com/otn_software/linux/instantclient/191000/instantclient-basiclite-linux.arm64-19.10.0.0.0dbru-2.zip + unzip oci-basic.zip -d src + + # Download client sdk + curl -o oci-sdk.zip https://download.oracle.com/otn_software/linux/instantclient/191000/instantclient-sdk-linux.arm64-19.10.0.0.0dbru.zip + unzip oci-sdk.zip -d src + + # Install + if [ "$php_version" = "8.0" ] ; then \ + echo "instantclient,${ORACLE_BUILD_DIR}/src/instantclient_19_10" | pecl install oci8-3.0.1; \ + else \ + echo "instantclient,${ORACLE_BUILD_DIR}/src/instantclient_19_10" | pecl install oci8; \ + fi +else + # Download client + curl -o oci-basic.zip https://download.oracle.com/otn_software/linux/instantclient/215000/instantclient-basiclite-linux.x64-21.5.0.0.0dbru.zip + unzip oci-basic.zip -d src + + # Download client sdk + curl -o oci-sdk.zip https://download.oracle.com/otn_software/linux/instantclient/215000/instantclient-sdk-linux.x64-21.5.0.0.0dbru.zip + unzip oci-sdk.zip -d src + + # Install + if [ "$php_version" = "8.0" ] ; then \ + echo "instantclient,${ORACLE_BUILD_DIR}/src/instantclient_21_5" | pecl install oci8-3.0.1; \ + else \ + echo "instantclient,${ORACLE_BUILD_DIR}/src/instantclient_21_5" | pecl install oci8; \ + fi +fi diff --git a/layers/oci8/test.php b/layers/oci8/test.php index b06fbfad..f207414e 100644 --- a/layers/oci8/test.php +++ b/layers/oci8/test.php @@ -1,7 +1,7 @@ /tmp/ext.ini diff --git a/layers/openswoole/config.json b/layers/openswoole/config.json index 782b4264..9a323d9b 100644 --- a/layers/openswoole/config.json +++ b/layers/openswoole/config.json @@ -1,6 +1,11 @@ { "php": [ "80", - "81" + "81", + "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/pcov/Dockerfile b/layers/pcov/Dockerfile index 8e6d7842..58f4b90e 100644 --- a/layers/pcov/Dockerfile +++ b/layers/pcov/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install pcov RUN cp `php-config --extension-dir`/pcov.so /tmp/pcov.so diff --git a/layers/pcov/config.json b/layers/pcov/config.json index a5a35316..9a323d9b 100644 --- a/layers/pcov/config.json +++ b/layers/pcov/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/pgsql/Dockerfile b/layers/pgsql/Dockerfile index 9a3655a5..e3c7087d 100644 --- a/layers/pgsql/Dockerfile +++ b/layers/pgsql/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext WORKDIR ${PHP_BUILD_DIR}/ext/pgsql RUN phpize diff --git a/layers/pgsql/config.json b/layers/pgsql/config.json index a5a35316..9a323d9b 100644 --- a/layers/pgsql/config.json +++ b/layers/pgsql/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/rdkafka/Dockerfile b/layers/rdkafka/Dockerfile index b0aceaa9..80630dcf 100644 --- a/layers/rdkafka/Dockerfile +++ b/layers/rdkafka/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ENV LIBRDKAFKA_BUILD_DIR=${BUILD_DIR}/librdkafka diff --git a/layers/rdkafka/config.json b/layers/rdkafka/config.json index a5a35316..9a323d9b 100644 --- a/layers/rdkafka/config.json +++ b/layers/rdkafka/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/redis-igbinary/Dockerfile b/layers/redis-igbinary/Dockerfile index 7ec26926..a0b38301 100644 --- a/layers/redis-igbinary/Dockerfile +++ b/layers/redis-igbinary/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install igbinary && \ pecl install -D 'enable-redis-igbinary="yes"' redis && \ diff --git a/layers/redis-igbinary/config.json b/layers/redis-igbinary/config.json index a5a35316..9a323d9b 100644 --- a/layers/redis-igbinary/config.json +++ b/layers/redis-igbinary/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/redis/Dockerfile b/layers/redis/Dockerfile index e9a03710..befc2175 100644 --- a/layers/redis/Dockerfile +++ b/layers/redis/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install --force redis RUN cp `php-config --extension-dir`/redis.so /tmp/redis.so diff --git a/layers/redis/config.json b/layers/redis/config.json index a5a35316..9a323d9b 100644 --- a/layers/redis/config.json +++ b/layers/redis/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/relay/Dockerfile b/layers/relay/Dockerfile index d525392e..294d703d 100644 --- a/layers/relay/Dockerfile +++ b/layers/relay/Dockerfile @@ -1,12 +1,18 @@ # syntax = docker/dockerfile:1.4 +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:2 AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ARG RELAY_VERSION=0.6.0 +ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib64:$LD_LIBRARY_PATH + # Docs: https://relay.so/docs/1.x/installation#manual-installation +# Added openssl11-libs +RUN yum install -y openssl11-libs + # Install extensions required by Relay RUN pecl install igbinary msgpack && \ cp `php-config --extension-dir`/igbinary.so /tmp/igbinary.so && \ @@ -27,8 +33,9 @@ END RUN <<'END' bash -e export php_version=$(php-config --version | cut -c -3) + export arch=$(arch | sed s/_/-/g) mkdir -p /tmp/relay - curl -sSL "https://builds.r2.relay.so/v$RELAY_VERSION/relay-v$RELAY_VERSION-php$php_version-centos7-x86-64.tar.gz" | tar -xz --strip-components=1 -C /tmp/relay + curl -sSL "https://builds.r2.relay.so/v$RELAY_VERSION/relay-v$RELAY_VERSION-php$php_version-centos7-$arch.tar.gz" | tar -xz --strip-components=1 -C /tmp/relay sed -i "s/00000000-0000-0000-0000-000000000000/$(cat /proc/sys/kernel/random/uuid)/" /tmp/relay/relay-pkg.so cp /tmp/relay/relay-pkg.so /tmp/relay.so echo 'extension=relay.so' > /tmp/ext-relay.ini diff --git a/layers/relay/config.json b/layers/relay/config.json index a5a35316..9a323d9b 100644 --- a/layers/relay/config.json +++ b/layers/relay/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/relay/test.php b/layers/relay/test.php index a0b83bc9..69f2374e 100644 --- a/layers/relay/test.php +++ b/layers/relay/test.php @@ -1,7 +1,7 @@ /tmp/ext.ini diff --git a/layers/scoutapm/config.json b/layers/scoutapm/config.json index a5a35316..9a323d9b 100644 --- a/layers/scoutapm/config.json +++ b/layers/scoutapm/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/scrypt/Dockerfile b/layers/scrypt/Dockerfile index 1e44b3b0..789a0a88 100644 --- a/layers/scrypt/Dockerfile +++ b/layers/scrypt/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN pecl install scrypt RUN cp `php-config --extension-dir`/scrypt.so /tmp/scrypt.so diff --git a/layers/scrypt/config.json b/layers/scrypt/config.json index d293785a..9a323d9b 100644 --- a/layers/scrypt/config.json +++ b/layers/scrypt/config.json @@ -1,5 +1,11 @@ { "php": [ - "80" + "80", + "81", + "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/spx/Dockerfile b/layers/spx/Dockerfile index 05e6771b..14ac5f87 100644 --- a/layers/spx/Dockerfile +++ b/layers/spx/Dockerfile @@ -1,10 +1,11 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN git clone https://github.com/NoiseByNorthwest/php-spx.git \ && cd php-spx \ - && git reset --hard v0.4.10 \ + && git reset --hard v0.4.13 \ && phpize \ && ./configure --prefix ${INSTALL_DIR} --exec-prefix ${INSTALL_DIR} \ && make -j $(nproc) \ diff --git a/layers/spx/config.json b/layers/spx/config.json index d293785a..9a323d9b 100644 --- a/layers/spx/config.json +++ b/layers/spx/config.json @@ -1,5 +1,11 @@ { "php": [ - "80" + "80", + "81", + "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/spx/test.php b/layers/spx/test.php index 393ca87d..24a043d1 100644 --- a/layers/spx/test.php +++ b/layers/spx/test.php @@ -1,7 +1,7 @@ 1])) { foreach (sqlsrv_errors() as $error) { if ($error['SQLSTATE'] == '01000') { - echo sprintf('FAIL: sqlsrv extension library not loaded. %s', $error['message']).PHP_EOL; + echo sprintf('FAIL: sqlsrv extension library not loaded. %s', $error['message']) . PHP_EOL; exit(1); } } diff --git a/layers/ssh2/Dockerfile b/layers/ssh2/Dockerfile index 9f10515e..1faf0c96 100644 --- a/layers/ssh2/Dockerfile +++ b/layers/ssh2/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN LD_LIBRARY_PATH=/lib64:/lib yum install -y libssh2 libssh2-devel RUN pecl install ssh2-beta diff --git a/layers/ssh2/config.json b/layers/ssh2/config.json index a5a35316..9a323d9b 100644 --- a/layers/ssh2/config.json +++ b/layers/ssh2/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/swoole/Dockerfile b/layers/swoole/Dockerfile index 335b6628..cfac3114 100644 --- a/layers/swoole/Dockerfile +++ b/layers/swoole/Dockerfile @@ -1,6 +1,7 @@ +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext RUN set -ex && \ LD_LIBRARY_PATH=/lib64:/lib yum install -y libcurl-devel openssl-devel && \ diff --git a/layers/swoole/config.json b/layers/swoole/config.json index a5a35316..9a323d9b 100644 --- a/layers/swoole/config.json +++ b/layers/swoole/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/symfony-runtime/config.json b/layers/symfony-runtime/config.json index a5a35316..9a323d9b 100644 --- a/layers/symfony-runtime/config.json +++ b/layers/symfony-runtime/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/tideways/Dockerfile b/layers/tideways/Dockerfile index ff46bbc0..024642a6 100644 --- a/layers/tideways/Dockerfile +++ b/layers/tideways/Dockerfile @@ -1,7 +1,8 @@ # syntax = docker/dockerfile:1.4 +ARG CPU_PREFIX ARG PHP_VERSION ARG BREF_VERSION -FROM bref/build-php-$PHP_VERSION:$BREF_VERSION AS ext +FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION:$BREF_VERSION AS ext ARG TIDEWAYS_VERSION=5.5.14 # Versions: https://tideways.com/profiler/downloads @@ -11,7 +12,12 @@ RUN <<'END' bash -e mkdir -p /tmp/tideways cd /tmp/tideways export version=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;") - curl -sSL "https://s3-eu-west-1.amazonaws.com/tideways/extension/${TIDEWAYS_VERSION}/tideways-php-${TIDEWAYS_VERSION}-x86_64.tar.gz" | tar -xz --strip-components=2 -C /tmp/tideways + export arch=$(arch | sed s/_/-/g) + if [ "$arch" = "aarch64" ] ; then + curl -sSL "https://s3-eu-west-1.amazonaws.com/tideways/extension/${TIDEWAYS_VERSION}/tideways-php-${TIDEWAYS_VERSION}-arm64.tar.gz" | tar -xz --strip-components=2 -C /tmp/tideways ; + else + curl -sSL "https://s3-eu-west-1.amazonaws.com/tideways/extension/${TIDEWAYS_VERSION}/tideways-php-${TIDEWAYS_VERSION}-x86_64.tar.gz" | tar -xz --strip-components=2 -C /tmp/tideways ; + fi cp /tmp/tideways/tideways-php-${version}.so /tmp/tideways.so echo 'extension=tideways.so' > /tmp/ext-tideways.ini END diff --git a/layers/tideways/config.json b/layers/tideways/config.json index a5a35316..9a323d9b 100644 --- a/layers/tideways/config.json +++ b/layers/tideways/config.json @@ -3,5 +3,9 @@ "80", "81", "82" + ], + "cpu": [ + "x86", + "arm" ] } diff --git a/layers/tideways/test.php b/layers/tideways/test.php index 98acffe3..2c017c6c 100644 --- a/layers/tideways/test.php +++ b/layers/tideways/test.php @@ -1,7 +1,7 @@