Skip to content
On this page

Docker

The Forme Codegen provides ketch - a useful selection of cli commands to run a basic zero config docker development container - similar in scope to Laravel's Sail.

Why "ketch"?

  1. Because a ketch is type of small boat which fits in nicely with Docker's shipping analogies.
  2. Because it meant we could have a ketch up command 😂

Prerequisites

  • docker & docker-compose - you can get both of these by installing Docker Desktop
  • wp cli ^2.5
  • php ^8.1
  • forme codegen ^2.0

Initialise

Firsly cd into your base installation and run

bash
forme ketch init

This will create all the relevant docker boilerplate for your project, and should also update your wp config with the relevant db credentials and other settings.

You can then run

bash
# 🍅🍅🍅
forme ketch up

This will spin up your app and mysql containers. This might take a while on first run since it needs to fetch and build images but should be pretty quick on subsequent runs.

You should be able to access your project from the browser at http://localhost and install WordPress.

You can run the following to stop and remove the running containers:

bash
forme ketch down

Don't worry though, your database data is safe. It's saved to a persistent volume.

You can also restart containers in one line

bash
forme ketch restart

If you're like us, you'll want to keep your plugin and theme repos seperate from your base install and symlink them in to keep things better organised. Local symlinks aren't recognised by docker, so forme ketch provides a convenience command to configure them within docker-compose.yml.

bash
forme ketch link /path/to/your/plugin/or/theme/repo

You might need to forme ketch down and forme ketch up if you already have running containers.

TIP

The link command operates naively and doesn't perform any kind of checks on the path. We don't currently have an unlink or undo command, so you'll need to edit docker-compose.yml manually if you make any mistakes or need to delete something.

List running containers

bash
forme ketch list

This runs docker-compose ps under the hood.

Running cli tools in the container

The ketch cli provides the ability to run composer, wp, npm and npx within the container.

bash
forme ketch composer require foo/bar
forme ketch wp forme-queue
forme ketch npm install
forme ketch npx taze

TIP

One caveat is that command line flags won't work with any of the above, but you can use shell if you need more advanced shell access within the container.

Shell access

Sometimes you need full shell access to the container in order to run more advanced commands or php scripts.

bash
forme ketch shell

This will give you a bash prompt with root access.

Under the hood

Forme's ketch configures a basic docker setup based on php@8.1, nginx and mysql@5.7. Two containers and a database persistence volume - no https, apache, dnsmasq or anything else.

It doesn't completely remove the need to have tools installed locally, but you can get away with a slightly simpler setup and should be able to get going pretty quickly.

Made by Moussa Clarke @ Sanders Web Works with ❤️