This script creates a Wordpress Docker instance on your local machine, clones your WordPress theme repository, and sets up the project.
Note
This script has only been tested on MacOS. Use on Linux at your own expense, though likely no issue with minor changes.
Unsupported on Windows.
- Docker
- Node.js (For Mac recommended install is via Homebrew, for Linux recommended install is via the CLI)
There are a few changes you have to make before running the commands. However, all these changes are simple variable manipulations. See the following table for instructions.
Line | Change | Description |
---|---|---|
14 | GIT_REPO_BASE |
The repo base the projected is located on |
15 | PATH_SCRIPT |
The location of this script |
16 | PATH_PROJECT |
The location of your local workspace |
You will also need to allow this script to be executed with:
chmod +x PATH_TO_REPO/new-docker-wordpress.sh
Simply call this script from the CLI to run the script. Once run all you need to do is enter the project name (no spaces) and wait until it has completed.
Note
Make sure you have have already prepared your WordPress theme repository on GitHub.
Make sure the container is running!
- Open localhost:8080 to connect to PHPMyAdmin.
- Enter login credentials
You can use the following commands to access the MySQL shell.
docker exec -it CONTAINER_NAME bash
mysql -uroot -proot
Once inside you can use all your regular MySQL commands such as SHOW DATABASES/TABLES;
, SELECT * FROM table;
, etc.
You can run the following command to pipe the database into an .sql
export.
docker exec CONTAINER_NAME /usr/bin/mysqldump -uroot -proot DATABASE_NAME > ~/Desktop/PROJECT_NAME.sql
Using the following command you can import an .sql
file into a MySQL database hosted on Docker.
cat backup.sql | docker exec -i CONTAINER_NAME mysql -uuser -ppassword DATABASE_NAME
The following sub-sections briefly explain how to find the unique information that will be different for every project.
While docker container is running
- Open Docker App
- Click arrow to dropdown all grouped containers
CONTAINER_NAME
= the MySQL container name
While docker container is running
docker exec -it CONTAINER_NAME mysql -uroot -proot
SHOW DATABASES;
exit
DATABASE_NAME
= the database shown from SHOW DATABASES;
.
The name of the project, i.e. the name of your project GitHub repository.
The location of this cloned repository.