From 82dc9b076d3d88b8b1099c2dbfd94e34276a9a0b Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Wed, 20 Mar 2024 18:41:25 -0300 Subject: [PATCH 1/6] Add MailHog container to provide login with email without extra config --- .env.sample | 4 ++-- README.md | 13 +++++++++++++ docker-compose.yml | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.env.sample b/.env.sample index e93f2ac9..5364b26e 100644 --- a/.env.sample +++ b/.env.sample @@ -12,8 +12,8 @@ TWITTER_ID= TWITTER_SECRET= # email -LOGIN_EMAIL_SERVER= -LOGIN_EMAIL_FROM= +LOGIN_EMAIL_SERVER=smtp://mailhog:1025 +LOGIN_EMAIL_FROM=sndev@mailhog.dev LIST_MONK_AUTH= ######################################################## diff --git a/README.md b/README.md index 2c39421a..32df8622 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,19 @@ You can login to test features like posting, replying, tipping, etc with `./snde ### Login with Email +#### MailHog + +- The app is already prepared to send emails through (MailHog)[https://github.com/mailhog/MailHog] so no extra configuration is needed +- Click "sign up" and enter any email address (remember, it's not going anywhere beyond your workstation) +- Access MailHog's web UI on http://localhost:1025 +- Click the link (looks like this): + +``` +http://localhost:3000/api/auth/callback/email?email=satoshi%40gmail.com&token=110e30a954ce7ca643379d90eb511640733de405f34a31b38eeda8e254d48cd7 +``` + +#### Sendgrid + - Create a Sendgrid account (or other smtp service) ``` diff --git a/docker-compose.yml b/docker-compose.yml index c24838c8..401027bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -377,6 +377,21 @@ services: command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME} volumes: - /var/run/docker.sock:/var/run/docker.sock:ro + mailhog: + image: mailhog/mailhog:latest + container_name: mailhog + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8025"] + interval: 10s + timeout: 10s + retries: 10 + start_period: 1m + ports: + - "8025:8025" + - "1025:1025" + links: + - app volumes: db: os: From 4d02bae826a10354f598d371002e63dc672ceed5 Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Wed, 20 Mar 2024 20:40:13 -0300 Subject: [PATCH 2/6] Fix mailhog link on README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32df8622..d5dfb539 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ You can login to test features like posting, replying, tipping, etc with `./snde #### MailHog -- The app is already prepared to send emails through (MailHog)[https://github.com/mailhog/MailHog] so no extra configuration is needed +- The app is already prepared to send emails through [MailHog](https://github.com/mailhog/MailHog) so no extra configuration is needed - Click "sign up" and enter any email address (remember, it's not going anywhere beyond your workstation) - Access MailHog's web UI on http://localhost:1025 - Click the link (looks like this): From 561e62481df69c7b860dc6015cfe42607d5e1574 Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Thu, 21 Mar 2024 09:16:29 -0300 Subject: [PATCH 3/6] Add 'profiles: email' to the MailHog container --- README.md | 8 +++++++- docker-compose.yml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d5dfb539..43bc05c0 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Start the development environment $ ./sndev start ``` -By default all services will be run. If you want to exclude specific services from running, set `COMPOSE_PROFILES` to use one or more of `minimal|images|search|payments`. To only run mininal services without images, search, or payments: +By default all services will be run. If you want to exclude specific services from running, set `COMPOSE_PROFILES` to use one or more of `minimal|images|search|payments|email`. To only run mininal services without images, search, or payments: ```sh $ COMPOSE_PROFILES=minimal ./sndev start @@ -61,6 +61,12 @@ To run with images and payments services: $ COMPOSE_PROFILES=images,payments ./sndev start ``` +To run with the option to sign up/login using [MailHog](#MailHog): + +```sh +$ COMPOSE_PROFILES=email ./sndev start +``` + View all available commands ```sh diff --git a/docker-compose.yml b/docker-compose.yml index 401027bf..50171b89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -380,6 +380,8 @@ services: mailhog: image: mailhog/mailhog:latest container_name: mailhog + profiles: + - email restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8025"] From eef9b3de4d0c0ae3dbab9671a81737cbef108332 Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Thu, 21 Mar 2024 15:02:58 -0300 Subject: [PATCH 4/6] Add email to COMPOSE_PROFILES on sndev + Cleanup README instructions --- README.md | 6 ------ sndev | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 43bc05c0..668ab07b 100644 --- a/README.md +++ b/README.md @@ -61,12 +61,6 @@ To run with images and payments services: $ COMPOSE_PROFILES=images,payments ./sndev start ``` -To run with the option to sign up/login using [MailHog](#MailHog): - -```sh -$ COMPOSE_PROFILES=email ./sndev start -``` - View all available commands ```sh diff --git a/sndev b/sndev index 4ac0623d..7b542f80 100755 --- a/sndev +++ b/sndev @@ -10,7 +10,7 @@ docker__compose() { fi if [ -z "$COMPOSE_PROFILES" ]; then - COMPOSE_PROFILES="images,search,payments" + COMPOSE_PROFILES="images,search,payments,email" fi CURRENT_UID=$(id -u) CURRENT_GID=$(id -g) COMPOSE_PROFILES=$COMPOSE_PROFILES command docker compose --env-file .env.development "$@" From 06005e3e40f985dc260af8fb935cb78ffcd1c22d Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Mon, 25 Mar 2024 09:09:35 -0300 Subject: [PATCH 5/6] Fix mailhog web UI url on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 668ab07b..f016e20f 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,7 @@ You can login to test features like posting, replying, tipping, etc with `./snde - The app is already prepared to send emails through [MailHog](https://github.com/mailhog/MailHog) so no extra configuration is needed - Click "sign up" and enter any email address (remember, it's not going anywhere beyond your workstation) -- Access MailHog's web UI on http://localhost:1025 +- Access MailHog's web UI on http://localhost:8025 - Click the link (looks like this): ``` From e919efc144003727eb435ba6bf3e5fd93c4a9519 Mon Sep 17 00:00:00 2001 From: Felipe Bueno Date: Mon, 25 Mar 2024 09:26:45 -0300 Subject: [PATCH 6/6] MailHog healthcheck with wget instead of curl --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 50171b89..ced370d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -384,7 +384,7 @@ services: - email restart: unless-stopped healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8025"] + test: ["CMD", "wget", "-q", "--spider", "http://localhost:8025"] interval: 10s timeout: 10s retries: 10