Skip to content

Commit

Permalink
Deduplicate php-fpm and php-debug container service specs
Browse files Browse the repository at this point in the history
Summary of side-effects of these changes:

* PHP_IDE_CONFIG is specified on both php-fpm and php-debug containers
* Laravel environment will now default to PHP 7.3 (version is not currently being locked in .env file)
* Magento 1 environment will now run default PHP 7.3 unless locked in .env file (it is and has been dumped to .env file as 7.2 for a while now)

The drift in spec resulting from these changes follows:

davidalger:09:12 AM:/sites/testenvs$ for type in local laravel magento1 magento2; do echo "==> comparing $type"; (cd $type; diff -u develop.yml <(warden env config)) done
==> comparing local
==> comparing laravel
--- develop.yml	2020-05-11 11:57:43.000000000 -0500
+++ /dev/fd/63	2020-05-12 09:36:06.000000000 -0500
@@ -53,7 +53,7 @@
       app.config.test: 0.0.0.0
       config.test: 0.0.0.0
     hostname: config-php-debug
-    image: quay.io/warden/php-fpm:7.2-debug
+    image: quay.io/warden/php-fpm:7.3-debug
     volumes:
     - /Users/davidalger/.warden/ssl/rootca/certs:/etc/ssl/warden-rootca-cert:ro
     - /Users/davidalger/.composer:/home/www-data/.composer:delegated
@@ -64,6 +64,7 @@
     - db
     environment:
       NODE_VERSION: '10'
+      PHP_IDE_CONFIG: serverName=config-docker
       SSH_AUTH_SOCK: /tmp/ssh-auth.sock
       TRAEFIK_DOMAIN: config.test
       TRAEFIK_SUBDOMAIN: app
@@ -71,7 +72,7 @@
       app.config.test: 0.0.0.0
       config.test: 0.0.0.0
     hostname: config-php-fpm
-    image: quay.io/warden/php-fpm:7.2
+    image: quay.io/warden/php-fpm:7.3
     volumes:
     - /Users/davidalger/.warden/ssl/rootca/certs:/etc/ssl/warden-rootca-cert:ro
     - /Users/davidalger/.composer:/home/www-data/.composer:delegated
==> comparing magento1
--- develop.yml	2020-05-11 11:57:59.000000000 -0500
+++ /dev/fd/63	2020-05-12 09:36:07.000000000 -0500
@@ -66,6 +66,7 @@
     - db
     environment:
       NODE_VERSION: '10'
+      PHP_IDE_CONFIG: serverName=config-docker
       SSH_AUTH_SOCK: /tmp/ssh-auth.sock
       TRAEFIK_DOMAIN: config.test
       TRAEFIK_SUBDOMAIN: app
==> comparing magento2
--- develop.yml	2020-05-11 11:58:04.000000000 -0500
+++ /dev/fd/63	2020-05-12 09:36:07.000000000 -0500
@@ -84,6 +84,7 @@
     - db
     environment:
       NODE_VERSION: '10'
+      PHP_IDE_CONFIG: serverName=config-docker
       SSH_AUTH_SOCK: /tmp/ssh-auth.sock
       TRAEFIK_DOMAIN: config.test
       TRAEFIK_SUBDOMAIN: app
  • Loading branch information
davidalger committed May 13, 2020
1 parent 7a22fd1 commit 5331df4
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 124 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"files.exclude": {
"docs/_build": true
}
},
"cSpell.words": [
"appdata"
]
}
9 changes: 9 additions & 0 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ fi
## simply allow the return code from docker-compose to bubble up per normal
trap '' ERR

## configure environment type defaults
if [[ ${WARDEN_ENV_TYPE} =~ ^magento ]]; then
export WARDEN_SVC_PHP_VARIANT=-${WARDEN_ENV_TYPE}
fi

## configure docker-compose files
DOCKER_COMPOSE_ARGS=()

appendEnvPartialIfExists "base"
appendEnvPartialIfExists "${WARDEN_ENV_SUBT}"

[[ ${WARDEN_ENV_TYPE} != local ]] \
&& appendEnvPartialIfExists "php-fpm.base" \
&& appendEnvPartialIfExists "php-fpm.${WARDEN_ENV_SUBT}"

[[ ${WARDEN_TEST_DB} -eq 1 ]] \
&& appendEnvPartialIfExists "tests"

Expand Down
29 changes: 0 additions & 29 deletions environments/laravel/laravel.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,11 @@ services:
- traefik.http.services.${WARDEN_ENV_NAME}-nginx.loadbalancer.server.port=80

php-fpm:
hostname: "${WARDEN_ENV_NAME}-php-fpm"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.2}
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- db
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated

php-debug:
hostname: "${WARDEN_ENV_NAME}-php-debug"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.2}-debug
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
- PHP_IDE_CONFIG=serverName=${WARDEN_ENV_NAME}-docker
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- php-fpm
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated

db:
Expand Down
29 changes: 0 additions & 29 deletions environments/magento1/magento1.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,11 @@ services:
- traefik.http.services.${WARDEN_ENV_NAME}-nginx.loadbalancer.server.port=80

php-fpm:
hostname: "${WARDEN_ENV_NAME}-php-fpm"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.2}-magento1
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- db
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated

