This set of scripts will set up a Wordpress development environment that will work on any major desktop platform (Mac, Windows, Linux). It is designed around the needs of students in Hacking History, a 4th year undergraduate seminar at the Unviersity of Toronto, and based on the work of of visiblevc, from which both the docker image and the run scripts are derived.
We use Docker and the Wordpress Command Line Interface to construct a “virtual environment” on your laptop. Wordpress and all the other services it depends on (including a webserver and a database server) will run in “containers” which can be accessed through the command line. You can also browse the local Wordpress site by pointing your browser at localhost:8080, and you can edit the theme files in Atom. Any changes you make will be visible in the browser window on refresh.
- first get ready by downloading Docker for Mac or Windows (if you are using Linux, use the terminal!)
- clone this repo with Github desktop or directly with
git clone https://github.com/titaniumbones/wordpress-starter
- If you use Github, Desktop, the repository will probably be saved to
/Users/yourname/Github/repositories/wordpress-starter/
(Mac), orC:\User\Github\repositories\wprdpress-starter
. Navigate to that location using a terminal (Mac) or the “Powershell” environment that comes with DOcker for Windows (Windows). - From the main repository, run
docker-compose up && docker-compose logs -f wordpress
. THe first time you do this, the process will ake about 10 minutes, so - go get a cup of coffee
- come back and visit http://localhost:8080/ to see the website, whih is running live on your computer!
- in Atom, edit
REPOSITORY_ROOT/wp-content/themes/dev-theme/sass/theme/_theme_variables.scss
or other files in thedev-theme
directory tree. Changes will appear in your browser on refresh. - if your computer shuts down, run
docker-compose up && docker-compose logs -f wordpress
again from the appropriate directory to bring the virtual environment back online. It wil only take about a minute the second time.
- thanks to wordpress-starter for the inspiration and much of the code. Kept it mostly because the color coding is so awesome
- thanks to the official wp-cli image for a starting point
- [ ] check whether I can use apt-get or not. If not, need to rewrite the wp-cli code
- [ ] decide how to manage db import and syncing. Might be easier to use a plugin, and maybe (???) even write a row to the db with a secret key passed as an environment variable (that could work with dp-sync, for instance)
- [X] remove all deprecated stuff.
- [X] don’t fail if DB already exists. Instead, continue silently.
- [ ] remove multisite stuff, I think
- [X] add a “build-finalizer” for completely local steps. Like, maybe we could add gulp watch.
- [ ] but since this last step will depend on the theme, maybe the smart thing to do is to add this script to the theme repo
- In which case might be better to call it something else.
- like, there might be a
wp-docker-final-script.sh
in the foot dir of the theme - which just does a
npm install -d && gulp watch
. That would be cool.
- [X] Add node and sass dependencies, either in dockerfile or via docker-compose, with another machine that adds node.