Skip to content

Commit e938294

Browse files
committed
Merging dev and prod branches using two different docker-compose files
1 parent 624ff6c commit e938294

File tree

5 files changed

+176
-56
lines changed

5 files changed

+176
-56
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ www/wp_files/*
22
www/wp_files/.*
33
www/wp_files/!.no-media
44

5+
configs/wordmove/*
6+
configs/wordmove/.*
7+
configs/wordmove/!.no-media
8+
59
configs/proxy/*

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,74 @@
1+
# DEVELOPMENT WordPress environment with Docker
2+
3+
#### 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`.
4+
5+
## Start everything
6+
7+
You need to pass several arguments such as:
8+
- **DB_PASS** When the DB is raised this will be its root password
9+
10+
`export DB_PASS=YOUR_SUPER_SECURE_PASSWORD && export UID && docker-compose up`
11+
12+
> 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). You can stop it when you are not using it with `docker-compose stop wp_phpmyadmin`
13+
14+
## Configuring Wordmove
15+
16+
Your `Movefile` must be inside `configs/wordmove/`.
17+
18+
## Deploying your database
19+
20+
We recommend to have a repo for your WordPress site, so the themes and plugins should be deployed by a `git pull` command.
21+
22+
> By the moment we don't expose the wordmove entrypoint in the container so you need to login to container and execute the following commands
23+
24+
25+
### Login in to the container
26+
27+
`docker-compose run --rm wp_wordmove /bin/bash`
28+
29+
### Creating Movefile
30+
31+
`wordmove init`
32+
33+
### Deploying `uploads` folder
34+
35+
`wordmove push --uploads`
36+
37+
### Deploying your database
38+
39+
`wordmove push --db`
40+
41+
> #### The database deploy will overwritte the database on the production site, each comment, post, subscriber that is not in your local database will be lost
42+
43+
----------------------------------
44+
145
# PRODUCTION WordPress environment with Docker
246

347
#### 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.
448

5-
> 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.
6-
> `docker-compose stop wp_phpmyadmin`
7-
849
## Start everything
950

1051
You need to pass several arguments such as:
1152
- **DB_PASS** When the DB is raised this will be its root password
1253
- **DOMAIN** Put your domain _your-domain.com_. This is needed to the https set up.
1354
- **EMAIL** Put your email domain _[email protected]_. This is needed to the https set up.
1455

15-
`export DB_PASS=YOUR_SUPER_SECURE_PASSWORD export DOMAIN=your-domain.com && export [email protected] && docker-compose up`
56+
`export DB_PASS=YOUR_SUPER_SECURE_PASSWORD && export DOMAIN=your-domain.com && export [email protected] && docker-compose --file docker-compose-production.yml up`
57+
58+
> This 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.
59+
> `docker-compose stop wp_phpmyadmin`
60+
61+
--------------------------
62+
63+
# Common features
64+
65+
In this section you will find development and production common features.
1666

1767
## Steps to begin with a new WP project
1868

1969
1. Create the user using phpmyadmin
20-
- allow conection from any host
21-
- create a database with the same name with all priviledges
70+
- allow connection from any host
71+
- create a database with the same name with all privileges
2272
2. Download the WordPress core using
2373
- `docker-compose run --rm --user=82 wp_server wp core download`
2474
3. Create your `wp-config` file
@@ -35,6 +85,8 @@ You need to pass several arguments such as:
3585

3686
## Changing the PHP version
3787

88+
> Remember that if you are on production you must specify docker compose file using `--file docker-compose-production.yml`
89+
3890
1. stop everything with
3991
- `docker-compose stop`
4092

configs/wordmove/.no-media

Whitespace-only changes.

docker-compose-production.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# PRODUCTION DOCKER-COMPOSE FILE
2+
version: "2"
3+
4+
services:
5+
6+
# Https >>>>>
7+
proxy:
8+
image: jwilder/nginx-proxy
9+
ports:
10+
- 80:80
11+
- 443:443
12+
volumes:
13+
- ./configs/proxy/conf.d:/etc/nginx/conf.d
14+
- ./configs/proxy/vhost.d:/etc/nginx/vhost.d
15+
- ./configs/proxy/html:/usr/share/nginx/html
16+
- ./configs/proxy/certs:/etc/nginx/certs:ro
17+
- /var/run/docker.sock:/tmp/docker.sock:ro
18+
networks:
19+
- proxy-tier
20+
restart: always
21+
22+
# Letsencrypt
23+
letsencrypt-companion:
24+
image: jrcs/letsencrypt-nginx-proxy-companion
25+
volumes_from:
26+
- proxy
27+
volumes:
28+
- /var/run/docker.sock:/var/run/docker.sock:ro
29+
- ./configs/proxy/certs:/etc/nginx/certs:rw
30+
restart: always
31+
# <<<<< Https
32+
33+
wp_http_server:
34+
image: nginx:1.13.3-alpine
35+
restart: always
36+
links:
37+
- wp_server
38+
volumes:
39+
- ./www/wp_files/:/www:ro
40+
- ./configs/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
41+
- ./configs/nginx/conf.d:/etc/nginx/conf.d:ro
42+
# The user must provied this env variables before run docker-compose up
43+
# The command would be
44+
# export DOMAIN=your-domain.com && export EMAIL = [email protected] && docker-compose up
45+
environment:
46+
- VIRTUAL_HOST=${DOMAIN}
47+
- VIRTUAL_NETWORK=nginx-proxy
48+
- VIRTUAL_PORT=80
49+
- LETSENCRYPT_HOST=${DOMAIN}
50+
- LETSENCRYPT_EMAIL=${EMAIL}
51+
networks:
52+
- proxy-tier
53+
- default
54+
55+
wp_server:
56+
build:
57+
context: ./docker-images/php/
58+
args:
59+
PHP_VERSION: 7.1
60+
# PHP_VERSION: 7.0
61+
# PHP_VERSION: 5.6
62+
volumes:
63+
- ./www/wp_files/:/www
64+
- ./configs/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
65+
links:
66+
- wp_mariadb
67+
68+
wp_mariadb:
69+
image: mariadb
70+
restart: always
71+
ports:
72+
- "127.0.0.1:3306:3306"
73+
volumes:
74+
- ./www/wp_DB:/var/lib/mysql
75+
# The user must provied this env variables before run docker-compose up
76+
# The command would be
77+
# export DB_PASS=YOUR_SUPER_SECURE_PASSWORD && docker-compose up
78+
environment:
79+
- MYSQL_ROOT_PASSWORD=${DB_PASS}
80+
81+
wp_phpmyadmin:
82+
image: phpmyadmin/phpmyadmin
83+
restart: always
84+
environment:
85+
- PMA_HOST=wp_mariadb
86+
links:
87+
- wp_mariadb
88+
ports:
89+
- "8888:80"
90+
91+
networks:
92+
proxy-tier:
93+
external:
94+
name: nginx-proxy

docker-compose.yml

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,20 @@
1+
# DEVELOPMENT DOCKER-COMPOSE FILE
12
version: "2"
23

34
services:
45

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-
326
wp_http_server:
337
image: nginx:1.13.3-alpine
348
restart: always
35-
links:
36-
- wp_server
9+
ports:
10+
- "80:80"
11+
- 443:443
3712
volumes:
3813
- ./www/wp_files/:/www:ro
3914
- ./configs/nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
4015
- ./configs/nginx/conf.d:/etc/nginx/conf.d:ro
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 protected] && 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
16+
links:
17+
- wp_server
5318

5419
wp_server:
5520
build:
@@ -58,9 +23,10 @@ services:
5823
PHP_VERSION: 7.1
5924
# PHP_VERSION: 7.0
6025
# PHP_VERSION: 5.6
26+
user: ${UID}:www-data
6127
volumes:
62-
- ./www/wp_files/:/www
63-
- ./configs/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
28+
- ./www/wp_files/:/www
29+
- ./configs/php/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
6430
links:
6531
- wp_mariadb
6632

@@ -71,9 +37,6 @@ services:
7137
- "127.0.0.1:3306:3306"
7238
volumes:
7339
- ./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
7740
environment:
7841
- MYSQL_ROOT_PASSWORD=${DB_PASS}
7942

@@ -87,7 +50,14 @@ services:
8750
ports:
8851
- "8888:80"
8952

90-
networks:
91-
proxy-tier:
92-
external:
93-
name: nginx-proxy
53+
wp_wordmove:
54+
build:
55+
context: ./docker-images/wordmove/
56+
command: 'echo "Hello From Wordmove"'
57+
volumes:
58+
- ./www/wp_files/:/www
59+
# Movefile
60+
- ./configs/wordmove/Movefile:/home:ro
61+
- ${HOME}/.ssh/:/root/.ssh:ro
62+
links:
63+
- wp_mariadb

0 commit comments

Comments
 (0)