php-debug:
hostname: "${WARDEN_ENV_NAME}-php-debug"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.2}-magento1-debug
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
- PHP_IDE_CONFIG=serverName=${WARDEN_ENV_NAME}-docker
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- php-fpm
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated

db:
Expand Down
6 changes: 6 additions & 0 deletions environments/magento1/magento1.darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ services:

php-fpm:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated

php-debug:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html:delegated
6 changes: 6 additions & 0 deletions environments/magento1/magento1.linux-gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ version: "3.5"
services:
php-fpm:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html

php-debug:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html
43 changes: 8 additions & 35 deletions environments/magento2/magento2.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,15 @@ services:
- traefik.http.services.${WARDEN_ENV_NAME}-varnish.loadbalancer.server.port=80

php-fpm:
hostname: "${WARDEN_ENV_NAME}-php-fpm"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}-magento2
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- db
labels:
- traefik.enable=true
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.tls=true
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.priority=2
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.rule=
(HostRegexp(`{subdomain:.+}.${TRAEFIK_DOMAIN}`) || Host(`${TRAEFIK_DOMAIN}`))
&& (Path(`/livereload.js`) || Path(`/livereload`))
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.service=${WARDEN_ENV_NAME}-livereload
- traefik.http.services.${WARDEN_ENV_NAME}-livereload.loadbalancer.server.port=35729

php-debug:
hostname: "${WARDEN_ENV_NAME}-php-debug"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}-magento2-debug
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
- PHP_IDE_CONFIG=serverName=${WARDEN_ENV_NAME}-docker
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
depends_on:
- php-fpm
- traefik.enable=true
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.tls=true
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.priority=2
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.rule=
(HostRegexp(`{subdomain:.+}.${TRAEFIK_DOMAIN}`) || Host(`${TRAEFIK_DOMAIN}`))
&& (Path(`/livereload.js`) || Path(`/livereload`))
- traefik.http.routers.${WARDEN_ENV_NAME}-livereload.service=${WARDEN_ENV_NAME}-livereload
- traefik.http.services.${WARDEN_ENV_NAME}-livereload.loadbalancer.server.port=35729

db:
hostname: "${WARDEN_ENV_NAME}-mariadb"
Expand Down
23 changes: 8 additions & 15 deletions environments/magento2/magento2.darwin.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
version: "3.5"

x-volumes: &volumes
- .${WARDEN_WEB_ROOT:-}/pub/media:/var/www/html/pub/media:delegated
- appdata:/var/www/html

services:
nginx:
environment:
- XDEBUG_CONNECT_BACK_HOST=${XDEBUG_CONNECT_BACK_HOST:-host.docker.internal}
volumes:
- .${WARDEN_WEB_ROOT:-}/pub/media:/var/www/html/pub/media:delegated
- appdata:/var/www/html
volumes: *volumes

php-fpm:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/pub/media:/var/www/html/pub/media:delegated
- appdata:/var/www/html
volumes: *volumes

php-debug:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/pub/media:/var/www/html/pub/media:delegated
- appdata:/var/www/html
volumes: *volumes

volumes:
appdata:
19 changes: 7 additions & 12 deletions environments/magento2/magento2.linux-gnu.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
version: "3.5"

x-volumes: &volumes
- .${WARDEN_WEB_ROOT:-}/:/var/www/html

services:
nginx:
volumes:
- .${WARDEN_WEB_ROOT:-}/:/var/www/html
volumes: *volumes

php-fpm:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html
volumes: *volumes

php-debug:
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html
volumes: *volumes
30 changes: 30 additions & 0 deletions environments/services/php-fpm.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.5"

x-defaults: &defaults
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
- PHP_IDE_CONFIG=serverName=${WARDEN_ENV_NAME}-docker
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated

services:
php-fpm:
<<: *defaults
hostname: "${WARDEN_ENV_NAME}-php-fpm"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}${WARDEN_SVC_PHP_VARIANT:-}
depends_on:
- db

php-debug:
<<: *defaults
hostname: "${WARDEN_ENV_NAME}-php-debug"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}${WARDEN_SVC_PHP_VARIANT:-}-debug
depends_on:
- php-fpm
8 changes: 8 additions & 0 deletions environments/services/php-fpm.darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.5"

x-volumes: &volumes
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock

services:
php-fpm: { volumes: *volumes }
php-debug: { volumes: *volumes }
8 changes: 8 additions & 0 deletions environments/services/php-fpm.linux-gnu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.5"

x-volumes: &volumes
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock

services:
php-fpm: { volumes: *volumes }
php-debug: { volumes: *volumes }
8 changes: 5 additions & 3 deletions utils/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ function assertValidEnvType () {

function appendEnvPartialIfExists () {
local PARTIAL_NAME="${1}"
local PARTIAL_PATH="${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.${PARTIAL_NAME}.yml"
local PARTIAL_PATH="${WARDEN_DIR}/environments"

if [[ -f "${PARTIAL_PATH}" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}")
if [[ -f "${PARTIAL_PATH}/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.${PARTIAL_NAME}.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.${PARTIAL_NAME}.yml")
elif [[ -f "${PARTIAL_PATH}/services/${PARTIAL_NAME}.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f" "${PARTIAL_PATH}/services/${PARTIAL_NAME}.yml")
fi
}

0 comments on commit 5331df4

Please sign in to comment.