Use Docker to develop WordPress sites locally and then deploy to shared hosting.

Alex Gleason 0c32e973ad Testing multiple deploy paths 8 years ago
scripts 0c32e973ad Testing multiple deploy paths 8 years ago
wordpress 28b17439d2 Set static container names, refactor 8 years ago
.gitignore 28b17439d2 Set static container names, refactor 8 years ago
LICENSE ea905c6580 Add license 8 years ago
Makefile 8b8aad4c92 Greatly improved project workflow 8 years ago
README.md 8b8aad4c92 Greatly improved project workflow 8 years ago
docker-compose.yml 28b17439d2 Set static container names, refactor 8 years ago
env-example 1779b77cc5 Initial commit 8 years ago

README.md

CodePress Boilerplate

This is a boilerplate for using Docker to develop WordPress sites locally and then deploy to shared hosting. This isn't a fun procedure, so this project exists to mitigate some of the pain.

Local development

1. Install Docker

Follow the tutorial to install Docker. This project assumes you're using a Linux workstation.

2. Start the containers

$ make start

You can now see the WordPress install screen at localhost:8000

3. Authenticate

You need a file called .env in the root of your project containing the necessary credentials for pulling and pushing to the server. There is an example file called env-example for reference.

Contributing

Make sure you are authenticated with a .env file before trying any of this.

Strategy

  1. Get things working locally, then push any relevant code to master
  2. Deploy the code to the server
  3. Log into the deployed site and configure the back-end as needed
  4. Pull the database back locally

This does require doing things in the dashboard twice. It's tedious, but probably also the best way currently available for WordPress.

Sync with the server

You can use the provided Makefile to automate some tasks.

make deploy

Logs in via FTP and uploads only the relevant files to the server.

make pulldb

Connects to the remote MySQL database, dumps it, and pulls it into your local Docker container.

Docker tips

Stop the container:

$ docker stop mysite

Start the container:

$ docker start mysite

List all active containers:

$ docker ps

List all active AND stopped containers:

$ docker ps -a

Shell into a container:

$ docker exec -it mysite /bin/bash

Remove a container:

$ docker stop mysite
$ docker rm mysite

Get all information imaginable about a container:

$ docker inspect mysite