yliaho / wp-docker-shenanigans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker Wordpress Shenanigans

The adventures of Wordpress containerization and theme development with Docker.

Requirements

  • Docker 18.09.0
  • Docker Compose 1.23.2

If you have node.js (and thus, probably npm) installed, that'd be super nice. We're using npm scripts to build, start, stop and remove containers. In the future, when this whole containerization process is fleshed out properly and the developer experience is smooth, you'll need to have node.js installed either way for theme development.

Developing

First, create .env file to the root of the project directory and use the .env.example as a reference. For example;

DB_USER=digitalents_wp
DB_PASSWORD=supersecret
DB_NAME=digitalents_wp

Depending on your operating system, the process of starting up the containers should be either straightforward or slightly annoying. MacOS setup is literally one command away from being ready for development purposes, while Linux requires you to chowning some directories. Don't even ask about Windows, I have literally no clue if it'll work there.

MacOS

  • npm run build:up builds images and starts the containers specified in docker-compose.yaml file.
  • Browse to http://localhost:8080 and finish the WP configuration using your preferred username and password.

Linux

  • npm run build:up builds images and starts the containers specified in docker-compose.yaml file.
  • sudo chown -R <uid>:www-data theme/ gutenberg-blocks/ gives your docker host user's permission to write to these specific directories.
  • Browse to http://localhost:8080 and finish the WP configuration using your preferred username and password.

If you need to restart the containers, npm run build:down does that for you. You can also check out the build.sh shell script on the root directory to see more options, such as stopping and removing both the containers and their respective volumes... Or just do it yourself using docker-compose.

About


Languages

Language:PHP 49.7%Language:HTML 43.8%Language:Shell 5.1%Language:Dockerfile 0.7%Language:CSS 0.5%Language:JavaScript 0.3%