Skip to content

Commit

Permalink
Changed mailhog from per-project service to run as a global service
Browse files Browse the repository at this point in the history
Resolves #175
  • Loading branch information
davidalger committed Jul 6, 2020
1 parent 33e903d commit 12d8452
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 30 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
## 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.6.0..develop)

**Upgrade Notes:**

* With `mailhog` being changed from running on a per-project basis to running as a global service (see issue [#175](https://github.com/davidalger/warden/issues/175)) you will need to ensure `warden svc up` has been run after updating Warden. On pre-existing projects that already had their own Mailhog container running, `warden env up --remove-orphans` will clean it up.

**Enhancements:**

* Changed `mailhog` service to run as a single global service rather than as a per-project service (issue [#175](https://github.com/davidalger/warden/issues/175))

## Version [0.6.0](https://github.com/davidalger/warden/tree/0.6.0) (2020-07-02)
[All Commits](https://github.com/davidalger/warden/compare/0.5.3..0.6.0)

Expand Down
4 changes: 0 additions & 4 deletions commands/env-init.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ if [[ "${WARDEN_ENV_TYPE}" == "magento1" ]]; then
WARDEN_DB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
MARIADB_VERSION=10.3
NODE_VERSION=10
Expand All @@ -76,7 +75,6 @@ if [[ "${WARDEN_ENV_TYPE}" == "magento2" ]]; then
WARDEN_VARNISH=1
WARDEN_RABBITMQ=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
ELASTICSEARCH_VERSION=7.7
MARIADB_VERSION=10.3
Expand Down Expand Up @@ -114,7 +112,6 @@ if [[ "${WARDEN_ENV_TYPE}" == "laravel" ]]; then
WARDEN_DB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
## Laravel Config
APP_URL=http://app.${WARDEN_ENV_NAME}.test
Expand Down Expand Up @@ -145,7 +142,6 @@ if [[ "${WARDEN_ENV_TYPE}" =~ ^symfony|shopware$ ]]; then
WARDEN_DB=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1
WARDEN_RABBITMQ=0
WARDEN_ELASTICSEARCH=0
WARDEN_VARNISH=0
Expand Down
14 changes: 7 additions & 7 deletions commands/env-init.help
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ WARDEN_USAGE=$(cat <<EOF
https://docs.warden.dev/environments/types.html#local
magento2 Nginx, varnish, php-fpm, db (mariadb), elasticsearch, redis,
rabbitmq, and mailhog services pre configured for Magento 2;
on macOS systems code files are synced into container using
mutagen session with pub/media, pub/static and var dirs
excluded. On Linux code is mounted natively.
and rabbitmq services pre configured for Magento 2; on macOS
systems code files are synced into container using mutagen
session with pub/media, pub/static and var dirs excluded.
On Linux code is mounted natively.
magento1 Nginx, php-fpm, db (mariadb), redis, and mailhog services
magento1 Nginx, php-fpm, db (mariadb), and redis services
pre-configured for running Magento 1
laravel Nginx, php-fpm, db (mariadb), redis, and mailhog services
laravel Nginx, php-fpm, db (mariadb), and redis services
pre-configured for running Laravel
symfony Nginx, php-fpm, db (mariadb), redis, and mailhog services
symfony Nginx, php-fpm, db (mariadb), and redis 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
Expand Down
4 changes: 0 additions & 4 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ if [[ ${WARDEN_ENV_TYPE} != local ]]; then
WARDEN_NGINX=${WARDEN_NGINX:-1}
WARDEN_DB=${WARDEN_DB:-1}
WARDEN_REDIS=${WARDEN_REDIS:-1}
WARDEN_MAILHOG=${WARDEN_MAILHOG:-1}
fi

if [[ ${WARDEN_ENV_TYPE} == "magento2" ]]; then
Expand Down Expand Up @@ -57,9 +56,6 @@ fi
[[ ${WARDEN_REDIS} -eq 1 ]] \
&& appendEnvPartialIfExists "redis"

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

appendEnvPartialIfExists "${WARDEN_ENV_TYPE}"

[[ ${WARDEN_TEST_DB} -eq 1 ]] \
Expand Down
10 changes: 10 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ services:
- traefik.http.services.dnsmasq.loadbalancer.server.port=8080
restart: ${WARDEN_RESTART_POLICY:-always}

mailhog:
container_name: mailhog
image: docker.io/wardenenv/mailhog:1.0
labels:
- traefik.enable=true
- traefik.http.routers.mailhog.tls=true
- traefik.http.routers.mailhog.rule=Host(`mailhog.${WARDEN_SERVICE_DOMAIN:-warden.test}`)
- traefik.http.services.mailhog.loadbalancer.server.port=8025
restart: ${WARDEN_RESTART_POLICY:-always}

tunnel:
container_name: tunnel
image: panubo/sshd:1.1.0
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/multipledomains.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Multiple Domains

If you need multiple domains configured for your project, Warden will now automatically route all sub-domains of the configured `TRAEFIK_DOMAIN` (as given when running `env-init`) to the Varnish/Nginx containers provided there is not a more specific rule such as for example `mailhog.exampleproject.com` which routes to the `mailhog` service.
If you need multiple domains configured for your project, Warden will now automatically route all sub-domains of the configured `TRAEFIK_DOMAIN` (as given when running `env-init`) to the Varnish/Nginx containers provided there is not a more specific rule such as for example `rabbitmq.exampleproject.com` which routes to the `rabbitmq` service for the project.

Multiple top-level domains may also be setup by following the instructions below:

Expand Down
2 changes: 0 additions & 2 deletions docs/environments/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ The below example demonstrates the from-scratch setup of the Magento 2 applicati
WARDEN_VARNISH=1
WARDEN_RABBITMQ=1
WARDEN_REDIS=1
WARDEN_MAILHOG=1

WARDEN_SYNC_IGNORE=

Expand Down Expand Up @@ -168,7 +167,6 @@ The below example demonstrates the from-scratch setup of the Magento 2 applicati
* [https://app.exampleproject.test/](https://app.exampleproject.test/)
* [https://app.exampleproject.test/backend/](https://app.exampleproject.test/backend/)
* [https://mailhog.exampleproject.test/](https://mailhog.exampleproject.test/)
* [https://rabbitmq.exampleproject.test/](https://rabbitmq.exampleproject.test/)
* [https://elasticsearch.exampleproject.test/](https://elasticsearch.exampleproject.test/)
Expand Down
2 changes: 1 addition & 1 deletion docs/environments/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ In order to achieve a well performing experience on macOS, files in the webroot

#### 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.
In addition to the above, each environment type (with the exception of the `local` type) come with PHP setup to use `mhsendmail` to ensure outbound email does not inadvertently leave your network and to support simpler testing of email functionality. Mailhog may be accessed by navigating to [https://mailhog.warden.test/](https://mailhog.warden.test/) in a browser.

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.

Expand Down
1 change: 1 addition & 0 deletions docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ After running `warden up` for the first time following installation, the followi
* [https://traefik.warden.test/](https://traefik.warden.test/)
* [https://portainer.warden.test/](https://portainer.warden.test/)
* [https://dnsmasq.warden.test/](https://dnsmasq.warden.test/)
* [https://mailhog.warden.test/](https://mailhog.warden.test/)

### Customizable Settings

Expand Down
10 changes: 0 additions & 10 deletions environments/includes/mailhog.base.yml

This file was deleted.

2 changes: 1 addition & 1 deletion utils/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[[ ! ${WARDEN_DIR} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!\033[0m" && exit 1

## global service containers to be connected with the project docker network
DOCKER_PEERED_SERVICES=("traefik" "tunnel")
DOCKER_PEERED_SERVICES=("traefik" "tunnel" "mailhog")

## messaging functions
function warning {
Expand Down

0 comments on commit 12d8452

Please sign in to comment.