-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
110 lines (103 loc) · 4.64 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# put the compose file format version here that corresponds to your version
# of docker engine found here: https://docs.docker.com/compose/compose-file/
version: '3.8'
services:
# create a database container with the latest image for MySQL
db:
image: mysql:8.0.21
# if the container should fail, ensure it gets started up again
restart: always
# create a volume mysql-data and map it to the file path that MySQL requires
volumes:
- ./mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: wordpressrootpw
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
# the first number (docker port) can be whatever you'd like and it's mapped to the
# 3306 port (container port), required by MySQL
ports:
- "3308:3306"
# create a PHPMyAdmin container so you can have a GUI for the DB; pull the latest image
pma:
image: phpmyadmin/phpmyadmin:5.0.1
# if the container should fail, ensure it gets started up again
restart: always
# the container will not function correctly without the db container running first, so
# make it dependent on the db container
depends_on:
- db
environment:
# this should reference the db container
PMA_HOST: db
# should match the MySQL one
MYSQL_ROOT_PASSWORD: wordpressrootpw
# set the first number to what you'd like; it's what you'll put at the end of the URL
# to access it (e.g. localhost:8081). 80 is the port that PMA requires.
ports:
- "8081:80"
# create the WordPress/PHP container; The image below uses PHP 7.4 with PHP-FPM, which is
# a processor that NGINX relies on for the processing of PHP files, as it doesn't have that
# functionality built in like Apache has.
php:
build: ./docker/php
# this container needs to have the db container running first, so make it dependent on it
depends_on:
- db
# if the container should fail, ensure it gets started up again
restart: always
# create a php ini file to set the proper restrictions on file uploads, memory limit, etc.
# and specify where it's stored; create the volume for WP and map it to the required file
# path /var/www/html
volumes:
- ./php-uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
- ./wordpress:/var/www/html
# create a logs directory and map to the required file path
- ./logs:/var/log/apache2
environment:
# host should match the db container's values (container name:port number)
WORDPRESS_DB_HOST: db:3306
# the user and pass should match the MySQL ones
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
# create a container to handle SMTP
mailhog:
image: mailhog/mailhog:v1.0.1
ports:
- "1025:1025"
- "8025:8025"
# create an https-portal using the latest image from Docker Hub
https-portal:
image: steveltn/https-portal:1
# nginx needs to be running first, so make the container dependent on it
depends_on:
- php
# the letsencrypt https-portal image needs ports 80 and 443; this exposes the ports from
# docker containers to the host system
ports:
- "80:80"
- "443:443"
# if the container should fail, ensure it gets started up again
restart: always
# create a directory to store the certs created between runs, to save on CPU processing
volumes:
- ./ssl_certs:/var/lib/https-portal
environment:
# you can use a custom domain for your local build and replace localhost below
# with it. Follow this tutorial to set it up:
# https://www.stevenrombauts.be/2018/01/use-dnsmasq-instead-of-etc-hosts/
# to get past the insecure warnings in Chrome type: thisisunsafe with your
# keyboard while on the webpage and the browser will refresh and bring up the site.
# This forwards the domain to the nginx container at port 80; flagged with local to tell
# https-portal that a self-signed certificate is needed (change to staging or
# production to get an actual cert from Lets Encrypt when you're in those stages
# of development)
DOMAINS: 'localhost -> http://php:80 #local'
# set the max file upload size here for nginx too (in addition to using the ini file)
CLIENT_MAX_BODY_SIZE: 64M
# these volumes are named volumes (mysql-data) so they must be specified in the top-level of
# this file here; this allows them to be reused across multiple services
volumes:
mysql-data:
wordpress: