From b79385fb470689c4658cdeeebfa66831eb10daef Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Wed, 21 Apr 2021 11:40:08 +0300 Subject: [PATCH 1/4] Allow define custom repository for image build --- environments/includes/elasticsearch.base.yml | 2 +- images/php-fpm/Dockerfile | 5 +- images/php-fpm/blackfire/Dockerfile | 5 +- images/php-fpm/debug/Dockerfile | 5 +- images/php-fpm/magento1/Dockerfile | 3 +- images/php-fpm/magento1/blackfire/Dockerfile | 3 +- images/php-fpm/magento1/debug/Dockerfile | 3 +- images/php-fpm/magento1/xdebug3/Dockerfile | 5 +- images/php-fpm/magento2/Dockerfile | 3 +- images/php-fpm/magento2/blackfire/Dockerfile | 3 +- images/php-fpm/magento2/debug/Dockerfile | 3 +- images/php-fpm/magento2/xdebug3/Dockerfile | 5 +- images/php-fpm/xdebug3/Dockerfile | 5 +- images/scripts/build.sh | 98 +++++++++++--------- 14 files changed, 84 insertions(+), 64 deletions(-) diff --git a/environments/includes/elasticsearch.base.yml b/environments/includes/elasticsearch.base.yml index cf502240..3e3f670a 100644 --- a/environments/includes/elasticsearch.base.yml +++ b/environments/includes/elasticsearch.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: elasticsearch: hostname: "${WARDEN_ENV_NAME}-elasticsearch" - image: docker.io/wardenenv/elasticsearch:${ELASTICSEARCH_VERSION:-7.8} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/elasticsearch:${ELASTICSEARCH_VERSION:-7.8} labels: - traefik.enable=true - traefik.http.routers.${WARDEN_ENV_NAME}-elasticsearch.tls=true diff --git a/images/php-fpm/Dockerfile b/images/php-fpm/Dockerfile index 5b3ede13..a7b7cf9d 100644 --- a/images/php-fpm/Dockerfile +++ b/images/php-fpm/Dockerfile @@ -1,6 +1,7 @@ -ARG PHP_VERSION= +ARG PHP_SOURCE_IMAGE="davidalger/php" +ARG PHP_VERSION ARG PHP_VARIANT="fpm-loaders" -FROM davidalger/php:${PHP_VERSION}-${PHP_VARIANT} +FROM ${PHP_SOURCE_IMAGE}:${PHP_VERSION}-${PHP_VARIANT} # Clear undesired settings from base fpm images ENV COMPOSER_ALLOW_SUPERUSER= diff --git a/images/php-fpm/blackfire/Dockerfile b/images/php-fpm/blackfire/Dockerfile index 20a499a4..a67bb253 100644 --- a/images/php-fpm/blackfire/Dockerfile +++ b/images/php-fpm/blackfire/Dockerfile @@ -1,5 +1,6 @@ -ARG PHP_VERSION= -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" +ARG PHP_VERSION +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION} USER root RUN curl -o - "http://packages.blackfire.io/fedora/blackfire.repo" \ diff --git a/images/php-fpm/debug/Dockerfile b/images/php-fpm/debug/Dockerfile index 580c65d6..c64e144d 100644 --- a/images/php-fpm/debug/Dockerfile +++ b/images/php-fpm/debug/Dockerfile @@ -1,5 +1,6 @@ -ARG PHP_VERSION= -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" +ARG PHP_VERSION +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION} USER root RUN set -eux \ diff --git a/images/php-fpm/magento1/Dockerfile b/images/php-fpm/magento1/Dockerfile index 518370fa..d24d99f4 100644 --- a/images/php-fpm/magento1/Dockerfile +++ b/images/php-fpm/magento1/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION} USER root RUN npm install -g grunt-cli gulp yarn diff --git a/images/php-fpm/magento1/blackfire/Dockerfile b/images/php-fpm/magento1/blackfire/Dockerfile index 31a0d7ea..e0530b07 100644 --- a/images/php-fpm/magento1/blackfire/Dockerfile +++ b/images/php-fpm/magento1/blackfire/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento1 +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento1 USER root RUN curl -o - "http://packages.blackfire.io/fedora/blackfire.repo" \ diff --git a/images/php-fpm/magento1/debug/Dockerfile b/images/php-fpm/magento1/debug/Dockerfile index be0d1dd4..ba71ddf3 100644 --- a/images/php-fpm/magento1/debug/Dockerfile +++ b/images/php-fpm/magento1/debug/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento1 +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento1 USER root RUN set -eux \ diff --git a/images/php-fpm/magento1/xdebug3/Dockerfile b/images/php-fpm/magento1/xdebug3/Dockerfile index 271092bc..c08d4d12 100644 --- a/images/php-fpm/magento1/xdebug3/Dockerfile +++ b/images/php-fpm/magento1/xdebug3/Dockerfile @@ -1,5 +1,6 @@ -ARG PHP_VERSION= -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento1 +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" +ARG PHP_VERSION +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento1 USER root RUN set -eux \ diff --git a/images/php-fpm/magento2/Dockerfile b/images/php-fpm/magento2/Dockerfile index afc89459..5fba6812 100644 --- a/images/php-fpm/magento2/Dockerfile +++ b/images/php-fpm/magento2/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION} USER root RUN npm install -g grunt-cli gulp yarn diff --git a/images/php-fpm/magento2/blackfire/Dockerfile b/images/php-fpm/magento2/blackfire/Dockerfile index e2ee4918..59cbcfad 100644 --- a/images/php-fpm/magento2/blackfire/Dockerfile +++ b/images/php-fpm/magento2/blackfire/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento2 +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento2 USER root RUN curl -o - "http://packages.blackfire.io/fedora/blackfire.repo" \ diff --git a/images/php-fpm/magento2/debug/Dockerfile b/images/php-fpm/magento2/debug/Dockerfile index 5c04277f..70d38c68 100644 --- a/images/php-fpm/magento2/debug/Dockerfile +++ b/images/php-fpm/magento2/debug/Dockerfile @@ -1,5 +1,6 @@ +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" ARG PHP_VERSION -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento2 +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento2 USER root RUN set -eux \ diff --git a/images/php-fpm/magento2/xdebug3/Dockerfile b/images/php-fpm/magento2/xdebug3/Dockerfile index ac191097..62442448 100644 --- a/images/php-fpm/magento2/xdebug3/Dockerfile +++ b/images/php-fpm/magento2/xdebug3/Dockerfile @@ -1,5 +1,6 @@ -ARG PHP_VERSION= -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION}-magento2 +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" +ARG PHP_VERSION +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION}-magento2 USER root RUN set -eux \ diff --git a/images/php-fpm/xdebug3/Dockerfile b/images/php-fpm/xdebug3/Dockerfile index 03622534..17b10350 100644 --- a/images/php-fpm/xdebug3/Dockerfile +++ b/images/php-fpm/xdebug3/Dockerfile @@ -1,5 +1,6 @@ -ARG PHP_VERSION= -FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +ARG ENV_SOURCE_IMAGE="wardenenv/php-fpm" +ARG PHP_VERSION +FROM ${ENV_SOURCE_IMAGE}:${PHP_VERSION} USER root RUN set -eux \ diff --git a/images/scripts/build.sh b/images/scripts/build.sh index f93da4de..8a08f9df 100755 --- a/images/scripts/build.sh +++ b/images/scripts/build.sh @@ -4,13 +4,13 @@ trap 'error "$(printf "Command \`%s\` at $BASH_SOURCE:$LINENO failed with exit c ## find directory where this script is located following symlinks if neccessary readonly BASE_DIR="$( - cd "$( - dirname "$( - (readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}") \ - | sed -e "s#^../#$(dirname "$(dirname "${BASH_SOURCE[0]}")")/#" - )" - )" >/dev/null \ - && pwd + cd "$( + dirname "$( + (readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}") | + sed -e "s#^../#$(dirname "$(dirname "${BASH_SOURCE[0]}")")/#" + )" + )" >/dev/null && + pwd )/.." pushd ${BASE_DIR} >/dev/null @@ -20,77 +20,85 @@ source "${WARDEN_DIR}/utils/core.sh" ## if --push is passed as first argument to script, this will login to docker hub and push images PUSH_FLAG= -if [[ "${1:-}" = "--push" ]]; then - PUSH_FLAG=1 - SEARCH_PATH="${2:-}" +if [[ "${1:-}" == "--push" ]]; then + PUSH_FLAG=1 + SEARCH_PATH="${2:-}" else - SEARCH_PATH="${1:-}" + SEARCH_PATH="${1:-}" fi ## since fpm images no longer can be traversed, this script should require a search path vs defaulting to build all if [[ -z ${SEARCH_PATH} ]]; then - fatal "Missing search path. Please try again passing an image type as an argument." + fatal "Missing search path. Please try again passing an image type as an argument." fi ## login to docker hub as needed if [[ ${PUSH_FLAG} ]]; then - if [[ ${DOCKER_USERNAME:-} ]]; then - echo "Attempting non-interactive docker login (via provided credentials)" - echo "${DOCKER_PASSWORD:-}" | docker login -u "${DOCKER_USERNAME:-}" --password-stdin ${DOCKER_REGISTRY:-docker.io} - elif [[ -t 1 ]]; then - echo "Attempting interactive docker login (tty)" - docker login ${DOCKER_REGISTRY:-docker.io} - fi + if [[ ${DOCKER_USERNAME:-} ]]; then + echo "Attempting non-interactive docker login (via provided credentials)" + echo "${DOCKER_PASSWORD:-}" | docker login -u "${DOCKER_USERNAME:-}" --password-stdin ${DOCKER_REGISTRY:-docker.io} + elif [[ -t 1 ]]; then + echo "Attempting interactive docker login (tty)" + docker login ${DOCKER_REGISTRY:-docker.io} + fi fi +## define image repository to push +WARDEN_SOURCE_REPOSITORY="${WARDEN_SOURCE_REPOSITORY:-"wardenenv"}" + ## iterate over and build each Dockerfile for file in $(find ${SEARCH_PATH} -type f -name Dockerfile | sort -V); do BUILD_DIR="$(dirname "${file}")" - IMAGE_TAG="docker.io/wardenenv/$(echo "${BUILD_DIR}" | cut -d/ -f1)" + IMAGE_TAG=WARDEN_SOURCE_REPOSITORY + IMAGE_TAG+="/$(echo "${BUILD_DIR}" | cut -d/ -f1)" IMAGE_SUFFIX="$(echo "${BUILD_DIR}" | cut -d/ -f2- -s | tr / - | sed 's/^-//')" ## due to build matrix requirements, magento1 and magento2 specific varients are built in separate invocation if [[ ${SEARCH_PATH} == "php-fpm" ]] && [[ ${file} =~ php-fpm/magento[1-2] ]]; then - continue; + continue fi ## fpm images will not have each version in a directory tree; require version be passed ## in as env variable for use as a build argument BUILD_ARGS=() - if [[ ${SEARCH_PATH} = *fpm* ]]; then - if [[ -z ${PHP_VERSION} ]]; then - fatal "Building ${SEARCH_PATH} images requires PHP_VERSION env variable be set." - fi - - export PHP_VERSION - - IMAGE_TAG+=":${PHP_VERSION}" - if [[ ${IMAGE_SUFFIX} ]]; then - IMAGE_TAG+="-${IMAGE_SUFFIX}" - fi - BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("PHP_VERSION") - - # Support for PHP 8 images which require (temporarily at least) use of non-loader variant of base image - if [[ ${PHP_VARIANT:-} ]]; then - export PHP_VARIANT + if [[ ${SEARCH_PATH} == *fpm* ]]; then + if [[ -z ${PHP_VERSION} ]]; then + fatal "Building ${SEARCH_PATH} images requires PHP_VERSION env variable be set." + fi + + ## define default sources for main php and environment images + export PHP_SOURCE_IMAGE="${PHP_SOURCE_IMAGE:-"davidalger/php"}" + export ENV_SOURCE_IMAGE="${ENV_SOURCE_IMAGE:-"wardenenv/php-fpm"}" + + export PHP_VERSION + + IMAGE_TAG+=":${PHP_VERSION}" + if [[ ${IMAGE_SUFFIX} ]]; then + IMAGE_TAG+="-${IMAGE_SUFFIX}" + fi BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("PHP_VARIANT") - fi + BUILD_ARGS+=("PHP_VERSION") + + # Support for PHP 8 images which require (temporarily at least) use of non-loader variant of base image + if [[ ${PHP_VARIANT:-} ]]; then + export PHP_VARIANT + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("PHP_VARIANT") + fi else - IMAGE_TAG+=":${IMAGE_SUFFIX}" + IMAGE_TAG+=":${IMAGE_SUFFIX}" fi # Skip build of xdebug3 fpm images on older versions of PHP (it requires PHP 7.2 or greater) if [[ ${IMAGE_SUFFIX} =~ xdebug3 ]] && test $(version ${PHP_VERSION}) -lt $(version "7.2"); then - warning "Skipping build for ${IMAGE_TAG} (xdebug3 is unavailable for PHP ${PHP_VERSION})" - continue + warning "Skipping build for ${IMAGE_TAG} (xdebug3 is unavailable for PHP ${PHP_VERSION})" + continue fi if [[ -d "$(echo ${BUILD_DIR} | cut -d/ -f1)/context" ]]; then - BUILD_CONTEXT="$(echo ${BUILD_DIR} | cut -d/ -f1)/context" + BUILD_CONTEXT="$(echo ${BUILD_DIR} | cut -d/ -f1)/context" else - BUILD_CONTEXT="${BUILD_DIR}" + BUILD_CONTEXT="${BUILD_DIR}" fi printf "\e[01;31m==> building ${IMAGE_TAG} from ${BUILD_DIR}/Dockerfile with context ${BUILD_CONTEXT}\033[0m\n" From 9a11f7c347e451c3914fdab545da796d3a1adea9 Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Wed, 21 Apr 2021 11:40:54 +0300 Subject: [PATCH 2/4] Allow define custom warden env repository --- commands/env.cmd | 6 ++++++ environments/includes/blackfire.base.yml | 2 +- environments/includes/db.base.yml | 2 +- environments/includes/nginx.base.yml | 2 +- environments/includes/php-fpm.base.yml | 4 ++-- environments/includes/rabbitmq.base.yml | 2 +- environments/includes/redis.base.yml | 2 +- environments/includes/varnish.base.yml | 2 +- environments/magento2/magento2.magepack.base.yml | 2 +- environments/magento2/magento2.splitdb.checkout.base.yml | 2 +- environments/magento2/magento2.splitdb.sales.base.yml | 2 +- environments/magento2/magento2.tests.base.yml | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/commands/env.cmd b/commands/env.cmd index 2e9d9a16..23c79985 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -12,6 +12,12 @@ fi ## allow return codes from sub-process to bubble up normally trap '' ERR +## define source repository +if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then + eval "$(grep "^WARDEN_SOURCE_REPOSITORY" "${WARDEN_HOME_DIR}/.env")" +fi +export WARDEN_SOURCE_REPOSITORY="${WARDEN_SOURCE_REPOSITORY:-"wardenenv"}" + ## configure environment type defaults if [[ ${WARDEN_ENV_TYPE} =~ ^magento ]]; then export WARDEN_SVC_PHP_VARIANT=-${WARDEN_ENV_TYPE} diff --git a/environments/includes/blackfire.base.yml b/environments/includes/blackfire.base.yml index 097946e0..9966bf88 100644 --- a/environments/includes/blackfire.base.yml +++ b/environments/includes/blackfire.base.yml @@ -12,7 +12,7 @@ x-extra_hosts: &extra_hosts services: php-blackfire: hostname: "${WARDEN_ENV_NAME}-php-blackfire" - image: docker.io/wardenenv/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-blackfire + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-blackfire environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN diff --git a/environments/includes/db.base.yml b/environments/includes/db.base.yml index 48acad70..09b4f4e7 100644 --- a/environments/includes/db.base.yml +++ b/environments/includes/db.base.yml @@ -6,7 +6,7 @@ services: db: hostname: "${WARDEN_ENV_NAME}-mariadb" - image: docker.io/wardenenv/mariadb:${MARIADB_VERSION:-10.4} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/mariadb:${MARIADB_VERSION:-10.4} environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-app} - MYSQL_DATABASE=${MYSQL_DATABASE:-app} diff --git a/environments/includes/nginx.base.yml b/environments/includes/nginx.base.yml index 13715ec8..93a5576c 100644 --- a/environments/includes/nginx.base.yml +++ b/environments/includes/nginx.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: nginx: hostname: "${WARDEN_ENV_NAME}-nginx" - image: docker.io/wardenenv/nginx:${NGINX_VERSION:-1.16} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/nginx:${NGINX_VERSION:-1.16} labels: - traefik.enable=true - traefik.http.routers.${WARDEN_ENV_NAME}-nginx.tls=true diff --git a/environments/includes/php-fpm.base.yml b/environments/includes/php-fpm.base.yml index 8797b632..16c5b01d 100644 --- a/environments/includes/php-fpm.base.yml +++ b/environments/includes/php-fpm.base.yml @@ -17,7 +17,7 @@ services: php-fpm: hostname: "${WARDEN_ENV_NAME}-php-fpm" - image: docker.io/wardenenv/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-} environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN @@ -32,7 +32,7 @@ services: php-debug: hostname: "${WARDEN_ENV_NAME}-php-debug" - image: docker.io/wardenenv/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-${XDEBUG_VERSION:-debug} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-${XDEBUG_VERSION:-debug} environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN diff --git a/environments/includes/rabbitmq.base.yml b/environments/includes/rabbitmq.base.yml index 3d488c20..154969dc 100644 --- a/environments/includes/rabbitmq.base.yml +++ b/environments/includes/rabbitmq.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: rabbitmq: hostname: "${WARDEN_ENV_NAME}-rabbitmq" - image: docker.io/wardenenv/rabbitmq:${RABBITMQ_VERSION:-3.8} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/rabbitmq:${RABBITMQ_VERSION:-3.8} labels: - traefik.enable=true - traefik.http.routers.${WARDEN_ENV_NAME}-rabbitmq.tls=true diff --git a/environments/includes/redis.base.yml b/environments/includes/redis.base.yml index 8ccc87ca..7401689f 100644 --- a/environments/includes/redis.base.yml +++ b/environments/includes/redis.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: redis: hostname: "${WARDEN_ENV_NAME}-redis" - image: docker.io/wardenenv/redis:${REDIS_VERSION:-5.0} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/redis:${REDIS_VERSION:-5.0} volumes: - redis:/data diff --git a/environments/includes/varnish.base.yml b/environments/includes/varnish.base.yml index e2f0762d..b1748fc2 100644 --- a/environments/includes/varnish.base.yml +++ b/environments/includes/varnish.base.yml @@ -7,7 +7,7 @@ services: varnish: hostname: "${WARDEN_ENV_NAME}-varnish" - image: docker.io/wardenenv/varnish:${VARNISH_VERSION:-6.0} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/varnish:${VARNISH_VERSION:-6.0} depends_on: - nginx labels: diff --git a/environments/magento2/magento2.magepack.base.yml b/environments/magento2/magento2.magepack.base.yml index fb77e16d..73c5a3e9 100644 --- a/environments/magento2/magento2.magepack.base.yml +++ b/environments/magento2/magento2.magepack.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: magepack: hostname: "${WARDEN_ENV_NAME}-magepack" - image: docker.io/wardenenv/magepack:${MAGEPACK_VERSION:-2.3} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/magepack:${MAGEPACK_VERSION:-2.3} environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN diff --git a/environments/magento2/magento2.splitdb.checkout.base.yml b/environments/magento2/magento2.splitdb.checkout.base.yml index 25fbee01..129a2251 100644 --- a/environments/magento2/magento2.splitdb.checkout.base.yml +++ b/environments/magento2/magento2.splitdb.checkout.base.yml @@ -10,7 +10,7 @@ services: checkoutdb: hostname: "${WARDEN_ENV_NAME}-checkoutdb" - image: docker.io/wardenenv/mariadb:${MARIADB_VERSION:-10.4} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/mariadb:${MARIADB_VERSION:-10.4} environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-magento} - MYSQL_DATABASE=${MYSQL_DATABASE:-magento} diff --git a/environments/magento2/magento2.splitdb.sales.base.yml b/environments/magento2/magento2.splitdb.sales.base.yml index 2c03bc21..b0ed5373 100644 --- a/environments/magento2/magento2.splitdb.sales.base.yml +++ b/environments/magento2/magento2.splitdb.sales.base.yml @@ -10,7 +10,7 @@ services: salesdb: hostname: "${WARDEN_ENV_NAME}-salesdb" - image: docker.io/wardenenv/mariadb:${MARIADB_VERSION:-10.4} + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/mariadb:${MARIADB_VERSION:-10.4} environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-magento} - MYSQL_DATABASE=${MYSQL_DATABASE:-magento} diff --git a/environments/magento2/magento2.tests.base.yml b/environments/magento2/magento2.tests.base.yml index 32c5125d..6ea96b46 100644 --- a/environments/magento2/magento2.tests.base.yml +++ b/environments/magento2/magento2.tests.base.yml @@ -2,7 +2,7 @@ version: "3.5" services: tmp-mysql: hostname: "${WARDEN_ENV_NAME}-mysql" - image: docker.io/wardenenv/mysql:5.7 + image: ${WARDEN_SOURCE_REPOSITORY:-wardenenv}/mysql:5.7 environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-magento} - MYSQL_DATABASE=magento_integration_tests From cfb9033c5b6604c3f36950322933a66cd608313c Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Wed, 21 Apr 2021 11:53:17 +0300 Subject: [PATCH 3/4] Update image build --- images/scripts/build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/images/scripts/build.sh b/images/scripts/build.sh index 8a08f9df..6422d2c8 100755 --- a/images/scripts/build.sh +++ b/images/scripts/build.sh @@ -49,7 +49,7 @@ WARDEN_SOURCE_REPOSITORY="${WARDEN_SOURCE_REPOSITORY:-"wardenenv"}" ## iterate over and build each Dockerfile for file in $(find ${SEARCH_PATH} -type f -name Dockerfile | sort -V); do BUILD_DIR="$(dirname "${file}")" - IMAGE_TAG=WARDEN_SOURCE_REPOSITORY + IMAGE_TAG=${WARDEN_SOURCE_REPOSITORY} IMAGE_TAG+="/$(echo "${BUILD_DIR}" | cut -d/ -f1)" IMAGE_SUFFIX="$(echo "${BUILD_DIR}" | cut -d/ -f2- -s | tr / - | sed 's/^-//')" @@ -68,7 +68,12 @@ for file in $(find ${SEARCH_PATH} -type f -name Dockerfile | sort -V); do ## define default sources for main php and environment images export PHP_SOURCE_IMAGE="${PHP_SOURCE_IMAGE:-"davidalger/php"}" + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("PHP_SOURCE_IMAGE") + export ENV_SOURCE_IMAGE="${ENV_SOURCE_IMAGE:-"wardenenv/php-fpm"}" + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("ENV_SOURCE_IMAGE") export PHP_VERSION From 23e28d8d5b7a24e49147aaf9573a326b25cbc8dc Mon Sep 17 00:00:00 2001 From: Denis Kopylov Date: Mon, 5 Jul 2021 14:43:46 +0300 Subject: [PATCH 4/4] Restore code reformat Signed-off-by: Denis Kopylov --- commands/env.cmd | 2 +- images/scripts/build.sh | 106 ++++++++++++++++++++-------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/commands/env.cmd b/commands/env.cmd index 23c79985..095478e7 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -14,7 +14,7 @@ trap '' ERR ## define source repository if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then - eval "$(grep "^WARDEN_SOURCE_REPOSITORY" "${WARDEN_HOME_DIR}/.env")" + eval "$(cat "${WARDEN_HOME_DIR}/.env" | sed 's/\r$//g' | grep "^WARDEN_")" fi export WARDEN_SOURCE_REPOSITORY="${WARDEN_SOURCE_REPOSITORY:-"wardenenv"}" diff --git a/images/scripts/build.sh b/images/scripts/build.sh index 6422d2c8..25917aba 100755 --- a/images/scripts/build.sh +++ b/images/scripts/build.sh @@ -4,13 +4,13 @@ trap 'error "$(printf "Command \`%s\` at $BASH_SOURCE:$LINENO failed with exit c ## find directory where this script is located following symlinks if neccessary readonly BASE_DIR="$( - cd "$( - dirname "$( - (readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}") | - sed -e "s#^../#$(dirname "$(dirname "${BASH_SOURCE[0]}")")/#" - )" - )" >/dev/null && - pwd + cd "$( + dirname "$( + (readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}") \ + | sed -e "s#^../#$(dirname "$(dirname "${BASH_SOURCE[0]}")")/#" + )" + )" >/dev/null \ + && pwd )/.." pushd ${BASE_DIR} >/dev/null @@ -20,27 +20,27 @@ source "${WARDEN_DIR}/utils/core.sh" ## if --push is passed as first argument to script, this will login to docker hub and push images PUSH_FLAG= -if [[ "${1:-}" == "--push" ]]; then - PUSH_FLAG=1 - SEARCH_PATH="${2:-}" +if [[ "${1:-}" = "--push" ]]; then + PUSH_FLAG=1 + SEARCH_PATH="${2:-}" else - SEARCH_PATH="${1:-}" + SEARCH_PATH="${1:-}" fi ## since fpm images no longer can be traversed, this script should require a search path vs defaulting to build all if [[ -z ${SEARCH_PATH} ]]; then - fatal "Missing search path. Please try again passing an image type as an argument." + fatal "Missing search path. Please try again passing an image type as an argument." fi ## login to docker hub as needed if [[ ${PUSH_FLAG} ]]; then - if [[ ${DOCKER_USERNAME:-} ]]; then - echo "Attempting non-interactive docker login (via provided credentials)" - echo "${DOCKER_PASSWORD:-}" | docker login -u "${DOCKER_USERNAME:-}" --password-stdin ${DOCKER_REGISTRY:-docker.io} - elif [[ -t 1 ]]; then - echo "Attempting interactive docker login (tty)" - docker login ${DOCKER_REGISTRY:-docker.io} - fi + if [[ ${DOCKER_USERNAME:-} ]]; then + echo "Attempting non-interactive docker login (via provided credentials)" + echo "${DOCKER_PASSWORD:-}" | docker login -u "${DOCKER_USERNAME:-}" --password-stdin ${DOCKER_REGISTRY:-docker.io} + elif [[ -t 1 ]]; then + echo "Attempting interactive docker login (tty)" + docker login ${DOCKER_REGISTRY:-docker.io} + fi fi ## define image repository to push @@ -55,55 +55,55 @@ for file in $(find ${SEARCH_PATH} -type f -name Dockerfile | sort -V); do ## due to build matrix requirements, magento1 and magento2 specific varients are built in separate invocation if [[ ${SEARCH_PATH} == "php-fpm" ]] && [[ ${file} =~ php-fpm/magento[1-2] ]]; then - continue + continue; fi ## fpm images will not have each version in a directory tree; require version be passed ## in as env variable for use as a build argument BUILD_ARGS=() - if [[ ${SEARCH_PATH} == *fpm* ]]; then - if [[ -z ${PHP_VERSION} ]]; then - fatal "Building ${SEARCH_PATH} images requires PHP_VERSION env variable be set." - fi - - ## define default sources for main php and environment images - export PHP_SOURCE_IMAGE="${PHP_SOURCE_IMAGE:-"davidalger/php"}" - BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("PHP_SOURCE_IMAGE") - - export ENV_SOURCE_IMAGE="${ENV_SOURCE_IMAGE:-"wardenenv/php-fpm"}" - BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("ENV_SOURCE_IMAGE") - - export PHP_VERSION - - IMAGE_TAG+=":${PHP_VERSION}" - if [[ ${IMAGE_SUFFIX} ]]; then - IMAGE_TAG+="-${IMAGE_SUFFIX}" - fi + if [[ ${SEARCH_PATH} = *fpm* ]]; then + if [[ -z ${PHP_VERSION} ]]; then + fatal "Building ${SEARCH_PATH} images requires PHP_VERSION env variable be set." + fi + + ## define default sources for main php and environment images + export PHP_SOURCE_IMAGE="${PHP_SOURCE_IMAGE:-"davidalger/php"}" + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("PHP_SOURCE_IMAGE") + + export ENV_SOURCE_IMAGE="${ENV_SOURCE_IMAGE:-"wardenenv/php-fpm"}" + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("ENV_SOURCE_IMAGE") + + export PHP_VERSION + + IMAGE_TAG+=":${PHP_VERSION}" + if [[ ${IMAGE_SUFFIX} ]]; then + IMAGE_TAG+="-${IMAGE_SUFFIX}" + fi + BUILD_ARGS+=("--build-arg") + BUILD_ARGS+=("PHP_VERSION") + + # Support for PHP 8 images which require (temporarily at least) use of non-loader variant of base image + if [[ ${PHP_VARIANT:-} ]]; then + export PHP_VARIANT BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("PHP_VERSION") - - # Support for PHP 8 images which require (temporarily at least) use of non-loader variant of base image - if [[ ${PHP_VARIANT:-} ]]; then - export PHP_VARIANT - BUILD_ARGS+=("--build-arg") - BUILD_ARGS+=("PHP_VARIANT") - fi + BUILD_ARGS+=("PHP_VARIANT") + fi else - IMAGE_TAG+=":${IMAGE_SUFFIX}" + IMAGE_TAG+=":${IMAGE_SUFFIX}" fi # Skip build of xdebug3 fpm images on older versions of PHP (it requires PHP 7.2 or greater) if [[ ${IMAGE_SUFFIX} =~ xdebug3 ]] && test $(version ${PHP_VERSION}) -lt $(version "7.2"); then - warning "Skipping build for ${IMAGE_TAG} (xdebug3 is unavailable for PHP ${PHP_VERSION})" - continue + warning "Skipping build for ${IMAGE_TAG} (xdebug3 is unavailable for PHP ${PHP_VERSION})" + continue fi if [[ -d "$(echo ${BUILD_DIR} | cut -d/ -f1)/context" ]]; then - BUILD_CONTEXT="$(echo ${BUILD_DIR} | cut -d/ -f1)/context" + BUILD_CONTEXT="$(echo ${BUILD_DIR} | cut -d/ -f1)/context" else - BUILD_CONTEXT="${BUILD_DIR}" + BUILD_CONTEXT="${BUILD_DIR}" fi printf "\e[01;31m==> building ${IMAGE_TAG} from ${BUILD_DIR}/Dockerfile with context ${BUILD_CONTEXT}\033[0m\n"