Wordpress directory structure was changed to convert default WordPress site into a version-controlled Git repository where WordPress, themes, and plugins are installed as a Composer dependency.
The power of this solution lies in the ability to create version-controlled WordPress project where rapid, collaborative theme and plugin development is made easy.
To run locally
- Git
- Docker
- Read Managing Your WordPress Site with Git and Composer series. Especially parts 2 and 4
- Makes a better directory structure for your WordPress project which looks like this:
- /public/ - The publicly-accessible root
- /public/wp - WordPress files installed by Composer (not included in version control)
- /public/wp-content - The wp-content directory contains all the plugins and themes unique to your WordPress project. Themes and plugins which installed via composer will be ignored by version control. If you want to customize theme/plugin, please add exception to .gitignore.
- / - The project root is behind the publicly accessible web root and contains any other dependencies you might want to require in the vendor directory.
- Improvement in WordPress configuration. In the project root, you'll find a local-config.sample.php - the modified wp-config.php located in the public directory will look first for a production-config.php and then fall back on a local-config.php. This will allow you to seamlessly manage your local/production configuration.
- Clone this repo
- Install composer dependencies
docker run --rm --interactive --tty --user $(id -u):$(id -g) --volume $PWD:/app composer:1.6 install
- Copy local-config.sample.php to local-config.php and set your configuration values
cp local-config.sample.php local-confi.php
- Build dev docker image:
docker build . -t flugelit-wp:dev
- Run container
docker run --rm -d -p 80:80 -v "$PWD":/var/www/html flugelit-wp:dev
- Now Wordpress available on http://127.0.0.1
- In your wp-options table, be sure to set your siteurl option to http://yourdomain.com/wp and your home option to http://yourdomain.com
Don't add themes/plugins via admin dashboard. Use composer.json instead. Run docker run --rm --interactive --tty --user $(id -u):$(id -g) --volume $PWD:/app composer:1.6 update
after composer.json modification.
Modify the .gitignore according to which parts of wp-content you'd like to include in version control. By default, the wp-content/uploads directory is included to version control.
wp-flugelit also contains manifest files to deploy it to Kubernetes cluster. Assumed that the container has the code and all necessary assets, no persistent storage needed. Delivery type - pull container image from registry. To run project in kuberenetes cluster, you need:
- Clone repo.
- Buid production image:
docker build . --build-arg IS_PROD=true -t [HOSTNAME]/[PROJECT-ID]/[IMAGE]:[VERSION]
- Push image to registry
- Set image into kubernetes deployment manifest /deployments/wp-flugelit-deployment.yaml
- Create secret named
wp-flugelit
for keysuser
andpassword
(put database connection credentials there) - Create
configmap
namedwp-flugelit
for keysdb_host
anddb_name
- Run deployment
kubectl create -f deployments/
This project was forked from Liore Shai wp-composer
project.