Skip to content

Commit 624ff6c

Browse files
committed
Https implementation and documentation improvement
2 parents 075ddab + e23c3f6 commit 624ff6c

File tree

3 files changed

+68
-22
lines changed

3 files changed

+68
-22
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
www/wp_files/*
22
www/wp_files/.*
3-
www/wp_files/!.no-media
3+
www/wp_files/!.no-media
4+
5+
configs/proxy/*

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
# Dev environment WordPress with Docker _**TIPS**_
1+
# PRODUCTION WordPress environment with Docker
22

3-
4-
#### This docker compose was made to have a modern WP dev environment which can be portable, easy to set up and focused on the use of `wp`.
3+
#### This docker compose was made to have a modern WP dev environment which can be portable, easy to set up and with HTTPS with letsencrypt.
54

65
> With `docker-compose up` it will run a phpmyadmin service, this is created with goal of facilitate the management of the DataBase (not all of us are command ninja) so we recommend, stop it when you are not using it.
76
> `docker-compose stop wp_phpmyadmin`
87
98
## Start everything
109

11-
For be able to manipulate easily the files of wordpress you need to:
10+
You need to pass several arguments such as:
11+
- **DB_PASS** When the DB is raised this will be its root password
12+
- **DOMAIN** Put your domain _your-domain.com_. This is needed to the https set up.
13+
- **EMAIL** Put your email domain _email@your-domain.com_. This is needed to the https set up.
1214

13-
`export UID && docker-compose up`
15+
`export DB_PASS=YOUR_SUPER_SECURE_PASSWORD export DOMAIN=your-domain.com && export EMAIL=email@your-domain.com && docker-compose up`
1416

1517
## Steps to begin with a new WP project
1618

1719
1. Create the user using phpmyadmin
1820
- allow conection from any host
1921
- create a database with the same name with all priviledges
2022
2. Download the WordPress core using
21-
- `docker-compose exec wp_server wp core download`
23+
- `docker-compose run --rm --user=82 wp_server wp core download`
2224
3. Create your `wp-config` file
23-
- `docker-compose exec wp_server wp core config --prompt`
25+
- `docker-compose run --rm --user=82 wp_server wp core config --prompt`
2426
- 1/12 --dbname=<**dbname**>: `YOUR_DB_NAME`
2527
- 2/12 --dbuser=<**dbuser**>: `USER_CREATED_AT_1`
2628
- 3/12 [--dbpass=<**dbpass**>]: `PASS_CREATED_AT_1`
2729
- 4/12 [--dbhost=<**dbhost**>]: `wp_mariadb`
2830
- 5...12 - Default values set by enter
2931
4. Install WordPress site
30-
- `docker-compose exec wp_server wp core install --prompt`
32+
- `docker-compose run --rm --user=82 wp_server wp core install --prompt`
3133
- 1/6 --url=<**url**>: `localhost`
3234
- 2...6 - Your personal configuration
3335

@@ -46,9 +48,9 @@ For be able to manipulate easily the files of wordpress you need to:
4648
3. Then build the new image with:
4749
- `docker-compose build`
4850
4. Run everything again:
49-
- `export UID && docker-compose up`
51+
- `export DB_PASS=YOUR_SUPER_SECURE_PASSWORD export DOMAIN=your-domain.com && export EMAIL=email@your-domain.com && docker-compose up`
5052

5153
5. To verify the version run
52-
- `docker exec wp_server php --version`
54+
- `docker-compose run --rm wp_server php --version`
5355

5456
> Written with [StackEdit](https://stackedit.io/).

docker-compose.yml

+53-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,54 @@ version: "2"
22

33
services:
44

5+
# Https >>>>>
6+
proxy:
7+
image: jwilder/nginx-proxy
8+
ports:
9+
- 80:80
10+
- 443:443
11+
volumes:
12+
- ./configs/proxy/conf.d:/etc/nginx/conf.d
13+
- ./configs/proxy/vhost.d:/etc/nginx/vhost.d
14+
- ./configs/proxy/html:/usr/share/nginx/html
15+
- ./configs/proxy/certs:/etc/nginx/certs:ro
16+
- /var/run/docker.sock:/tmp/docker.sock:ro
17+
networks:
18+
- proxy-tier
19+
restart: always
20+
21+
# Letsencrypt
22+
letsencrypt-companion:
23+
image: jrcs/letsencrypt-nginx-proxy-companion
24+
volumes_from:
25+
- proxy
26+
volumes:
27+
- /var/run/docker.sock:/var/run/docker.sock:ro
28+
- ./configs/proxy/certs:/etc/nginx/certs:rw
29+
restart: always
30+
# <<<<< Https
31+
532
wp_http_server:
633
image: nginx:1.13.3-alpine
734
restart: always
8-
ports:
9-
- "80:80"
10-
- 443:443
35+
links:
36+
- wp_server
1137
volumes:
1238
- ./www/wp_files/:/www:ro
1339
- ./configs/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
1440
- ./configs/nginx/conf.d:/etc/nginx/conf.d:ro
15-
16-
links:
17-
- wp_server
41+
# The user must provied this env variables before run docker-compose up
42+
# The command would be
43+
# export DOMAIN=your-domain.com && export EMAIL = email@your-domain.com && docker-compose up
44+
environment:
45+
- VIRTUAL_HOST=${DOMAIN}
46+
- VIRTUAL_NETWORK=nginx-proxy
47+
- VIRTUAL_PORT=80
48+
- LETSENCRYPT_HOST=${DOMAIN}
49+
- LETSENCRYPT_EMAIL=${EMAIL}
50+
networks:
51+
- proxy-tier
52+
- default
1853

1954
wp_server:
2055
build:
@@ -23,10 +58,9 @@ services:
2358
PHP_VERSION: 7.1
2459
# PHP_VERSION: 7.0
2560
# PHP_VERSION: 5.6
26-
user: ${UID}:www-data
2761
volumes:
28-
- ./www/wp_files/:/www
29-
- ./configs/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
62+
- ./www/wp_files/:/www
63+
- ./configs/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
3064
links:
3165
- wp_mariadb
3266

@@ -37,8 +71,11 @@ services:
3771
- "127.0.0.1:3306:3306"
3872
volumes:
3973
- ./www/wp_DB:/var/lib/mysql
74+
# The user must provied this env variables before run docker-compose up
75+
# The command would be
76+
# export DB_PASS=YOUR_SUPER_SECURE_PASSWORD && docker-compose up
4077
environment:
41-
- MYSQL_ROOT_PASSWORD=YOUR_SUPER_SECURE_PASSWORD
78+
- MYSQL_ROOT_PASSWORD=${DB_PASS}
4279

4380
wp_phpmyadmin:
4481
image: phpmyadmin/phpmyadmin
@@ -48,4 +85,9 @@ services:
4885
links:
4986
- wp_mariadb
5087
ports:
51-
- "8888:80"
88+
- "8888:80"
89+
90+
networks:
91+
proxy-tier:
92+
external:
93+
name: nginx-proxy

0 commit comments

Comments
 (0)