Use Docker to develop WordPress sites locally and then deploy to shared hosting.
Alex Gleason 578ec18f24 Fix port conflict issue by using port 0 | 8 vuotta sitten | |
---|---|---|
scripts | 8 vuotta sitten | |
wordpress | 8 vuotta sitten | |
.gitignore | 8 vuotta sitten | |
LICENSE | 8 vuotta sitten | |
Makefile | 8 vuotta sitten | |
README.md | 8 vuotta sitten | |
docker-compose.yml | 8 vuotta sitten | |
env-example | 8 vuotta sitten |
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.
$ wget -nv -O - https://get.docker.com/ | sh
Once installed, you will need to add yourself to the docker
group on your computer. Replace myname
with your username below.
$ sudo usermod -aG docker myname
Finally, log out of and back into your computer (or reboot it).
If this doesn't work, you can follow the tutorial to install Docker. This project assumes you're using a Linux workstation.
$ make start
You can now see the WordPress install screen at localhost:8000
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.
Make sure you are authenticated with a .env
file before trying any of this.
This does require doing things in the dashboard twice. It's tedious, but probably also the best way currently available for WordPress.
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.
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