feat: add support for sending email to the docker image
This commit is contained in:
parent
31f5063a96
commit
ea572cb82a
4 changed files with 62 additions and 4 deletions
|
@ -1,6 +1,8 @@
|
|||
FROM debian:12-slim
|
||||
RUN <<EOF
|
||||
set -e
|
||||
export PHP_VERSION=8.3
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export DEBCONF_NONINTERACTIVE_SEEN=true
|
||||
apt-get update && apt-get dist-upgrade -uy
|
||||
|
@ -13,9 +15,9 @@ RUN <<EOF
|
|||
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" \
|
||||
> /etc/apt/sources.list.d/php.list
|
||||
apt-get update
|
||||
apt-get install -y apache2 libapache2-mod-php8.3 \
|
||||
php8.3-cli php8.3-opcache php8.3-pgsql \
|
||||
php8.3-xml socat
|
||||
apt-get install -y apache2 libapache2-mod-php${PHP_VERSION} msmtp \
|
||||
php${PHP_VERSION}-cli php${PHP_VERSION}-opcache \
|
||||
php${PHP_VERSION}-pgsql php${PHP_VERSION}-xml socat
|
||||
|
||||
adduser --system --ingroup www-data \
|
||||
--shell '/bin/false' \
|
||||
|
@ -23,6 +25,13 @@ RUN <<EOF
|
|||
--home /opt/lwb5 --no-create-home \
|
||||
lwticks
|
||||
|
||||
for what in apache2 cli; do
|
||||
cat >/etc/php/${PHP_VERSION}/${what}/conf.d/99-smtp.ini <<EOC
|
||||
[mail function]
|
||||
sendmail_path = "/usr/bin/msmtp -t"
|
||||
EOC
|
||||
done
|
||||
|
||||
a2dismod mpm_event
|
||||
a2enmod mpm_prefork
|
||||
/bin/echo -e "Listen 80\nListen 81" > /etc/apache2/ports.conf
|
||||
|
|
|
@ -44,14 +44,22 @@ services:
|
|||
- planets:/opt/lwb5/site/static/beta5/pics/pl:ro
|
||||
- pgen:/var/spool/pgen:rw
|
||||
environment:
|
||||
LW_DB_HOST: db
|
||||
LW_DB_ADMIN_PASS_FILE: /run/secrets/lw_db_admin_pass
|
||||
LW_DB_HOST: db
|
||||
LW_DB_USER_PASS_FILE: /run/secrets/lw_db_user_pass
|
||||
LW_MAIL_FROM: ${LW_MAIL_FROM}
|
||||
LW_SEND_MAIL: ${LW_SEND_MAIL}
|
||||
LW_STATIC_URL: ${LW_STATIC_URL}
|
||||
SMTP_AUTH: ${SMTP_AUTH}
|
||||
SMTP_ENVFROM: ${SMTP_ENVFROM}
|
||||
SMTP_HOST: ${SMTP_HOST}
|
||||
SMTP_PORT: ${SMTP_PORT}
|
||||
SMTP_TLS: ${SMTP_TLS}
|
||||
SMTP_USER: ${SMTP_USER}
|
||||
secrets:
|
||||
- lw_db_user_pass
|
||||
- lw_db_admin_pass
|
||||
- smtp_password
|
||||
|
||||
planetgen:
|
||||
build:
|
||||
|
@ -81,3 +89,5 @@ secrets:
|
|||
environment: LW_ADMIN_PASSWORD
|
||||
lw_peacekeepers_password:
|
||||
environment: LW_PEACEKEEPERS_PASSWORD
|
||||
smtp_password:
|
||||
environment: SMTP_PASSWORD
|
||||
|
|
|
@ -1,10 +1,25 @@
|
|||
# Password for the database superuser
|
||||
DB_PASSWORD=...
|
||||
|
||||
# SMTP - Outgoing server
|
||||
SMTP_HOST=smtp.example.org
|
||||
# SMTP - Port number
|
||||
SMTP_PORT=587
|
||||
# SMTP - Enable TLS? (on/off)
|
||||
SMTP_TLS=on
|
||||
# SMTP - Authenticate to outgoing server? (on/off)
|
||||
SMTP_AUTH=on
|
||||
# SMTP - User name
|
||||
SMTP_USER=...
|
||||
# SMTP - Password
|
||||
SMTP_PASSWORD=...
|
||||
|
||||
# URL of the static assets from an external perspective
|
||||
LW_STATIC_URL=http://localhost/static
|
||||
# Send email? (yes or no)
|
||||
LW_SEND_MAIL=no
|
||||
# Source address for LW mails
|
||||
LW_MAIL_FROM=legacyworlds@example.org
|
||||
|
||||
# Legacyworlds database - Main user
|
||||
LW_DB_USER_PASS=...
|
||||
|
|
|
@ -1,5 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
(
|
||||
cat <<EOF
|
||||
defaults
|
||||
tls $SMTP_TLS
|
||||
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||
syslog on
|
||||
|
||||
account account
|
||||
host $SMTP_HOST
|
||||
port $SMTP_PORT
|
||||
auth $SMTP_AUTH
|
||||
from $LW_MAIL_FROM
|
||||
EOF
|
||||
if [ "$SMTP_AUTH" = "on" ]; then
|
||||
echo "user $SMTP_USER"
|
||||
echo 'passwordeval "cat /run/secrets/smtp_password"'
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
account default : account
|
||||
aliases /etc/aliases
|
||||
EOF
|
||||
) > /etc/msmtprc
|
||||
|
||||
socat -u \
|
||||
UNIX-LISTEN:/dev/log,reuseaddr,mode=666,fork \
|
||||
SYSTEM:"(sed -z 's/$/\\\\n/'; /bin/echo)" \
|
||||
|
|
Loading…
Reference in a new issue