From 70df1c0aa808e84bd0788a66594b720702d03a8a Mon Sep 17 00:00:00 2001 From: Matthew Lopez <73856503+MatthewL246@users.noreply.github.com> Date: Thu, 30 May 2024 14:26:23 -0400 Subject: [PATCH] Switch from MailDev to Mailpit --- .github/compose.ci.yml | 2 +- compose.yml | 19 +++++++------------ docs/docs/containers.md | 2 +- environment/account.env | 4 ++-- environment/maildev.env | 3 --- environment/mailpit.env | 3 +++ scripts/backup.sh | 5 ++++- scripts/restore.sh | 6 +++++- 8 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 environment/maildev.env create mode 100644 environment/mailpit.env diff --git a/.github/compose.ci.yml b/.github/compose.ci.yml index 8c57e55..4154aba 100644 --- a/.github/compose.ci.yml +++ b/.github/compose.ci.yml @@ -27,7 +27,7 @@ services: redis-commander: restart: no ports: !reset [] - maildev: + mailpit: restart: no ports: !reset [] postgres: diff --git a/compose.yml b/compose.yml index e72f570..6d281b2 100644 --- a/compose.yml +++ b/compose.yml @@ -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 @@ -218,7 +213,7 @@ services: - mongodb - minio - redis - - maildev + - mailpit restart: unless-stopped ports: # Node.js debugger @@ -421,7 +416,7 @@ volumes: mongodb-database: minio-s3-data: redis-data: - maildev-mail: + mailpit-mail: postgres-database: networks: diff --git a/docs/docs/containers.md b/docs/docs/containers.md index c8ea630..7e94b6d 100644 --- a/docs/docs/containers.md +++ b/docs/docs/containers.md @@ -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. | diff --git a/environment/account.env b/environment/account.env index 6f51a2e..f12e6e0 100644 --- a/environment/account.env +++ b/environment/account.env @@ -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 " +PN_ACT_CONFIG_EMAIL_FROM="Jon Pretendo " PN_ACT_CONFIG_GRPC_PORT=5000 PN_ACT_CONFIG_SERVER_ENVIRONMENT=prod diff --git a/environment/maildev.env b/environment/maildev.env deleted file mode 100644 index 425678d..0000000 --- a/environment/maildev.env +++ /dev/null @@ -1,3 +0,0 @@ -MAILDEV_SMTP_PORT=1025 -MAILDEV_WEB_PORT=8084 -MAILDEV_MAIL_DIRECTORY=/data diff --git a/environment/mailpit.env b/environment/mailpit.env new file mode 100644 index 0000000..22ef08e --- /dev/null +++ b/environment/mailpit.env @@ -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 diff --git a/scripts/backup.sh b/scripts/backup.sh index a9fa118..4fa9ddd 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -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 @@ -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." diff --git a/scripts/restore.sh b/scripts/restore.sh index 85ce08d..3e768f8 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -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 @@ -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