- React / Wordpress / Docker
- Overview 🔎
- Up and Running 🚀
- Front-End Development 🎨
- Backend / CMS Development 🗄
- Docker 🐳
- TODO ✅
This site is a headless Wordpress CMS with a React.js front end.
- Wordpress code is in
<project root>/cms
- React code is in
<project root>/client
Attribution:
- WordPress Docker code by @Drew Dahlman
- React Docker code by @Michael Herman
- Docker Compose URL
$ cd client
$ docker-compose up
Visit the react app at http://localhost:3000
$ cd cms
$ docker-compose up
- Wordpress website: http://localhost:8080
- PHPMyAdmin: http://localhost:8181
Start the node-sass process.
$ cd <project root>/client
$ yarn run watch:sass
This will watch all the files in client/src/styles/scss
and build them into .css
files in client/src/styles/css
.
SASS variables are in client/src/styles/scss/theme/variables
TypeScript:
For more resources on React / TypeScript please see:
- [Typescript / React Cheat Sheet](https://github.com/sw-yx/react-typescript-cheatsheet
- https://levelup.gitconnected.com/ultimate-react-component-patterns-with-typescript-2-8-82990c516935
Redux + thunk
None at the moment.
Getting started with the administrative tools.
- Go to
http://localhost:8080/wp-admin
- UN: 'root'
- PW: 'root'
- Click on 'Posts' -> 'Categories'
- Make a new category by giving it a
- Name
- Slug
- Parent Category (optional)
- Description
Practicing this flow of adding content it crucial because this will set the endpoints of our CMS as well as make relationships between the data in the DB. Please make sure to leverage post categories
and tagging
as much as possible.
Once there is some content in the CMS, we can retrieve it from the Wordpress RESTful API.
Call the API: (this is not the right way to do so. See: TODO)
- http://localhost:8080/?rest_route=/wp/v2/ (meta data)
- http://localhost:8080/?rest_route=/wp/v2/posts (all posts)
- http://localhost:8080/?rest_route=/wp/v2/categories (all categories)
For more documentation on the Wordpress V2 API please see:
The CMS is running on top of a MySQL DB.
PHPMyAdmin Easy Access:
- visit: http://localhost:8181
This will pull up the PHPMyAdmin interface on the docker container. Here you can easily interface with the MySQL database in the Docker container.
If you want to change the name of the database or configure it to run locally on a MAMP server you can change those configs in <project root>/cms/wp-client.php
define('DB_NAME', 'db');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'db:3306');
define('DB_HOST', 'localhost'); // for local development
To make a dump of the data in the database run the following command from <project root>/cms
on you local machine:
$ docker exec <container> sh -c "cd /data && wp db export --path=/app --allow-root"
This will generate a .sql
file in the <project root>/cms/data
folder. The run.sh file in <project root>/cms/docker
.
- Visit http://localhost:8181
- Click on 'import'
- Upload the generated .sql file in `/cms/data
- Press the 'Go" button
This should load the sql file into the MySQL databse.
If you make a change to the Dockerfile
make sure to run docker-compose up -d --build
to rebuild the container.
If you want to just start the container use docker-compose up
- Find a good hosting strategy that makes sense for current needs
- t2 micros for EC2 and RDS
- use AWS codepipline to store code in an S3 bucket and build it when we publish new changes
- Or automate the deploy any way possible - Jenkins, travis, etc.
- Set up .env files for docker to pull from
- build and watch the .scss files
- Consolidate to one docker-compose.yml at root of project that builds both the react app and the wordpress cms