Skip to content

catenare/wordpressdockerservice

Repository files navigation

Wordpress Configuration with composer.json and Docker

  • Install docker on your testing server
  • Clone repository
  • Create .env file (see sample)
  • Build containers with docker compose. docker-compose up --build

Creating the Wordpress Docker configuration

Developer environment using DevContainers

  • Docker installed
  • Already configured in devcontainer
  • Add ssh keys to allow git access
eval "$(ssh-agent -s)"
ssh-add ~/ssh/github_catenare
  • Steps
    1. Start the dev container
    • F1 remote-container: Reopen container - Will restart with a devcontainer configuration
    1. Add local .env variables to container environment.
    • set -a; source .env; set +a
    1. Run composer install. composer install
    1. Run php built-in server. `php -S 0.0.0.0:8080 -t wordpress/
    2. Open your browser to http://localhost:8000

Setting up Nginx Unit

  • Custom build php does not make it easy to run unit

Building custom docker image

git clone https://github.com/nginx/unit
cd unit
git checkout 1.26.1
cd pkg/docker/
# make build-php7.4 VERSION_php=7.4
make dockerfiles VERSION_php=7.4
export UNIT=$(                                             \
      docker run -d --mount type=bind,src="$(pwd)/site",dst=/www  \
      -p 8080:8000 unit:1.27.0-php7.4               \
  )
docker exec -ti $UNIT curl -X PUT --data-binary @/www/config.json  \
      --unix-socket /var/run/control.unit.sock  \
      http://localhost/config

Resources

Push image to Github registry

Debugging Docker image

  • docker run --rm -it -p 8000:8000/tcp nziswano:wordpress bash

Github action to push to AWS Registry

  • Need to push generated image to AWS registry

CDK Configuration for our AWS Cloud Based WordPress instance

This is a project to automate the deployment of WordPress as a service into AWS.

  • TODO: Put diagram of overall system architecture

CDK Details

The cdk.json file tells the CDK Toolkit how to execute your app.

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

AWS ECR Config

  • Container registry via CDK
  • Created the aws-ecr-repo stack
  • Added test to test against generated cloudformation

Adding a github action to deploy this stack