diff --git a/commands/env.cmd b/commands/env.cmd index 2e9d9a16..095478e7 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 "$(cat "${WARDEN_HOME_DIR}/.env" | sed 's/\r$//g' | grep "^WARDEN_")" +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/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/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 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..25917aba 100755 --- a/images/scripts/build.sh +++ b/images/scripts/build.sh @@ -43,10 +43,14 @@ if [[ ${PUSH_FLAG} ]]; then 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 @@ -62,6 +66,15 @@ for file in $(find ${SEARCH_PATH} -type f -name Dockerfile | sort -V); do 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}"