Lately I’m playing with Docker and as exercise I tried to setup full installation of WordPress using docker.
The most simple is to use official wordpress repository. The problem was that wordpress container doesn’t support sending mails. The easiest way to provide such functionality is to install ssmtp. So I created a container for that purpose defragmentator/wordpress_ssmtp
Sources are published on my GitHub.
That container enables user to easy configure outgoing email account with environment variables. If someone prefer to use config file on volume (/etc/ssmtp/ssmtp.conf) it is also possible.
config.yml:
version: '3' services: db: image: mysql:5.7 volumes: - /home/docker/wordpress/db:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: mysql MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db volumes: - /home/docker/wordpress/html:/var/www/html image: defragmentator/wordpress_ssmtp:fpm restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress SSMTP_ROOT: [email protected] SSMTP_MAILHUB: smtp.gmail.com:587 SSMTP_USETLS: 'YES' SSMTP_USESTARTTLS: 'YES' SSMTP_FROMLINEOVERRIDE: 'YES' SSMTP_AUTHUSER: [email protected] SSMTP_AUTHPASS: password web: image: nginx:latest restart: always ports: - "80:80" volumes: - /home/docker/wordpress/log:/var/log/nginx - /home/docker/wordpress/html:/var/www/html - /home/docker/wordpress/nginx/default.conf:/etc/nginx/conf.d/default.conf
Having properly edited config.yml deployment can be done with command:
sudo docker stack deploy -c config.yml wordpresssite
My repository contains of two branches: apache and fpm. I prefere fpm with nginx, bacause it was much simpler to deploy with CloudFlare. To get real IPs of users I added some lines to default.conf:
set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 104.16.0.0/12; set_real_ip_from 108.162.192.0/18; set_real_ip_from 131.0.72.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 162.158.0.0/15; set_real_ip_from 172.64.0.0/13; set_real_ip_from 173.245.48.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 190.93.240.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; set_real_ip_from 2400:cb00::/32; set_real_ip_from 2606:4700::/32; set_real_ip_from 2803:f800::/32; set_real_ip_from 2405:b500::/32; set_real_ip_from 2405:8100::/32; set_real_ip_from 2c0f:f248::/32; set_real_ip_from 2a06:98c0::/29; # use any of the following two real_ip_header CF-Connecting-IP; #real_ip_header X-Forwarded-For;