Dockerize WordPress with themes, plugins and common configuration

This article is the continuation of WordPress with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series. For better understating, please start from the beginning of the series.

In this article, we will create the following files and folders

Let’s create files and folders

Dockerfile

Paste the following content into the Dockerfile

entrypoint-child.sh

Our WordPress Docker image (wordpress:latest) already contains an entry point. which is called docker-entrypoint.sh. The reason have added our custom entrypoint file into the mix is because of AWS EFS volumes for our Plugins storage on AWS. That is why we need some permissions to be added again. This entrypoint just add those permissions and then execute the image default entrypoint. Don’t worry about this for now, I will shed more light on it as we progress.

uploads.ini config

Paste the following content into config/uploads.ini file

Please change the above as per your wordpress website requirements

docker-compose

Paste the following content into development/docker-compose.yml file

We have created two service in the docker-compose file

  • wordpress
  • db

WordPress service is building a Docker image from the Dockerfile we have created in the begining

The above line is telling the docker-compose to build the image from a Dockerfile which is on the root of this project

The above command is just mapping the 8000 port from outside world to the port 80 of this container

We are also setting some environment variables such as database credentials which are initialized in the db service

Time to see something on the browser !!!

All the required files and directories have been created. Let’s start our wordpress website by running the following commands

Open your web browser and type http://localhost:8000 and you should be able to see this page.

Written by

Leave a Reply

Your email address will not be published. Required fields are marked *