From e98ec8c950b0b0061595b2bcc5ffed84be1219d9 Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Mon, 19 Sep 2022 13:04:49 +0000 Subject: [PATCH] build(docker): add email configuration for the docker image --- docker/production/app/entrypoint.sh | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docker/production/app/entrypoint.sh b/docker/production/app/entrypoint.sh index b5b1f3ed..7246b533 100644 --- a/docker/production/app/entrypoint.sh +++ b/docker/production/app/entrypoint.sh @@ -143,6 +143,54 @@ cache.redis.database=${CP_REDIS_DATABASE} EOF fi +if [ ! -z "${CP_EMAIL_SMTP_HOST}" ] +then + if [ -z "${CP_EMAIL_SMTP_USERNAME}" ] + then + echo "When CP_EMAIL_SMTP_HOST is provided, CP_EMAIL_SMTP_USERNAME must be set" + exit 1 + fi + + if [ -z "${CP_EMAIL_SMTP_PASSWORD}" ] + then + echo "When CP_EMAIL_SMTP_HOST is provided, CP_EMAIL_SMTP_PASSWORD must be set" + exit 1 + fi + + if [ -z "${CP_EMAIL_FROM}" ] + then + echo "When CP_EMAIL_SMTP_HOST is provided, CP_EMAIL_FROM must be set" + exit 1 + fi + + cat << EOF >> /opt/castopod/.env +email.protocol="smtp" +email.SMTPHost="${CP_EMAIL_SMTP_HOST}" +email.SMTPUser=${CP_EMAIL_SMTP_USERNAME} +email.SMTPPass=${CP_EMAIL_SMTP_PASSWORD} +email.fromEmail=${CP_EMAIL_FROM} +EOF + + if [ ! -z "${CP_EMAIL_SMTP_PORT}" ] + then + cat << EOF >> /opt/castopod/.env +email.SMTPPort=${CP_EMAIL_SMTP_PORT} +EOF + fi + + if [ ! -z "${CP_EMAIL_SMTP_CRYPTO}" ] + then + if [ "${CP_EMAIL_SMTP_CRYPTO}" != "ssl" ] && [ "${CP_EMAIL_SMTP_CRYPTO}" != "tls" ] + then + echo "CP_EMAIL_SMTP_CRYPTO must be ssl or tls" + exit 1 + fi + cat << EOF >> /opt/castopod/.env +email.SMTPCrypto=${CP_EMAIL_SMTP_CRYPTO} +EOF + fi +fi + echo "Using config:" cat /opt/castopod/.env