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

Add optional (opt-in) support for Mailpit #779

Merged
merged 5 commits into from
Aug 5, 2024
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
2 changes: 1 addition & 1 deletion commands/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ 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
EOT
fi
3 changes: 3 additions & 0 deletions commands/svc.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if [[ -f "${WARDEN_HOME_DIR}/.env" ]]; then
eval "$(grep "^WARDEN_PORTAINER_ENABLE" "${WARDEN_HOME_DIR}/.env")"
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}"
if [[ "$WARDEN_DNSMASQ_ENABLE" == "1" ]]; then
Expand Down
27 changes: 27 additions & 0 deletions docker/docker-compose.mailpit.yml
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tags in this file don't use the "array of strings" format because the redirect wasn't working unless I used the object style notation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
mailpit:
container_name: mailhog
Copy link
Contributor

@ihor-sviziev ihor-sviziev Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the container name is mailhog?
Just During upgrade, it caused a conflict
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility so you can still reference "mailhog" but it's really just mailpit. This can easily be removed and whatever breaks will need to be upgraded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simple solution would be: warden svc down --remove-orphans && warden svc up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I did like that and it worked. But I got confused that container is named mailhog, while we don't have such service and domain. So I would prefer removing this line

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.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:
10 changes: 0 additions & 10 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down