Adding a custom dockerfile based on the official WordPress docker file with MSMTP install and configured.
This sets the default SMTP details for the server to those of MailHog.
volumes: | |
db_data: | |
version: '3.7' | |
services: | |
mysql: | |
container_name: mysql | |
image: mysql:5.7 | |
volumes: | |
- ./db:/docker-entrypoint-initdb.d | |
- ./db_data:/var/lib/mysql | |
restart: always | |
ports: | |
- 3306:3306 | |
environment: | |
MYSQL_ROOT_PASSWORD: wordpress | |
MYSQL_DATABASE: wordpress | |
MYSQL_USER: wordpress | |
MYSQL_PASSWORD: wordpress | |
wordpress: | |
container_name: wordpress | |
build: | |
dockerfile: ./wordpress.dockerfile | |
context: . | |
volumes: | |
- ./:/var/www/ | |
- ./php.ini:/usr/local/etc/php/php.ini | |
depends_on: | |
- mysql | |
links: | |
- mysql:mysql | |
restart: always | |
ports: | |
- 8080:80 | |
environment: | |
WORDPRESS_DB_HOST: mysql:3306 | |
WORDPRESS_DB_NAME: wordpress | |
WORDPRESS_DB_USER: wordpress | |
WORDPRESS_DB_PASSWORD: wordpress | |
mailhog: | |
container_name: mailhog | |
image: mailhog/mailhog:latest | |
restart: always | |
ports: | |
- 1025:1025 | |
- 8025:8025 | |
volumes: | |
wordpress: | |
db_data: |
# Set default values for all following accounts. | |
account default | |
host mailhog | |
port 1025 | |
from webmaster@localhost | |
tls off | |
tls_starttls off | |
syslog LOG_MAIL | |
logfile /var/www/msmtp.log |
sendmail_path = "/usr/bin/msmtp -t" | |
mail.log = "/var/www/phpmail.log" |
FROM wordpress:latest | |
RUN apt-get update && apt-get install msmtp -y && \ | |
rm -rf /var/lib/apt/lists/* | |
COPY msmtprc /etc/msmtprc | |
RUN chown :msmtp /etc/msmtprc && \ | |
chmod 640 /etc/msmtprc |
do you have any suggestions on this question: https://stackoverflow.com/questions/69931826/how-to-set-up-wordpress-to-use-mailhog-without-manual-install-of-smtp-plugin-for