From 3dd696acf98530fde8378f1e07f25f557d1837e5 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Wed, 16 Jun 2021 19:33:51 +0200 Subject: [PATCH] Deploy Mailcatcher to jenkins, as well Summary: So it's possible to test emails without reading logs Test Plan: tbd Reviewers: #reviewers Subscribers: jenkins-user Differential Revision: https://hub.sealcode.org/D1099 --- docker-compose.yml | 6 +++--- jenkins.prepare.sh | 2 +- jenkins.start.sh | 8 ++++++-- jenkins.stop.sh | 2 +- src/back/app.ts | 14 +++++++++++++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a99c83f..745fcd0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: db: image: mongo:4.4-bionic ports: - - "127.0.0.1:2${SEALIOUS_PORT:-0723}:27017" + - "127.0.0.1:${PORT:-2072}4:27017" test: image: sealious-test:latest build: @@ -16,5 +16,5 @@ services: mailcatcher: image: schickling/mailcatcher:latest ports: - - "127.0.0.1:1080:1080" - - "127.0.0.1:1025:1025" + - "127.0.0.1:${PORT:-108}1:1080" + - "127.0.0.1:${PORT:-102}5:1025" diff --git a/jenkins.prepare.sh b/jenkins.prepare.sh index 839e120..6559635 100755 --- a/jenkins.prepare.sh +++ b/jenkins.prepare.sh @@ -7,7 +7,7 @@ docker-compose down cp secrets.example.json secrets.json -export SEALIOUS_PORT=$PORT +export SEALIOUS_PORT="${PORT}0" SEALIOUS_BASE_URL=$(cat .base_url) export SEALIOUS_BASE_URL diff --git a/jenkins.start.sh b/jenkins.start.sh index e19de74..a771456 100755 --- a/jenkins.start.sh +++ b/jenkins.start.sh @@ -1,16 +1,19 @@ #!/bin/bash -export SEALIOUS_PORT=$PORT +SEALIOUS_PORT="${PORT}0" SEALIOUS_BASE_URL=$(cat .base_url) export SEALIOUS_BASE_URL ./npm.sh run build:front; +docker-compose up -d mailcatcher + docker-compose run --user="$UID"\ -e "SEALIOUS_MONGO_PORT=27017" \ -e "SEALIOUS_MONGO_HOST=db" \ -e "SEALIOUS_PORT=$SEALIOUS_PORT" \ -e "SEALIOUS_BASE_URL=$SEALIOUS_BASE_URL" \ + -e "SEALIOUS_MAILER=mailcatcher" \ -p "${SEALIOUS_PORT}:${SEALIOUS_PORT}" \ -d \ test \ @@ -18,5 +21,6 @@ docker-compose run --user="$UID"\ && echo "App started on $SEALIOUS_PORT" -echo "Deployed to https://${PORT}.dep.sealco.de" +echo "Deployed app to https://${SEALIOUS_PORT}.dep.sealco.de" +echo "Mailcatcher available at https://${PORT}1.dep.sealco.de" echo "Application logs should be available at https://jenkins.sealcode.org/job/Deploy%20to%20dep.sealco.de/ws v2/$PORT/log.html" diff --git a/jenkins.stop.sh b/jenkins.stop.sh index 3078999..0438a0b 100755 --- a/jenkins.stop.sh +++ b/jenkins.stop.sh @@ -1,6 +1,6 @@ #!/bin/bash -export SEALIOUS_PORT=$PORT +export SEALIOUS_PORT="${PORT}0" SEALIOUS_BASE_URL=$(cat .base_url) export SEALIOUS_BASE_URL diff --git a/src/back/app.ts b/src/back/app.ts index fb68ba8..9d914ae 100644 --- a/src/back/app.ts +++ b/src/back/app.ts @@ -1,6 +1,6 @@ import _locreq from "locreq"; import { resolve } from "path"; -import { App } from "sealious"; +import { App, LoggerMailer, SMTPMailer } from "sealious"; import tasks from "./collections/tasks"; const locreq = _locreq(__dirname); @@ -31,6 +31,9 @@ export default class TheApp extends App { "www-server": { port: PORT, }, + core: { + environment: "production", // to send the full html emails + }, }; manifest = { name: "Sealious Playground", @@ -47,4 +50,13 @@ export default class TheApp extends App { ...App.BaseCollections, tasks, }; + mailer = + process.env.SEALIOUS_MAILER === "mailcatcher" + ? new SMTPMailer({ + host: "mailcatcher", + port: 1025, + user: "any", + password: "any", + }) + : new LoggerMailer(); }