Skip to content

Commit

Permalink
Switch from MailDev to Mailpit
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewL246 committed May 30, 2024
1 parent f0c300a commit 70df1c0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
redis-commander:
restart: no
ports: !reset []
maildev:
mailpit:
restart: no
ports: !reset []
postgres:
Expand Down
19 changes: 7 additions & 12 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,23 @@ services:
env_file:
- ./environment/redis-commander.env

# TODO: MailDev appears to be unmaintained and has security vulnerabilities.
# Find an alternative. MailCatcher doesn't support persistance, and MailHog
# also seems unmaintained.
maildev:
image: maildev/maildev:latest
mailpit:
image: axllent/mailpit:latest
depends_on:
- coredns-internal
restart: unless-stopped
ports:
# MailDev web UI
# Mailpit web UI
- 127.0.0.1:8084:8084
volumes:
- type: volume
source: maildev-mail
source: mailpit-mail
target: /data
networks:
internal:
dns: 172.20.0.200
env_file:
- ./environment/maildev.env
# We need to set the user to root so that MailDev can write to the volume.
user: root
- ./environment/mailpit.env

postgres:
image: postgres:alpine
Expand Down Expand Up @@ -218,7 +213,7 @@ services:
- mongodb
- minio
- redis
- maildev
- mailpit
restart: unless-stopped
ports:
# Node.js debugger
Expand Down Expand Up @@ -421,7 +416,7 @@ volumes:
mongodb-database:
minio-s3-data:
redis-data:
maildev-mail:
mailpit-mail:
postgres-database:

networks:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ to authenticate with the servers.
| [Mongo Express](https://github.com/mongo-express/mongo-express) | Simple web GUI for MongoDB administration. | Open [127.0.0.1:8082](http://127.0.0.1:8082) in your browser with the container running. |
| [MinIO](https://min.io/) | Object store compatable with the AWS S3 API. It is used as file storage and a CDN for the Pretendo servers. Mii images, Juxtaposition screenshots, and more are uploaded here. | Open [127.0.0.1:8083](http://127.0.0.1:8083) in your browser with the container running. |
| [Redis](https://redis.io/) | Cache database used by the account server. | No administration necessary. |
| [MailDev](https://maildev.github.io/maildev/) | SMTP server used to test sending emails from the account server. Use this to view your PNID email verification code. | Open [127.0.0.1:8084](http://127.0.0.1:8084) in your browser with the container running. |
| [Mailpit](https://mailpit.axllent.org/) | SMTP server used to test sending emails from the account server. Use this to view your PNID email verification code. | Open [127.0.0.1:8084](http://127.0.0.1:8084) in your browser with the container running. |
| [PostgreSQL](https://www.postgresql.org/) | Secondary database used by Friends and many game servers. | Use Adminer (see below) to view the databases and run SQL scripts. You can also download the [pgAdmin GUI](https://www.pgadmin.org/) and connect to `127.0.0.1:5432` to perform advanced administration tasks. |
| [Adminer](https://www.adminer.org/) | Web GUI for database administration, used for Postgres. | Open [127.0.0.1:8085](http://127.0.0.1:8085) in your browser with the container running. |
| [Redis Commander](https://joeferner.github.io/redis-commander/) | Web GUI for Redis database administration. | Open [127.0.0.1:8086](http://127.0.0.1:8086) in your browser with the container running. |
Expand Down
4 changes: 2 additions & 2 deletions environment/account.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ PN_ACT_CONFIG_S3_ENDPOINT=http://minio.pretendo.cc
PN_ACT_CONFIG_S3_ACCESS_KEY=minio_pretendo
PN_ACT_CONFIG_CDN_BASE_URL=http://pretendo-cdn.b-cdn.net
PN_ACT_CONFIG_CDN_SUBDOMAIN=cdn
PN_ACT_CONFIG_EMAIL_HOST=maildev
PN_ACT_CONFIG_EMAIL_HOST=mailpit
PN_ACT_CONFIG_EMAIL_PORT=1025
PN_ACT_CONFIG_EMAIL_SECURE=false
PN_ACT_CONFIG_EMAIL_USERNAME=pretendo_mail
PN_ACT_CONFIG_EMAIL_PASSWORD=password
PN_ACT_CONFIG_EMAIL_FROM="Jon Pretendo <jon@maildev.pretendo.cc>"
PN_ACT_CONFIG_EMAIL_FROM="Jon Pretendo <jon@mail.pretendo.cc>"
PN_ACT_CONFIG_GRPC_PORT=5000
PN_ACT_CONFIG_SERVER_ENVIRONMENT=prod
3 changes: 0 additions & 3 deletions environment/maildev.env

This file was deleted.

3 changes: 3 additions & 0 deletions environment/mailpit.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MP_SMTP_BIND_ADDR=0.0.0.0:1025
MP_UI_BIND_ADDR=0.0.0.0:8084
MP_DATABASE=/data/mailpit.db
5 changes: 4 additions & 1 deletion scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mkdir -p "$backup_dir"
print_info "Backing up to $backup_dir"

print_info "Starting necessary services..."
compose_no_progress up -d mitmproxy-pretendo mongodb postgres minio redis
compose_no_progress up -d mitmproxy-pretendo mongodb postgres minio redis mailpit

print_info "Backing up MongoDB..."
run_verbose docker compose exec mongodb rm -rf /tmp/backup
Expand All @@ -49,4 +49,7 @@ run_verbose compose_no_progress cp redis:/data/dump.rdb "$backup_dir/redis.rdb"
print_info "Backing up Mitmproxy..."
run_verbose compose_no_progress cp mitmproxy-pretendo:/home/mitmproxy/.mitmproxy "$backup_dir/mitmproxy"

print_info "Backing up Mailpit..."
run_verbose compose_no_progress cp mailpit:/data/mailpit.db "$backup_dir/mailpit.db"

print_success "Backup completed successfully."
6 changes: 5 additions & 1 deletion scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fi
print_info "Stopping unnecessary services..."
compose_no_progress down
print_info "Starting necessary services..."
compose_no_progress up -d mitmproxy-pretendo mongodb postgres minio redis
compose_no_progress up -d mitmproxy-pretendo mongodb postgres minio redis mailpit

print_info "Restoring MongoDB..."
run_verbose docker compose exec mongodb rm -rf /tmp/backup
Expand Down Expand Up @@ -61,6 +61,10 @@ print_info "Restoring Mitmproxy..."
run_verbose compose_no_progress stop mitmproxy-pretendo
run_verbose compose_no_progress cp "$backup_dir/mitmproxy" mitmproxy-pretendo:/home/mitmproxy/.mitmproxy

print_info "Restoring Mailpit..."
run_verbose compose_no_progress stop mailpit
run_verbose compose_no_progress cp "$backup_dir/mailpit.db" mailpit:/data/mailpit.db

# The restored backup might be using different secrets than what are currently in the .env files
"$git_base_dir/scripts/setup-environment.sh" --force

Expand Down

0 comments on commit 70df1c0

Please sign in to comment.