Skip to content

Instantly share code, notes, and snippets.

@AugustMiller
Last active April 15, 2019 05:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AugustMiller/158b39a5525b7e75600400b2c87892a0 to your computer and use it in GitHub Desktop.
Save AugustMiller/158b39a5525b7e75600400b2c87892a0 to your computer and use it in GitHub Desktop.
Boilerplate Deployer config for a Craft 3 project https://deployer.org
<?php
namespace Deployer;
require 'recipe/composer.php';
// Project name
set('application', 'my-project');
// Project repository
set('repository', 'git@github.com:organization/repo.git');
// Use Git cache to speed up cloning new code:
set('git_cache', true);
// Allow multiplexing
set('ssh_multiplexing', true);
// Shared files/dirs between deploys
add('shared_files', [
'.env',
'config/license.key'
]);
add('shared_dirs', [
'storage',
'web/cpresources',
'web/your-asset-folder'
]);
// Composer Settings
set('composer_options', '{{composer_action}} --no-dev --optimize-autoloader --no-progress --no-interaction --ignore-platform-reqs');
// Writable dirs by web server
add('writable_dirs', []);
// Hosts
inventory('hosts.yml');
// Tasks
desc('Custom Pipeline: Build local assets');
task('build:render', function () {
runLocally('npm run build');
});
after('deploy:update_code', 'build:render');
desc('Custom Pipeline: Sync built assets to remote server');
task('build:sync', function () {
upload('web/assets/css', '{{release_path}}/web/assets', ['options' => ['--recursive']]);
upload('web/assets/js', '{{release_path}}/web/assets', ['options' => ['--recursive']]);
});
after('deploy:update_code', 'build:sync');
// Re-trigger this, as it isn't part of the default `composer` recipe:
after('deploy:vendors', 'deploy:writable');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
set('allow_anonymous_stats', false);
staging:
hostname: staging.yourdomain.com
stage: staging
roles: web
user: deploy
forwardAgent: true
deploy_path: /var/www/my-project
@AugustMiller
Copy link
Author

AugustMiller commented Jun 8, 2018

Deploy to the defined staging host with:

$ php vendor/bin/dep deploy staging

(This should always work—there are ways to make the dep command directly available to your terminal, though!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment