Skip to content

Latest commit

 

History

History
 
 

wordpress

Our World in Data - Headless Wordpress

Note for external contributors: this is meant for internal use only at this stage. Without the proper credentials, the installation procedure described below will fail at the lando refresh step (which tries to generate and retrieve a database dump from our servers).

Stack

  • Bedrock: Wordpress stack
  • Lando: local development environment + DevOps
  • Custom theme
  • Custom plugin

Requirements

A reasonably powerful machine with 20GB+ of available disk space.

See https://docs.lando.dev/basics/installation.html#hardware-requirements

Custom plugin

  • Extra REST API fields
  • Custom Gutenberg blocks

Overview

This setup uses Lando which internally uses docker-compose to run mysql (with one DB for wordpress and one for the grapher data) and wordpress inside containers. It comes with scripts that will fill the database for you from the (production?) server.

When you want to work with the grapher you would still run the grapher admin node server, grapher typescript server and webpack locally on your dev machine and set them up so that they talk to the mysql db and where required wordpress when necessary.

Basically this setup allows you to just follow the top level readme instruction from the section "Development server". Ask another dev for an .env variable file preconfigured with the correct settings for the top level .env config file.

Installation

Note: the following commands need to run in the current folder, not the root of the project.

  1. Install Lando (Docker comes packaged with the installer, which is the recommended way to install both).

  2. Configure (no updates necessary at this point)

    $ cp .env.example .env
  3. Start & build

    $ lando start && lando build
  4. Populate databases and retrieve Wordpress uploads

    $ lando refresh -c -u

File sharing

File sharing between host and containers is required for your HOME folder, for SSH keys to work properly.

File sharing can be adjusted in your Docker preferences.

Development

yarn and composer dependencies are not shared with the Docker host for performance reasons. They are installed during the build step (lando build) directly into their respective containers. For instance, composer dependencies can be accessed through lando ssh in /app/vendor. As a result yarnand composer need to be run from within the containers only (otherwise dependencies won't be found as they are not synced back to the host).

OWID Wordpress plugin

  1. (Once) Follow installation steps above
  2. Start development environment
lando start && lando dev

Upgrade

Bedrock

Bedrock's upgrade process is manual, and requires selective copy / paste operations from the latest release files.

Below is the (current) list of Bedrock files grouped by the type of action to be carried out on those files.

Override

  • /config/environments
  • /web/app/mu-plugins
  • /web/index.php
  • /web/wp-config.php
  • /phpcs.xml
  • /wp-cli.yml

Ignore

  • /CHANGELOG.md
  • /README.md
  • /web/app/plugins (should be empty)
  • /web/app/themes (should be empty)
  • /web/app/uploads (should be empty)
  • /composer.lock

Selectively update

  • /composer.json (keep versions pinned)
  • /config/application.php
  • /LICENSE.md (change unlikely)

Wordpress, Wordpress plugins

  1. lando ssh then composer outdated --direct to find the latest versions of direct dependencies
  2. Update composer.json with the new pinned version
  3. lando composer update