Skip to content

Commit

Permalink
Replace MailHog with Mailpit
Browse files Browse the repository at this point in the history
  • Loading branch information
back-2-95 committed Aug 14, 2023
1 parent b52c941 commit 930e143
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 35 deletions.
27 changes: 16 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
ARG TRAEFIK_VERSION

#
# MailHog
# Mailpit binary
#
FROM golang:alpine as mailhog-builder
FROM golang:alpine as mailpit-builder

ARG MAILHOG_VERSION=1.0.1
WORKDIR /go/src/github.com/mailhog/MailHog
ADD https://github.com/mailhog/MailHog/archive/v${MAILHOG_VERSION}.tar.gz .
RUN tar --strip-components=1 -zxf v${MAILHOG_VERSION}.tar.gz -C .
RUN GO111MODULE=off CGO_ENABLED=0 go install -ldflags='-s -w'
ARG MAILPIT_VERSION=1.8.1

WORKDIR /app

ADD https://github.com/axllent/mailpit/archive/refs/tags/v${MAILPIT_VERSION}.tar.gz .

RUN apk add --no-cache git npm
RUN tar --strip-components=1 -zxf v${MAILPIT_VERSION}.tar.gz -C .
RUN npm install && npm run package
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/axllent/mailpit/config.Version=${MAILPIT_VERSION}" -o /mailpit

#
# Traefik
# Stonehenge
#
FROM traefik:${TRAEFIK_VERSION}
FROM traefik:${TRAEFIK_VERSION} as stonehenge

LABEL org.opencontainers.image.authors="Druid.fi" maintainer="Druid.fi"
LABEL org.opencontainers.image.source="https://github.com/druidfi/stonehenge" repository="https://github.com/druidfi/stonehenge"
Expand Down Expand Up @@ -50,8 +55,8 @@ COPY traefik/dynamic/traefik.dynamic.yml /configuration/traefik.dynamic.yml
COPY traefik/add-service.sh /usr/local/bin/add-service
COPY traefik/remove-service.sh /usr/local/bin/remove-service

# Copy Mailhog binary
COPY --from=mailhog-builder /go/bin/MailHog /usr/local/bin/
# Copy Mailpit binary
COPY --from=mailpit-builder /mailpit /usr/local/bin/

# Copy Catch-all confs
COPY catchall/nginx.conf /etc/nginx/http.d/default.conf
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ domains for your projects as well as SSL certificates for those domains out of t

- [Traefik](https://traefik.io/traefik/) in [traefik.docker.so](https://traefik.docker.so) to handle all traffic to containers
- [mkcert](https://github.com/FiloSottile/mkcert) generated wildcard SSL certificate
- [MailHog](https://github.com/mailhog/MailHog) in [mailhog.docker.so](https://mailhog.docker.so) to catch emails
- [Mailpit](https://github.com/axllent/mailpit) in [mailpit.docker.so](https://mailpit.docker.so) to catch emails

## Setup

Expand Down Expand Up @@ -162,7 +162,7 @@ make debug

## References

- [https://github.com/mailhog/MailHog](https://github.com/mailhog/MailHog)
- [https://github.com/axllent/mailpit](https://github.com/axllent/mailpit)
- [https://github.com/FiloSottile/mkcert](https://github.com/FiloSottile/mkcert)
- [https://traefik.io/](https://traefik.io/)

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
command: |-
--providers.docker.network="${PREFIX}-network"
environment:
MAILHOG_HOST: mailhog.${DOCKER_DOMAIN}
MAILPIT_HOST: mailpit.${DOCKER_DOMAIN}
TRAEFIK_HOST: traefik.${DOCKER_DOMAIN}
ports:
- "${HTTPS_PORT:-443}:443"
Expand Down
16 changes: 8 additions & 8 deletions examples/drupal/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
services:

app:
hostname: "drupal.docker.so"
container_name: "drupal-example-app"
image: "druidfi/drupal-test:php-8.2"
hostname: drupal.docker.so
container_name: drupal-example-app
image: druidfi/drupal-test:php-8.2
depends_on:
- db
environment:
APP_ENV: "prod"
DRUPAL_ROUTES: "https://drupal.docker.so"
PHP_SENDMAIL_PATH: "/usr/sbin/sendmail -S stonehenge-mailhog:1025"
APP_ENV: prod
DRUPAL_ROUTES: https://drupal.docker.so
PHP_SENDMAIL_PATH: /usr/sbin/sendmail -S stonehenge:1025
labels:
traefik.enable: "true"
traefik.http.routers.drupal-example-app.entrypoints: https
Expand All @@ -22,8 +22,8 @@ services:
- stonehenge-network

db:
container_name: "drupal-example-db"
image: druidfi/mariadb:10.7-drupal
container_name: drupal-example-db
image: druidfi/mariadb:10.11-drupal-lts

networks:
stonehenge-network:
Expand Down
4 changes: 2 additions & 2 deletions make/stonehenge.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ PHONY += --up-post-actions
$(call step,You can now access Stonehenge services with these URLs:)
ifdef HTTPS_PORT
$(call item,- https://traefik.${DOCKER_DOMAIN}:$(HTTPS_PORT))
$(call item,- https://mailhog.${DOCKER_DOMAIN}:$(HTTPS_PORT))
$(call item,- https://mailpit.${DOCKER_DOMAIN}:$(HTTPS_PORT))
else
$(call item,- https://traefik.${DOCKER_DOMAIN})
$(call item,- https://mailhog.${DOCKER_DOMAIN})
$(call item,- https://mailpit.${DOCKER_DOMAIN})
endif
$(call success,SUCCESS! Happy Developing!)

Expand Down
6 changes: 6 additions & 0 deletions tests/email.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
From: sender@example.com
To: recipient@example.com
Subject: Email Subject

This is the body of the email.
It can contain multiple lines of text.
14 changes: 7 additions & 7 deletions traefik/dynamic/traefik.dynamic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ http:
service: api@internal
tls: true

mailhog_http:
mailpit_http:
entryPoints: http
rule: Host(`{{ env "MAILHOG_HOST" }}`)
service: mailhog@file
rule: Host(`{{ env "MAILPIT_HOST" }}`)
service: mailpit@file
middlewares: redirect-to-https@file
mailhog:
mailpit:
entryPoints: https
rule: Host(`{{ env "MAILHOG_HOST" }}`)
service: mailhog@file
rule: Host(`{{ env "MAILPIT_HOST" }}`)
service: mailpit@file
tls: true

catchall_http:
Expand All @@ -51,7 +51,7 @@ http:
servers:
- url: "http://stonehenge:8080"

mailhog:
mailpit:
loadBalancer:
servers:
- url: "http://stonehenge:8025"
Expand Down
8 changes: 4 additions & 4 deletions traefik/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ start_nginx(){
exec nginx -g 'daemon off;'
}

start_mailhog(){
echo "Start up MailHog..."
exec MailHog &
start_mailpit(){
echo "Start up Mailpit..."
exec mailpit --verbose &
}

create_ssh_proxy &
start_nginx &
start_mailhog &
start_mailpit &

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
Expand Down

0 comments on commit 930e143

Please sign in to comment.