Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

codelight-eu/trellis

 
 

Repository files navigation

Trellis, pre-configured for Codelight

This is a fork of the official Trellis repo, configured for Codelight's use. It should be kept more or less up to date with the official repo. Note that this repository is public.

For anything not covered in the quick start guide below, see the official Trellis docs or the official repo.

Instructions below assume you're running a Windows machine.

Structure

dev/              # → Root folder for all projects
├── trellis/      # → Your clone of this repository
└── site1/        # → A Bedrock-based WordPress site
    └── web/
        ├── app/  # → WordPress content directory (themes, plugins, etc.)
        └── wp/   # → WordPress core (don't touch!)
└── site2/        # → A Bedrock-based WordPress site
    └── web/
        ├── app/  # → WordPress content directory (themes, plugins, etc.)
        └── wp/   # → WordPress core (don't touch!)
└── site3/        # → A Bedrock-based WordPress site
    └── web/
        ├── app/  # → WordPress content directory (themes, plugins, etc.)
        └── wp/   # → WordPress core (don't touch!)

Quick start

Set up Trellis

Note: The instructions here prefix Trellis folder with an underscore. This differs from the official docs.

  1. Ensure you've installed all requirements listed here
  2. In Windows, open git bash & create a new root directory:
    $ mkdir dev && cd dev
  3. Clone codelight/trellis:
    $ git clone --depth=1 [email protected]:codelight-eu/trellis.git _trellis
  4. Clone codelight/bedrock:
    $ git clone --depth=1 [email protected]:codelight-eu/bedrock.git [SITENAME] && rm -rf [SITENAME]/.git Maybe use [SITENAME].local as the folder name.
  5. Make a copy of the local environment config folder example (will not be stored in the repo):
    $ cp -r _trellis/group_vars/development.example _trellis/group_vars/development
  6. Configure your WordPress site in _trellis/group_vars/development/wordpress_sites.yml and in _trellis/group_vars/development/vault.yml (use .local instead of .dev)
  7. Run $ cd _trellis && vagrant up
  8. Run $ vagrant ssh to access your new shiny box via SSH

Create another synced folder and add our required tools

  1. In Windows, clone our composer repo into the auto-generated tools folder:
    $ cd dev/_tools && git clone [email protected]:codelight-eu/composer-global.git composer todo: add a script to make this happen automagically?

Add a new local site

  1. In Windows, open git bash & go to your root directory: $ cd dev
  2. Clone codelight/bedrock:
    $ git clone --depth=1 [email protected]:codelight-eu/bedrock.git [NEW_SITENAME] && rm -rf [NEW_SITENAME]/.git Maybe use [SITENAME].local as the folder name.
  3. Configure your WordPress site in _trellis/group_vars/development/wordpress_sites.yml and in _trellis/group_vars/development/vault.yml (use .local instead of .dev)
  4. Run $ cd _trellis && vagrant halt then $ vagrant up and then $ vagrant provision

Update plugins via composer

While Composer works on both the host (Windows) machine and the guest (Vagrant) machine, you'll probably want to run composer install from inside the Vagrant box. Many of the composer packages used have specific requirements for various PHP components, which might be missing from your Windows machine. Running composer install from inside Vagrant bypasses that problem.

Build the theme

Building the theme should also be done on the host (Windows) machine. Go to the theme folder and run yarn run build:production

Documentation

Global composer file

Codelight's private repositories are stored in our global composer.json file, which is merged to every site's own composer.json using Composer Merge Plugin. If you need to add a new private or github-based repository, please add it to composer.global.json located in dev/_tools/composer/composer.global.json, commit and push.

Development

When you install a plugin from github via composer, it comes with the git repo set up. In most cases, you should be able to use that same repository for development and push your changes back up to github.

Local config

In order to override the default config with local values, create a file called vagrant.local.yml in trellis/ directory. Values defined in this file will override the values defined in vagrant.default.yml. For example, to increase the RAM assigned to the virtual machine, add the following line to vagrant.local.yml

vagrant_memory: 2048

Troubleshooting

  • Make sure sitename.local is in hosts file without www at the beginning too. Local site opens from http://sitename.local

  • If you change folder names you may need to do vagrant halt and up for it to register.

  • Vagrant currently doesn't work with VirtualBox 5.2. Use 5.1.3 instead

  • In case you are seeing the following error: "Vagrant was unable to mount VirtualBox shared folders. This is usually because the filesystem "vboxsf" is not available.", before running vagrant up run the following commands:
    vagrant plugin install vagrant-vbguest
    vagrant plugin install vagrant-winnfsd
    vagrant plugin install vagrant-bindfs

About

Ansible playbooks for a WordPress LEMP stack

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 73.6%
  • Ruby 17.9%
  • Shell 7.7%
  • PHP 0.8%