Skip to content

Commit

Permalink
Merge pull request #76 from druidfi/mailpit
Browse files Browse the repository at this point in the history
Replace MailHog with Mailpit
  • Loading branch information
back-2-95 authored Aug 16, 2023
2 parents aee47c4 + f079936 commit 1bb1b4f
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ PREFIX=stonehenge
STONEHENGE_VERSION=4

# Image versions
STONEHENGE_TAG=4.0
STONEHENGE_TAG=4.1
35 changes: 21 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
ARG TRAEFIK_VERSION
ARG MAILPIT_VERSION=1.8.2

#
# 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
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"

ARG MAILPIT_VERSION
ARG TRAEFIK_VERSION
ARG TARGETARCH
ARG USER=druid
Expand All @@ -28,11 +34,12 @@ ENV CAROOT=/ssl
ENV SOCKET_DIR=/tmp/${USER}_ssh-agent
ENV SSH_AUTH_SOCK=${SOCKET_DIR}/socket
ENV SSH_AUTH_PROXY_SOCK=${SOCKET_DIR}/proxy-socket
ENV MAILPIT_VERSION=${MAILPIT_VERSION}
ENV TRAEFIK_VERSION=${TRAEFIK_VERSION}

RUN wget -O /usr/local/bin/mkcert "https://dl.filippo.io/mkcert/latest?for=linux/${TARGETARCH}"

RUN apk --update --no-cache add bind-tools nginx openssh socat sudo && \
RUN apk --update --no-cache add bind-tools nginx openssh socat sudo tzdata && \
adduser -D -u ${UID} ${USER} && \
mkdir ${SOCKET_DIR} && chown ${USER} ${SOCKET_DIR} && \
chmod +x /usr/local/bin/mkcert && \
Expand All @@ -50,14 +57,14 @@ 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
COPY catchall/index.html /usr/share/nginx/html/index.html

# Expose the SMTP and HTTP ports used by default by MailHog:
EXPOSE 1025 8025
# Expose the SMTP and HTTP ports used by default by Mailpit:
EXPOSE 1025/tcp 8025/tcp

VOLUME ${SOCKET_DIR}
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
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "REPO_NAME" {
}

variable "TRAEFIK_VERSION" {
default = "2.10.3"
default = "2.10.4"
}

group "default" {
Expand All @@ -24,5 +24,5 @@ target "traefik" {
args = {
TRAEFIK_VERSION = "${TRAEFIK_VERSION}"
}
tags = ["${REPO_NAME}:4", "${REPO_NAME}:4.0", "${REPO_NAME}:latest"]
tags = ["${REPO_NAME}:4", "${REPO_NAME}:4.1", "${REPO_NAME}:latest"]
}
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 -t
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: [email protected]
To: [email protected]
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 ${MAILPIT_VERSION}..."
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 1bb1b4f

Please sign in to comment.