Implemented msmtp for wordpress

This commit is contained in:
2025-04-03 14:05:00 +02:00
parent fa10fe558d
commit 170636d098
16 changed files with 200 additions and 42 deletions

View File

@@ -2,14 +2,21 @@
## database
## access database
To access the database execute
If you use a local instead of a central database you can use the following commands.
### access database
To access the database execute:
```bash
docker-compose exec -it database /bin/mysql -u wordpress -p
```
## upgrade database
To upgrade the database execute
### upgrade database
To upgrade the database execute:
```bash
docker-compose exec -it database /bin/mysql_upgrade --user=root --password=
```
@@ -18,10 +25,18 @@ To upgrade the database execute
- https://wolfgang.gassler.org/reset-password-mariadb-mysql-docker/
- https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password
## bash in application
docker-compose exec -it wordpress-application-1 /bin/sh
## shell in docker
To execute the commands in the docker container execute:
## update wp-config.php
```bash
apt update && apt install nano && nano wp-config.php
```
docker-compose exec -it application /bin/sh
```
## Test Email
To test the email execute:
```bash
echo "Test Email" | sendmail -v your-email@example.com
```

View File

@@ -1,6 +1,40 @@
# role docker-wordpress
# WordPress
## Description
This role deploys and manages a Docker-based [WordPress](http://wordpress.com/) instance, including support for multisite installations. It builds a custom WordPress image that installs msmtp (for email delivery) and configures PHP settings for uploads and email functionality.
For detailed administrative procedures (database access, container management, etc.), please refer to the [Administration Reference](./Administration.md).
## Overview
Tailored for Arch Linux environments using Docker, this role:
- **Custom Image Build:** Builds a Docker image for WordPress with msmtp installed to act as a sendmail replacement.
- **Multisite Support:** Configures WordPress to support multiple sites by integrating with external domain setup roles.
- **Centralized Database Management:** Leverages the docker-central-database role to ensure consistent database configuration.
- **Docker Compose Integration:** Uses Docker Compose templates for container orchestration and service management.
## Purpose
The role aims to automate the provisioning of a robust, scalable WordPress instance in a containerized environment while ensuring reliable email delivery through msmtp and streamlined multi-site management.
## Features
- **Custom WordPress Container:** Builds an image with msmtp and custom PHP settings.
- **Multisite Capabilities:** Configures settings and domains for multisite WordPress deployments.
- **Integrated Database Access:** Works in tandem with a central database role.
- **Seamless Docker Compose Deployment:** Provides templates for Docker Compose and environment configuration.
- **Administration Documentation:** See the [Administration Reference](./Administration.md) for tasks like database access, upgrades, and configuration updates.
## multiside
- https://multilingualpress.de/doku/wordpress-multisite-installieren-einrichten/
- https://pressable.com/knowledgebase/adding-or-changing-the-domain-on-a-wordpress-multisite/
- https://wpengine.com/support/how-to-change-a-multi-site-primary-domain/
## Credits
Developed and maintained by **Kevin Veen-Birkenbach**.
Learn more at [www.veen.world](https://www.veen.world)
Part of the [CyMaIS Project](https://github.com/kevinveenbirkenbach/cymais)
License: [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl)

View File

@@ -1,2 +1,12 @@
FROM wordpress
# Update and installation of msmtp
RUN apt-get update && \
apt-get install -y msmtp msmtp-mta && \
rm -rf /var/lib/apt/lists/*
# Copy the msmtp configuration into the container
COPY msmtp.conf /etc/msmtp.conf
# Copy the PHP configuration for uploads (and mail settings)
COPY upload.ini $PHP_INI_DIR/conf.d/

View File

@@ -0,0 +1,25 @@
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: >
Deploys and configures a Docker-based WordPress instance with multisite support,
custom image building, and integrated msmtp for reliable email delivery.
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
company: |
Kevin Veen-Birkenbach
Consulting & Coaching Solutions
https://www.veen.world
min_ansible_version: "2.9"
platforms:
- name: Archlinux
versions:
- rolling
galaxy_tags:
- wordpress
- docker
- multisite
- msmtp
- automation
repository: "https://s.veen.world/cymais"
issue_tracker_url: "https://s.veen.world/cymaisissues"
documentation: "https://s.veen.world/cymais"

View File

@@ -3,32 +3,39 @@
include_role:
name: docker-central-database
- name: "include role nginx-domain-setup for {{application_id}}"
- name: "include role nginx-domain-setup for {{ application_id }}"
include_role:
name: nginx-domain-setup
loop: "{{ domains.wordpress }}"
loop_control:
loop_var: domain
vars:
nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{wordpress_max_upload_size}};"
http_port: "{{ ports.localhost.http[application_id] }}"
nginx_docker_reverse_proxy_extra_configuration: "client_max_body_size {{ wordpress_max_upload_size }};"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "Transfering upload.ini to {{docker_compose.directories.instance}}"
- name: "Transfering upload.ini to {{ docker_compose.directories.instance }}"
template:
src: upload.ini.j2
dest: "{{docker_compose.directories.instance}}upload.ini"
dest: "{{ docker_compose.directories.instance }}upload.ini"
notify:
- docker compose project setup
- rebuild wordpress container
- name: "Transfering Dockerfile to {{docker_compose.directories.instance}}"
- name: "Transfering msmtp.conf to {{ docker_compose.directories.instance }}"
template:
src: "{{ playbook_dir }}/roles/msmtp/templates/msmtprc.conf.j2"
dest: "{{ docker_compose.directories.instance }}msmtp.conf"
notify:
- docker compose project setup
- rebuild wordpress container
- name: "Transfering Dockerfile to {{ docker_compose.directories.instance }}"
copy:
src: Dockerfile
dest: "{{docker_compose.directories.instance}}Dockerfile"
dest: "{{ docker_compose.directories.instance }}Dockerfile"
notify:
- docker compose project setup
- rebuild wordpress container
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml

View File

@@ -1,5 +1,8 @@
file_uploads = On
memory_limit = {{wordpress_max_upload_size}}
upload_max_filesize = {{wordpress_max_upload_size}}
post_max_size = {{wordpress_max_upload_size}}
max_execution_time = 300
memory_limit = {{ wordpress_max_upload_size }}
upload_max_filesize = {{ wordpress_max_upload_size }}
post_max_size = {{ wordpress_max_upload_size }}
max_execution_time = 300
; Use msmtp as the Mail Transfer Agent
sendmail_path = "/usr/bin/msmtp -t"