Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Docker files for running a basic WordPress application.

License

Notifications You must be signed in to change notification settings

korben-info/wordpress-sail

 
 

Repository files navigation

Introduction

Sail provides a Docker powered local development experience for Laravel that is compatible with macOS, Windows (WSL2), and Linux.

This library has taken that work and tailored it for a WordPress environment.

Other than Docker, no software or libraries are required to be installed on your local computer before using Sail. Sail's simple CLI means you can start building your Laravel application without any previous Docker experience.

Inspiration

WordPress Sail is inspired by and derived from Laravel Sail, which is inspired by and derived from Vessel by Chris Fidao. If you're looking for a thorough introduction to Docker, check out Chris' course: Shipping Docker.

Installation

From a Bedrock project, require WordPress Sail:

composer require sterner-stuff/wordpress-sail

To ensure the local autoloader is run as part of the WP-CLI lifecycle, ensure it's included in your wp-cli.yml file:

require:
    - vendor/autoload.php

Scaffold your docker-composer.yml file:

wp sail:install [--with=]

By default, MySQL and Mailhog containers will be attached, but you can also use, for example, Redis:

wp sail:install --with=mysql,mailhog,redis

At this point, you may want to change the version of PHP used in the docker-compose.yml file.

version: '3'
services:
    wordpress.test:
        build:
            context: ./vendor/sterner-stuff/wordpress-sail/runtimes/8.1 <-- Supports 7.4, 8.0, and 8.1
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: wordpress-sail-8.1/app <-- Update here as well.
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        # ...

Finally, build your containers:

vendor/bin/sail build

Install without PHP/Composer on your host machine

If you're trying to use purely Docker to get going, that's an option. We'll assume you already started your Bedrock project and updated wp-cli.yml. Then you can run these two commands:

// Require Sail
docker run -it --rm \
	-u "$(id -u):$(id -g)" \
	-v $(pwd):/var/www/html \
	-w /var/www/html \
	composer \
	require --dev sterner-stuff/wordpress-sail

// Scaffold your docker-compose.yml file
docker run -it --rm \
	-u "$(id -u):$(id -g)" \
	-v $(pwd):/var/www/html \
	-w /var/www/html \
	wordpress:cli-php8.1 \
	sail:install

When using the wordpress:cli-phpx.x image, you should use the same version of PHP that you're using for your application (7.4, 8.0, or 8.1).

Usage

WordPress Sail tries to match Laravel Sail as closely as possible. WP-CLI is also now available in your container, so you don't need to use the bundled one.

You might do some of the following (assuming you've aliased sail to vendor/bin/sail):

sail up -d
sail down
sail wp cli info
sail tinker # alias for wp shell

If you want to customize the Dockerfile used:

sail up -d
sail wp sail:publish
sail down

After customizing your Sail installation, change the image name for the application container in your application's docker-compose.yml file so it doesn't conflict with other projects using the default Dockerfile. Then run sail build --no-cache

Starting on a project with Sail already installed

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

When using the laravelsail/phpXX-composer image, you should use the same version of PHP that you're using for your application (74, 80, or 81).

Official Documentation

WordPress Sail should be considered unstable and does not currently have docs. Documentation for Sail can be found on the Laravel website.

Contributing

Thank you for considering contributing to Sail! You can read the contribution guide here.

License

Laravel Sail is open-sourced software licensed under the MIT license.

About

Docker files for running a basic WordPress application.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 45.6%
  • PHP 27.5%
  • Dockerfile 26.9%