From b3f12e6c1edc8bede01fea8c03a7c6e490a1fb72 Mon Sep 17 00:00:00 2001 From: Thomas Ailleaume Date: Fri, 19 Aug 2022 18:03:04 +0200 Subject: [PATCH] feat: add mailcatcher docker image for development --- .env.example | 4 ++++ CHANGELOG.md | 1 + README.md | 9 +++++++++ docker-compose.yml | 10 ++++++++++ 4 files changed, 24 insertions(+) diff --git a/.env.example b/.env.example index 155e6a10..e3a65dd2 100644 --- a/.env.example +++ b/.env.example @@ -103,6 +103,10 @@ export DOCKER_CABLE_PORT_FORWARD=28080 #export DOCKER_WEB_VOLUME=./public:/app/public export DOCKER_WEB_VOLUME=.:/app +# mailcatcher Docker image uses them for its default smtp serveur +export SMTP_DOMAIN=mailcatcher +export SMTP_PORT=1025 + # What CPU and memory constraints will be added to your services? When left at # 0 they will happily use as much as needed. # export DOCKER_POSTGRES_CPUS=0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3adb7447..d22ccc91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - `set -o nounset` to `run` script to exit if there's any undefined variables +- docker image `Mailcatcher` for development ### Changed diff --git a/README.md b/README.md index 1da6b914..e5ee9569 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ out for something else on your own. - [Sidekiq](https://github.com/mperham/sidekiq) - [Action Cable](https://guides.rubyonrails.org/action_cable_overview.html) - [ERB](https://guides.rubyonrails.org/layouts_and_rendering.html) +- [MailCatcher](https://mailcatcher.me/) ### Front-end @@ -326,6 +327,14 @@ latest versions of your gems and then write out a new lock file. You can check out the `run` file to see what these commands do in more detail. +If you want to check that your mailing is working and that the emails are integrated +You can use mailcatcher +To do this, you must enter this value +`config.action_mailer.smtp_settings = { address: ENV.fetch("SMTP_DOMAIN"), +port: ENV.fetch("SMTP_PORT"), domain: ENV.fetch("SMTP_DOMAIN") }` +in the file `config/environments/development.rb` + + #### In CI: You'll want to run `docker-compose build` since it will use any existing lock diff --git a/docker-compose.yml b/docker-compose.yml index 52559910..412b46a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -45,6 +45,16 @@ services: volumes: - "redis:/data" + mailcatcher: + restart: on-failure:10 + image: stpaquet/alpinemailcatcher:latest + environment: + - MAIL_LIMIT=70 # docker image default is 50 + - TIMEZONE=Europe/Paris # docker image default is UTC + ports: + - "1080:1080" + - "1025:1025" + web: <<: *default-app deploy: