Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment and image build improvements #363

Merged
merged 4 commits into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/blackfire.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/db.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/elasticsearch.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/nginx.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions environments/includes/php-fpm.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/rabbitmq.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/redis.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion environments/includes/varnish.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion environments/magento2/magento2.magepack.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/magento2/magento2.splitdb.checkout.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion environments/magento2/magento2.splitdb.sales.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion environments/magento2/magento2.tests.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/blackfire/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento1/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento1/blackfire/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento1/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/magento1/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento2/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento2/blackfire/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" \
Expand Down
3 changes: 2 additions & 1 deletion images/php-fpm/magento2/debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/magento2/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions images/php-fpm/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
15 changes: 14 additions & 1 deletion images/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down