From 454ba3e268464906d432110beea3dcb92c9f0d8f Mon Sep 17 00:00:00 2001 From: Brett Patterson Date: Tue, 25 Jun 2024 13:39:18 -0400 Subject: [PATCH 1/5] Add optional (opt-in) support for Mailpit --- commands/install.cmd | 4 +++- commands/svc.cmd | 11 +++++++++++ docker/docker-compose.mailhog.yml | 10 ++++++++++ docker/docker-compose.mailpit.yml | 17 +++++++++++++++++ docker/docker-compose.yml | 10 ---------- 5 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 docker/docker-compose.mailhog.yml create mode 100644 docker/docker-compose.mailpit.yml diff --git a/commands/install.cmd b/commands/install.cmd index 2034a92e..db840b95 100644 --- a/commands/install.cmd +++ b/commands/install.cmd @@ -91,7 +91,9 @@ if [[ ! -f "${WARDEN_HOME_DIR}/.env" ]]; then cat >> "${WARDEN_HOME_DIR}/.env" <<-EOT # Set to "1" to enable global Portainer service WARDEN_PORTAINER_ENABLE=0 - # SEt to "0" to disable DNSMasq + # Set to "0" to disable DNSMasq WARDEN_DNSMASQ_ENABLE=1 + # Specify which mail trapping service to use: "mailhog" or "mailpit" + WARDEN_MAIL_SERVICE=mailhog EOT fi diff --git a/commands/svc.cmd b/commands/svc.cmd index 77ed263f..c20bb744 100644 --- a/commands/svc.cmd +++ b/commands/svc.cmd @@ -23,6 +23,17 @@ if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(grep "^WARDEN_DNSMASQ_ENABLE" "${WARDEN_HOME_DIR}/.env")" # Check Portainer eval "$(grep "^WARDEN_PORTAINER_ENABLE" "${WARDEN_HOME_DIR}/.env")" + # Check Mail service + eval "$(grep "^WARDEN_MAIL_SERVICE" "${WARDEN_HOME_DIR}/.env")" +fi + +WARDEN_MAIL_SERVICE="${WARDEN_MAIL_SERVICE:-mailhog}" +if [[ "$WARDEN_MAIL_SERVICE" == "mailpit" ]]; then + DOCKER_COMPOSE_ARGS+=("-f") + DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.mailpit.yml") +else + DOCKER_COMPOSE_ARGS+=("-f") + DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.mailhog.yml") fi ## add dnsmasq docker-compose diff --git a/docker/docker-compose.mailhog.yml b/docker/docker-compose.mailhog.yml new file mode 100644 index 00000000..807651ad --- /dev/null +++ b/docker/docker-compose.mailhog.yml @@ -0,0 +1,10 @@ +services: + mailhog: + container_name: mailhog + image: wardenenv/mailhog:1.0 + labels: + - traefik.enable=true + - traefik.http.routers.mailhog.tls=true + - traefik.http.routers.mailhog.rule=Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) + - traefik.http.services.mailhog.loadbalancer.server.port=8025 + restart: ${WARDEN_RESTART_POLICY:-always} \ No newline at end of file diff --git a/docker/docker-compose.mailpit.yml b/docker/docker-compose.mailpit.yml new file mode 100644 index 00000000..8944d4b6 --- /dev/null +++ b/docker/docker-compose.mailpit.yml @@ -0,0 +1,17 @@ +services: + mailpit: + container_name: mailhog + image: axllent/mailpit:${WARDEN_MAILPIT_VERSION:-latest} + environment: + - MP_DATABASE=/data/mailpit.db + volumes: + - mailpitdata:/data + labels: + - traefik.enable=true + - traefik.http.routers.mailpit.tls=true + - traefik.http.routers.mailpit.rule=Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) + - traefik.http.services.mailpit.loadbalancer.server.port=8025 + restart: ${WARDEN_RESTART_POLICY:-always} + +volumes: + mailpitdata: \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f8eb69a6..21e2bf1b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -17,16 +17,6 @@ services: - traefik.http.routers.traefik.service=api@internal restart: ${WARDEN_RESTART_POLICY:-always} - mailhog: - container_name: mailhog - image: 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:latest From 364c8713d3ed62650425f940cf692a3dc6b45134 Mon Sep 17 00:00:00 2001 From: Brett Patterson Date: Sun, 21 Jul 2024 21:31:00 -0400 Subject: [PATCH 2/5] Remove feature flagging of mailpit --- commands/install.cmd | 2 -- commands/svc.cmd | 10 ++-------- docker/docker-compose.mailhog.yml | 10 ---------- 3 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 docker/docker-compose.mailhog.yml diff --git a/commands/install.cmd b/commands/install.cmd index db840b95..86ae2246 100644 --- a/commands/install.cmd +++ b/commands/install.cmd @@ -93,7 +93,5 @@ if [[ ! -f "${WARDEN_HOME_DIR}/.env" ]]; then WARDEN_PORTAINER_ENABLE=0 # Set to "0" to disable DNSMasq WARDEN_DNSMASQ_ENABLE=1 - # Specify which mail trapping service to use: "mailhog" or "mailpit" - WARDEN_MAIL_SERVICE=mailhog EOT fi diff --git a/commands/svc.cmd b/commands/svc.cmd index c20bb744..a8882e05 100644 --- a/commands/svc.cmd +++ b/commands/svc.cmd @@ -27,14 +27,8 @@ if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(grep "^WARDEN_MAIL_SERVICE" "${WARDEN_HOME_DIR}/.env")" fi -WARDEN_MAIL_SERVICE="${WARDEN_MAIL_SERVICE:-mailhog}" -if [[ "$WARDEN_MAIL_SERVICE" == "mailpit" ]]; then - DOCKER_COMPOSE_ARGS+=("-f") - DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.mailpit.yml") -else - DOCKER_COMPOSE_ARGS+=("-f") - DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.mailhog.yml") -fi +DOCKER_COMPOSE_ARGS+=("-f") +DOCKER_COMPOSE_ARGS+=("${WARDEN_DIR}/docker/docker-compose.mailpit.yml") ## add dnsmasq docker-compose WARDEN_DNSMASQ_ENABLE="${WARDEN_DNSMASQ_ENABLE:-1}" diff --git a/docker/docker-compose.mailhog.yml b/docker/docker-compose.mailhog.yml deleted file mode 100644 index 807651ad..00000000 --- a/docker/docker-compose.mailhog.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - mailhog: - container_name: mailhog - image: wardenenv/mailhog:1.0 - labels: - - traefik.enable=true - - traefik.http.routers.mailhog.tls=true - - traefik.http.routers.mailhog.rule=Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) - - traefik.http.services.mailhog.loadbalancer.server.port=8025 - restart: ${WARDEN_RESTART_POLICY:-always} \ No newline at end of file From 5f558458fc2dbacec6f67e335326efd9d9cc8f41 Mon Sep 17 00:00:00 2001 From: Brett Patterson Date: Sun, 21 Jul 2024 21:32:43 -0400 Subject: [PATCH 3/5] Initial attempt at redirecting legacy domain --- docker/docker-compose.mailpit.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker/docker-compose.mailpit.yml b/docker/docker-compose.mailpit.yml index 8944d4b6..7fc92ecd 100644 --- a/docker/docker-compose.mailpit.yml +++ b/docker/docker-compose.mailpit.yml @@ -11,6 +11,15 @@ services: - traefik.http.routers.mailpit.tls=true - traefik.http.routers.mailpit.rule=Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) - traefik.http.services.mailpit.loadbalancer.server.port=8025 + + # Create legacy mailhog redirect middleware + - traefik.http.routers.legacymailhog.tls=true + - traefik.http.routers.legacymailhog.rule=Host(`mailhog.${WARDEN_SERVICE_DOMAIN:-warden.test}`) + - traefik.http.middlewares.legacymailhog.redirectregex.regex=https?://mailhog\\.([^/]+)/?.* + - traefik.http.middlewares.legacymailhog.redirectregex.replacement=https://webmail.$${1}/ + - traefik.http.middlewares.legacymailhog.redirectregex.permanent=true + - traefik.http.routers.legacymailhog.middlewares=legacymailhog + restart: ${WARDEN_RESTART_POLICY:-always} volumes: From 1115f1ddc16c878c56912d8e855d868e0fa5ec95 Mon Sep 17 00:00:00 2001 From: Brett Patterson Date: Tue, 23 Jul 2024 13:28:05 -0400 Subject: [PATCH 4/5] Redirect now works --- docker/docker-compose.mailpit.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/docker/docker-compose.mailpit.yml b/docker/docker-compose.mailpit.yml index 7fc92ecd..0b818f4d 100644 --- a/docker/docker-compose.mailpit.yml +++ b/docker/docker-compose.mailpit.yml @@ -7,20 +7,21 @@ services: volumes: - mailpitdata:/data labels: - - traefik.enable=true - - traefik.http.routers.mailpit.tls=true - - traefik.http.routers.mailpit.rule=Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) - - traefik.http.services.mailpit.loadbalancer.server.port=8025 - - # Create legacy mailhog redirect middleware - - traefik.http.routers.legacymailhog.tls=true - - traefik.http.routers.legacymailhog.rule=Host(`mailhog.${WARDEN_SERVICE_DOMAIN:-warden.test}`) - - traefik.http.middlewares.legacymailhog.redirectregex.regex=https?://mailhog\\.([^/]+)/?.* - - traefik.http.middlewares.legacymailhog.redirectregex.replacement=https://webmail.$${1}/ - - traefik.http.middlewares.legacymailhog.redirectregex.permanent=true - - traefik.http.routers.legacymailhog.middlewares=legacymailhog + traefik.enable: true + traefik.http.routers.mailpit.tls: true + traefik.http.routers.mailpit.priority: 2 + traefik.http.routers.mailpit.rule: Host(`webmail.${WARDEN_SERVICE_DOMAIN:-warden.test}`) + traefik.http.routers.mailpit.service: mailpit + traefik.http.services.mailpit.loadbalancer.server.port: 8025 + # Legacy Mailhog redirect + traefik.http.routers.legacy-mailhog.tls: true + traefik.http.routers.legacy-mailhog.priority: 1 + traefik.http.routers.legacy-mailhog.rule: Host(`mailhog.${WARDEN_SERVICE_DOMAIN:-warden.test}`) + traefik.http.routers.legacy-mailhog.middlewares: legacy-mailhog-redirect + traefik.http.middlewares.legacy-mailhog-redirect.redirectregex.regex: "^https?://mailhog\\.([^/]+)/.*" + traefik.http.middlewares.legacy-mailhog-redirect.redirectregex.replacement: https://webmail.$${1}/ + traefik.http.middlewares.legacy-mailhog-redirect.redirectregex.permanent: true restart: ${WARDEN_RESTART_POLICY:-always} - volumes: mailpitdata: \ No newline at end of file From c3803b51f8865cfb12eff3f386810faba915c16c Mon Sep 17 00:00:00 2001 From: Brett Patterson Date: Tue, 23 Jul 2024 13:29:36 -0400 Subject: [PATCH 5/5] Remove unsupported variable load --- commands/svc.cmd | 2 -- 1 file changed, 2 deletions(-) diff --git a/commands/svc.cmd b/commands/svc.cmd index a8882e05..1b94d494 100644 --- a/commands/svc.cmd +++ b/commands/svc.cmd @@ -23,8 +23,6 @@ if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then eval "$(grep "^WARDEN_DNSMASQ_ENABLE" "${WARDEN_HOME_DIR}/.env")" # Check Portainer eval "$(grep "^WARDEN_PORTAINER_ENABLE" "${WARDEN_HOME_DIR}/.env")" - # Check Mail service - eval "$(grep "^WARDEN_MAIL_SERVICE" "${WARDEN_HOME_DIR}/.env")" fi DOCKER_COMPOSE_ARGS+=("-f")