nutshell-framework/deployer-recipes

The Deployer recipes used at Erdmann & Freunde

1.2.4 2024-02-21 14:39 UTC

This package is auto-updated.

Last update: 2024-10-28 10:10:44 UTC


README

The Deployer recipes used at Erdmann & Freunde.

Intended to work with Contao version 4.13+ and Deployer 7. An opinionated extension of the default Contao recipe.

Install

composer require --dev 'nutshell-framework/deployer-recipes:^1.0'

Usage

Install Deployer globally or per project.

Create a deploy.php inside the project. Either use single recipes or the simplified project.php recipe.

<?php

// deploy.php

namespace Deployer;

import(__DIR__.'/vendor/nutshell-framework/deployer-recipes/recipe/project.php');
import('contrib/cachetool.php');

set('rsync_src', __DIR__);

host('DEV')
    ->setHostname('www.example.org')
    ->set('remote_user', 'acme')
    ->set('http_user', 'acme')
    ->set('deploy_path', '/home/www/{{hostname}}')
    ->set('bin/php', 'php8.1')
    ->set('bin/composer', '{{bin/php}} /home/composer.phar')
    ->set('cachetool_args', '--web=SymfonyHttpClient --web-path=./{{public_path}} --web-url=https://{{hostname}}')
;

after('deploy:success', 'cachetool:clear:opcache');

// Project-specific exclude
add('exclude', [
    '.githooks',
]);

// Project-specific tasks
task('yarn:build', function () {
    runLocally('yarn run prod');
});

before('deploy', 'yarn:build');

after('contao:manager:download', 'contao:manager:lock');

When not using public as the web directory, please set it respectively:

{
  "extra": {
    "public-dir": "web"
  }
}

Deploy

  • dep deploy [host]

Custom .htaccess file per host

Create a .htaccess file in your project, e.g., .htaccess_prod, then configure it for the host:

host('www.example.org')
    ->set('htaccess_filename', '.htaccess_prod')

Files sync

  • dep files:retrieve [host] syncs the remote /files folder with the local /files folder

Database helpers

These tasks restore/release the database local <-> remote unidirectionally.

  • dep database:retrieve [host] downloads a database dump from remote and overwrites the local database
  • dep database:release [host] overwrites the remote database with the local one

Other

Upgrading from Deployer 6

First, it is easiest to create the deploy.php from scratch since it is much simplified now and the host config changed.

Second, since the release history numbering is not compatible between v6 and v7, you need to specify the release name manually for the first time. Otherwise, you start with release 1.

  • Find out the latest release (SSH onto the remote machine, look into the releases folder), e.g., "42".
  • dep deploy -o release_name=43

Note: Old releases from Deployer 6 won't be cleaned up automatically. Delete the old release manually. (Actually, you can also start with release 1, that's no big deal.)