Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' for release 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidalger committed May 21, 2020
2 parents 45d82c3 + 8180f7b commit 422280f
Show file tree
Hide file tree
Showing 61 changed files with 511 additions and 428 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.sync
/Icon?
/.idea
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"
]
}
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# Change Log

## UNRELEASED [x.y.z](https://github.com/davidalger/warden/tree/x.y.z) (yyyy-mm-dd)
[All Commits](https://github.com/davidalger/warden/compare/0.4.0..develop)
[All Commits](https://github.com/davidalger/warden/compare/0.5.0..develop)

## Version [0.5.0](https://github.com/davidalger/warden/tree/0.5.0) (2020-05-21)
[All Commits](https://github.com/davidalger/warden/compare/0.4.4..0.5.0)

**Upgrade Notes:**

If `PHP_VERSION` is not defined in a project's `.env` type the default version is now 7.3 across the board for all environment types. This should not pose any issues for recent `magento1` or `magento2` setups, but `laravel` environments will likely require an update to the project's `.env` to continue using PHP 7.2 or rather than 7.3 for local development.

There is a **breaking change** where custom environment config specific to Linux has been used in the form of placing a `.warden/warden-env.linux-gnu.yml` file in the project directory. The value used for `WARDEN_ENV_SUBT` on Linux is now `linux` rather than `linux-gnu`. After upgrading, these files will need to be re-named from `.warden/warden-env.linux-gnu.yml` to `.warden/warden-env.linux.yml`. Where continued compatibility with prior versions of Warden is desired (for example, to not require the entire team to upgrade Warden at once), a symlink may be placed to point the old file name to the new one allowing Warden to load the definition correctly on both new and old implementations: `warden-env.linux-gnu.yml -> warden-env.linux.yml`

The `BYPASS_VARNISH` flag will continue to work as before but has been **deprecated** to be removed in a future release. It will no longer be included in the `.env` file created for new `magento2` environments.Please use the new feature toggle `WARDEN_VARNISH=0` to disable Varnish instead.

**Enhancements:**

* Added `symfony` environment type for use with Symfony 4+ ([#146](https://github.com/davidalger/warden/pull/146) by @lbajsarowicz)
* Added `COMPOSER_MEMORY_LIMIT=-1` to env on all `php-*` containers ([#154](https://github.com/davidalger/warden/pull/154) by @navarr)
* Added new feature flag `WARDEN_DB` to enable/disable service on per-project basis.
* Added new feature flag `WARDEN_ELASTICSEARCH` to enable/disable service on per-project basis.
* Added new feature flag `WARDEN_VARNISH` to enable/disable service on per-project basis.
* Added new feature flag `WARDEN_RABBITMQ` to enable/disable service on per-project basis.
* Added new feature flag `WARDEN_REDIS` to enable/disable service on per-project basis.
* Added new feature flag `WARDEN_MAILHOG` to enable/disable service on per-project basis.
* Updated `WARDEN_ALLURE` to now enable Allure container on any environment type.
* Updated `WARDEN_SELENIUM` to now enable Selenium containers on any environment type.
* Updated `WARDEN_BLACKFIRE` to now enable Blackfire containers on any environment type.
* Updated `env-init` command to include locked values for `MARIADB_VERSION`, `NODE_VERSION`, `PHP_VERSION`, and `REDIS_VERSION` for `laravel` environment types.
* Updated `local` env type so it can now include common services by adding the above feature flags to the project `.env` file.

## Version [0.4.4](https://github.com/davidalger/warden/tree/0.4.4) (2020-05-14)
[All Commits](https://github.com/davidalger/warden/compare/0.4.3..0.4.4)
Expand Down
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Selenium container hostname contain underscores (should be hyphens)
* Selenium container versions are not configurable via env variables
* tmp-mysql service does not depend on php-fpm or php-debug as it should
* tmp-mysql service hostname is poorly named
7 changes: 6 additions & 1 deletion commands/db.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ source "${WARDEN_DIR}/utils/env.sh"
WARDEN_ENV_PATH="$(locateEnvPath)" || exit $?
loadEnvConfig "${WARDEN_ENV_PATH}" || exit $?

if [[ ${WARDEN_DB:-1} -eq 0 ]]; then
echo -e "\033[33mDatabase environment is not used."
exit 1
fi

if (( ${#WARDEN_PARAMS[@]} == 0 )); then
echo -e "\033[33mThis command has required params, please use --help for details."
exit 1
Expand All @@ -13,7 +18,7 @@ fi
## load connection information for the mysql service
eval "$(grep "^MYSQL_" "${WARDEN_ENV_PATH}/.env")"
eval "$(
grep -E '^\W+- MYSQL_.*=\$\{.*\}' "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.base.yml" \
grep -E '^\W+- MYSQL_.*=\$\{.*\}' "${WARDEN_DIR}/environments/${WARDEN_ENV_TYPE}/${WARDEN_ENV_TYPE}.db.base.yml" \
| sed -E 's/.*- //g'
)"

Expand Down
39 changes: 38 additions & 1 deletion commands/env-init.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ EOF
if [[ "${WARDEN_ENV_TYPE}" == "magento1" ]]; then
cat >> "${WARDEN_ENV_PATH}/.env" <<-EOT
WARDEN_DB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
MARIADB_VERSION=10.3
NODE_VERSION=10
PHP_VERSION=7.2
Expand All @@ -48,7 +52,12 @@ fi
if [[ "${WARDEN_ENV_TYPE}" == "magento2" ]]; then
cat >> "${WARDEN_ENV_PATH}/.env" <<-EOT
BYPASS_VARNISH=false
WARDEN_DB=1
WARDEN_ELASTICSEARCH=1
WARDEN_VARNISH=1
WARDEN_RABBITMQ=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
ELASTICSEARCH_VERSION=6.8
MARIADB_VERSION=10.3
Expand Down Expand Up @@ -78,6 +87,15 @@ fi
if [[ "${WARDEN_ENV_TYPE}" == "laravel" ]]; then
cat >> "${WARDEN_ENV_PATH}/.env" <<-EOT
MARIADB_VERSION=10.3
NODE_VERSION=10
PHP_VERSION=7.2
REDIS_VERSION=5.0
WARDEN_DB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
## Laravel Config
APP_URL=http://app.${WARDEN_ENV_NAME}.test
APP_KEY=base64:$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64)
Expand All @@ -101,3 +119,22 @@ if [[ "${WARDEN_ENV_TYPE}" == "laravel" ]]; then
MAIL_DRIVER=sendmail
EOT
fi

if [[ "${WARDEN_ENV_TYPE}" == "symfony" ]]; then
cat >> "${WARDEN_ENV_PATH}/.env" <<-EOT
MARIADB_VERSION=10.3
NODE_VERSION=10
PHP_VERSION=7.4
RABBITMQ_VERSION=3.7
REDIS_VERSION=5.0
VARNISH_VERSION=6.0
WARDEN_MARIADB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
WARDEN_RABBITMQ=1
WARDEN_ELASTICSEARCH=0
WARDEN_VARNISH=0
EOT
fi
5 changes: 5 additions & 0 deletions commands/env-init.help
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ WARDEN_USAGE=$(cat <<EOF
laravel Nginx, php-fpm, db (mariadb), redis, and mailhog services
pre-configured for running Laravel
symfony Nginx, php-fpm, db (mariadb), redis, and mailhog services
pre-configured for running Symfony 4+
Due to the fact that Symfony uses `.env` file too,
WEBROOT value of `/web/` is used by default
EOF
)
57 changes: 49 additions & 8 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,72 @@ 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

if [[ ${WARDEN_ENV_TYPE} != local ]]; then
WARDEN_DB=${WARDEN_DB:-1}
WARDEN_REDIS=${WARDEN_REDIS:-1}
WARDEN_MAILHOG=${WARDEN_MAILHOG:-1}
fi

if [[ ${WARDEN_ENV_TYPE} == "magento2" ]]; then
WARDEN_VARNISH=${WARDEN_VARNISH:-1}
WARDEN_ELASTICSEARCH=${WARDEN_ELASTICSEARCH:-1}
WARDEN_RABBITMQ=${WARDEN_RABBITMQ:-1}
fi

## configure docker-compose files
DOCKER_COMPOSE_ARGS=()

appendEnvPartialIfExists "base"
appendEnvPartialIfExists "${WARDEN_ENV_SUBT}"
appendEnvPartialIfExists "networks"

if [[ ${WARDEN_ENV_TYPE} != local ]]; then
appendEnvPartialIfExists "nginx"
appendEnvPartialIfExists "php-fpm"
fi

[[ ${WARDEN_DB} -eq 1 ]] \
&& appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.db"

[[ ${WARDEN_ELASTICSEARCH} -eq 1 ]] \
&& appendEnvPartialIfExists "elasticsearch"

[[ ${WARDEN_VARNISH} -eq 1 ]] \
&& appendEnvPartialIfExists "varnish"

[[ ${WARDEN_RABBITMQ} -eq 1 ]] \
&& appendEnvPartialIfExists "rabbitmq"

[[ ${WARDEN_REDIS} -eq 1 ]] \
&& appendEnvPartialIfExists "redis"

[[ ${WARDEN_MAILHOG} -eq 1 ]] \
&& appendEnvPartialIfExists "mailhog"

appendEnvPartialIfExists "${WARDEN_ENV_TYPE}"

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

[[ ${WARDEN_SPLIT_SALES} -eq 1 ]] \
&& appendEnvPartialIfExists "splitdb.sales"
&& appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.splitdb.sales"

[[ ${WARDEN_SPLIT_CHECKOUT} -eq 1 ]] \
&& appendEnvPartialIfExists "splitdb.checkout"
&& appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.splitdb.checkout"

if [[ ${WARDEN_BLACKFIRE} -eq 1 ]]; then
appendEnvPartialIfExists "blackfire.base"
appendEnvPartialIfExists "blackfire.${WARDEN_ENV_SUBT}"
appendEnvPartialIfExists "blackfire"
appendEnvPartialIfExists "${WARDEN_ENV_TYPE}.blackfire"
fi

[[ ${WARDEN_ALLURE} -eq 1 ]] \
&& appendEnvPartialIfExists "allure"

[[ ${WARDEN_SELENIUM} -eq 1 ]] \
&& appendEnvPartialIfExists "selenium.base"
&& appendEnvPartialIfExists "selenium"

if [[ -f "${WARDEN_ENV_PATH}/.warden/warden-env.yml" ]]; then
DOCKER_COMPOSE_ARGS+=("-f")
Expand Down
12 changes: 12 additions & 0 deletions docs/environments/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ The versions of MariaDB, Elasticsearch, Varnish, Redis, and NodeJS may also be s
* `RABBITMQ_VERSION`
* `NODE_VERSION`

Start of some environments could be skipped by using variables in `.env` file:

* `WARDEN_DB=0`
* `WARDEN_REDIS=0`
* `WARDEN_MAILHOG=0`

### Magento 2 Specific Customizations

The following variables can be added to the project's `.env` file to enable additional database containers for use with the Magento 2 (Commerce Only) [split-database solution](https://devdocs.magento.com/guides/v2.3/config-guide/multi-master/multi-master.html).

* `WARDEN_SPLIT_SALES=1`
* `WARDEN_SPLIT_CHECKOUT=1`

Start of some Magento 2 specific environments could be skipped by using variables in `.env` file:

* `WARDEN_ELASTICSEARCH=0`
* `WARDEN_VARNISH=0`
* `WARDEN_RABBITMQ=0`
7 changes: 6 additions & 1 deletion docs/environments/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ The below example demonstrates the from-scratch setup of the Magento 2 applicati
TRAEFIK_DOMAIN=exampleproject.test
TRAEFIK_SUBDOMAIN=app

BYPASS_VARNISH=false
WARDEN_DB=1
WARDEN_ELASTICSEARCH=1
WARDEN_VARNISH=1
WARDEN_RABBITMQ=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1

WARDEN_SYNC_IGNORE=

Expand Down
18 changes: 16 additions & 2 deletions docs/environments/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `local` environment type does nothing more than declare the `docker-compose`

When this type is used, a `.warden/warden-env.yml` may be placed in the root directory of the project workspace to define the desired containers, volumes, etc needed for the project. An example of a `local` environment type being used can be found in the [m2demo project](https://github.com/davidalger/m2demo).

Similar to the other environment type's base definitions, Warden supports a `warden-env.darwin.yml` and `warden-env.linux-gnu.yml`
Similar to the other environment type's base definitions, Warden supports a `warden-env.darwin.yml` and `warden-env.linux.yml`

#### Magento 2

Expand Down Expand Up @@ -46,13 +46,27 @@ The `laravel` environment type supports development of Laravel projects, launchi

Files are currently mounted using a delegated mount on macOS and natively on Linux.

#### Symfony

The `symfony` environment type supports development of Symfony 4+ projects, launching containers including:

* Nginx
* PHP-FPM
* MariaDB
* Redis
* RabbitMQ
* Varnish (disabled by default)
* Elasticsearch (disabled by default)

Files are currently mounted using a delegated mount on macOS and natively on Linux.

#### Commonalities

In addition to the above, each environment type (with the exception of the `local` type) come with a pre-configured Mailhog service, with PHP setup to use `mhsendmail` to ensure outbound email does not inadvertently leave your network and to support simpler testing of email functionality. You can use [Traefik](https://traefik.warden.test/) to find the Mailhog URL for each project.

Where PHP is specified in the above list, there should be two `fpm` containers, `php-fpm` and `php-debug` in order to provide Xdebug support. Use of Xdebug is enabled by setting the `XDEBUG_SESSION` cookie in your browser to direct the request to the `php-debug` container. Shell sessions opened in the debug container via `warden debug` will also connect PHP process for commands on the CLI to Xdebug.

The configuration of each environment leverages a `base` configuration YAML file, and optionally a `darwin` and `linux-gnu` file to add to `base` configuration anything which may be specific to a given host architecture (this is, for example, how the `magento2` environment type works seamlessly on macOS with Mutagen sync sessions while using native filesystem mounts on Linux hosts).
The configuration of each environment leverages a `base` configuration YAML file, and optionally a `darwin` and `linux` file to add to `base` configuration anything which may be specific to a given host architecture (this is, for example, how the `magento2` environment type works seamlessly on macOS with Mutagen sync sessions while using native filesystem mounts on Linux hosts).

### Environment Templates

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
version: "3.5"

x-volumes: &volumes
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated

x-extra_hosts: &extra_hosts
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}

services:
php-blackfire:
hostname: "${WARDEN_ENV_NAME}-php-blackfire"
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}-magento2-blackfire
image: quay.io/warden/php-fpm:${PHP_VERSION:-7.3}${WARDEN_SVC_PHP_VARIANT:-}-blackfire
environment:
- TRAEFIK_DOMAIN
- TRAEFIK_SUBDOMAIN
- SSH_AUTH_SOCK=/tmp/ssh-auth.sock
- NODE_VERSION=${NODE_VERSION:-10}
volumes:
- ${WARDEN_SSL_DIR}/rootca/certs:/etc/ssl/warden-rootca-cert:ro
- ${WARDEN_COMPOSER_DIR}:/home/www-data/.composer:delegated
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- COMPOSER_MEMORY_LIMIT=-1
volumes: *volumes
extra_hosts: *extra_hosts
depends_on:
- php-fpm

Expand All @@ -25,6 +31,4 @@ services:
- BLACKFIRE_CLIENT_TOKEN=${BLACKFIRE_CLIENT_TOKEN}
- BLACKFIRE_SERVER_ID=${BLACKFIRE_SERVER_ID}
- BLACKFIRE_SERVER_TOKEN=${BLACKFIRE_SERVER_TOKEN}
extra_hosts:
- ${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
- ${TRAEFIK_SUBDOMAIN:-app}.${TRAEFIK_DOMAIN}:${TRAEFIK_ADDRESS:-0.0.0.0}
extra_hosts: *extra_hosts
6 changes: 6 additions & 0 deletions environments/includes/blackfire.darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3.5"
services:
php-blackfire:
volumes:
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ services:
php-blackfire:
volumes:
- ${SSH_AUTH_SOCK:-/dev/null}:/run/host-services/ssh-auth.sock
- .${WARDEN_WEB_ROOT:-}/:/var/www/html
19 changes: 19 additions & 0 deletions environments/includes/elasticsearch.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.5"
services:
elasticsearch:
hostname: "${WARDEN_ENV_NAME}-elasticsearch"
image: quay.io/warden/elasticsearch:${ELASTICSEARCH_VERSION:-6.8}
labels:
- traefik.enable=true
- traefik.http.routers.${WARDEN_ENV_NAME}-elasticsearch.tls=true
- traefik.http.routers.${WARDEN_ENV_NAME}-elasticsearch.rule=Host(`elasticsearch.${TRAEFIK_DOMAIN}`)
- traefik.http.services.${WARDEN_ENV_NAME}-elasticsearch.loadbalancer.server.port=9200
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms64m -Xmx512m"
volumes:
- esdata:/usr/share/elasticsearch/data

volumes:
esdata:
10 changes: 10 additions & 0 deletions environments/includes/mailhog.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.5"
services:
mailhog:
hostname: "${WARDEN_ENV_NAME}-mailhog"
image: quay.io/warden/mailhog:${MAILHOG_VERSION:-1.0}
labels:
- traefik.enable=true
- traefik.http.routers.${WARDEN_ENV_NAME}-mailhog.tls=true
- traefik.http.routers.${WARDEN_ENV_NAME}-mailhog.rule=Host(`mailhog.${TRAEFIK_DOMAIN}`)
- traefik.http.services.${WARDEN_ENV_NAME}-mailhog.loadbalancer.server.port=8025
6 changes: 6 additions & 0 deletions environments/includes/networks.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3.5"
networks:
default:
labels:
- dev.warden.environment.name=${WARDEN_ENV_NAME}
- dev.warden.environment.type=${WARDEN_ENV_TYPE}
Loading

0 comments on commit 422280f

Please sign in to comment.