-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch standard deploy setup to bitbucket
- Loading branch information
Showing
8 changed files
with
221 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
image: statikbe/bitbucket-php81:latest | ||
|
||
pipelines: | ||
branches: | ||
develop: | ||
- step: | ||
name: Deploy to staging | ||
deployment: staging | ||
caches: | ||
- composer | ||
script: | ||
# build frontend and run composer | ||
- composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader | ||
# deploy: | ||
- cp .deploy/ssh/* ~/.ssh/. && chmod 400 ~/.ssh/bitbucket_pipelines* | ||
- dep deploy staging -vv | ||
main: | ||
- step: | ||
name: Deploy to live | ||
deployment: production | ||
caches: | ||
- composer | ||
script: | ||
# build frontend and run composer | ||
- composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader | ||
# deploy: | ||
- cp .deploy/ssh/* ~/.ssh/. && chmod 400 ~/.ssh/bitbucket_pipelines* | ||
- dep deploy production -vv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<?php | ||
namespace Deployer; | ||
|
||
require_once 'recipe/common.php'; | ||
require_once 'contrib/rsync.php'; | ||
require_once 'contrib/cachetool.php'; | ||
require_once 'contrib/yarn.php'; | ||
|
||
// Config | ||
set('repository', '[email protected]:statikbe/[PROJECT_CODE_HERE].git'); | ||
//change writeable mode to chown because combell does not have acl installed: | ||
set('writable_mode', 'chown'); | ||
set('keep_releases', 2); | ||
//set('copy_dirs', ['vendor', 'node_modules']); | ||
|
||
// [Optional] Allocate tty for git clone. Default value is false. | ||
set('git_tty', true); | ||
|
||
set('cachetool_args', '--web --web-path=./web --web-url=https://{{http_host}}'); | ||
|
||
// Shared files/dirs between deploys | ||
set('shared_files', [ | ||
'.env' | ||
]); | ||
set('shared_dirs', [ | ||
'storage', | ||
'public/files' | ||
]); | ||
|
||
// Writable dirs by web server | ||
set('writable_dirs', [ | ||
'storage', | ||
'storage/runtime', | ||
'storage/logs', | ||
'storage/rebrand', | ||
'public/cpresources', | ||
'public/frontend' | ||
]); | ||
|
||
// Set the worker process user | ||
set('http_user', 'worker'); | ||
|
||
// Disable multiplexing | ||
set('ssh_multiplexing', false); | ||
|
||
//configure rsync: | ||
set('rsync_src', __DIR__); | ||
set('rsync_dest','{{release_path}}'); | ||
set('rsync', [ | ||
'exclude' => [ | ||
'.git', | ||
'deploy.php', | ||
'node_modules', | ||
'public/frontend' | ||
], | ||
'exclude-file' => false, | ||
'include' => [], | ||
'include-file' => false, | ||
'filter' => [], | ||
'filter-file' => false, | ||
'filter-perdir' => false, | ||
'flags' => 'rz', | ||
'options' => ['delete'], | ||
'timeout' => 300, | ||
]); | ||
|
||
// Hosts | ||
import('hosts.yml'); | ||
|
||
desc('Copy the correct .htaccess file for the given stage'); | ||
task('statik:copy_htaccess', function () { | ||
$htaccessFile = get('htaccess_file'); | ||
if($htaccessFile){ | ||
run("cp {{release_path}}/config/$htaccessFile {{release_path}}/public/.htaccess"); | ||
} | ||
}); | ||
|
||
desc('Copy the correct robots.txt file for the given stage'); | ||
task('statik:copy_robots', function () { | ||
$robotsFile = get('robots_file'); | ||
if($robotsFile){ | ||
run("cp {{release_path}}/config/$robotsFile {{release_path}}/public/robots.txt"); | ||
} | ||
}); | ||
|
||
desc('Give execute permissions for the Craft console command'); | ||
task('craft:set_permissions', function () { | ||
run('chmod +x {{release_path}}/craft'); | ||
})->once(); | ||
|
||
desc('Craft up'); | ||
task('craft:up', function () { | ||
run('{{release_path}}/craft up'); | ||
})->once(); | ||
|
||
desc('Cache clear'); | ||
task('craft:clear_caches', function () { | ||
run('{{release_path}}/craft clear-caches/all'); | ||
})->once(); | ||
|
||
desc('Frontend build'); | ||
task('statik:frontend_build', function () { | ||
run('cd {{release_path}} && yarn install --ignore-optional && yarn run prod'); | ||
})->once(); | ||
|
||
desc('Fichenbak versioning'); | ||
task('statik:fichenbak_versioning', function () { | ||
run('if [ -s {{release_path}}/fichenbak-versioning.sh ]; then sh {{release_path}}/fichenbak-versioning.sh; fi'); | ||
})->once(); | ||
|
||
desc('Symlink current/public to www'); | ||
task('statik:symlink', function () { | ||
$stage = get('stage'); | ||
|
||
if ($stage === 'production') { | ||
run('if [ ! -L "/data/sites/web/[PROJECT_CODE_HERE]livestatikbe/www" ]; then ln -s subsites/[PROJECT_CODE_HERE].live.statik.be/current/public /data/sites/web/[PROJECT_CODE_HERE]livestatikbe/www; fi'); | ||
} else { | ||
run('echo "only run this task on production"'); | ||
} | ||
|
||
})->once(); | ||
|
||
//overwrite the deploy:prepare task, to change the git clone command with rsync: | ||
task('deploy:prepare', [ | ||
'deploy:info', | ||
'deploy:setup', | ||
'deploy:lock', | ||
'deploy:release', | ||
'rsync', | ||
'deploy:shared', | ||
'deploy:writable', | ||
]); | ||
|
||
task('deploy', [ | ||
'deploy:prepare', | ||
'craft:set_permissions', | ||
'craft:up', | ||
'craft:clear_caches', | ||
'statik:copy_htaccess', | ||
'statik:copy_robots', | ||
'statik:frontend_build', | ||
'statik:fichenbak_versioning', | ||
'deploy:publish', | ||
]); | ||
|
||
//Adjust standard deployment: | ||
after('deploy:failed', 'deploy:unlock'); | ||
after('deploy', 'statik:symlink'); | ||
after('deploy', 'deploy:success'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
hosts: | ||
staging: | ||
stage: staging | ||
hostname: [PROJECT_CODE_HERE].ssh.statik.be | ||
remote_user: [PROJECT_CODE_HERE]livestatikbe | ||
deploy_path: ~/subsites/[PROJECT_CODE_HERE].staging.statik.be | ||
http_user: [PROJECT_CODE_HERE]livestatikbe | ||
htaccess_file: htaccess-staging | ||
robots_file: robots-staging | ||
configFile: ~/.ssh/config | ||
http_host: [PROJECT_CODE_HERE].staging.statik.be | ||
production: | ||
stage: production | ||
hostname: [PROJECT_CODE_HERE].ssh.statik.be | ||
remote_user: [PROJECT_CODE_HERE]livestatikbe | ||
deploy_path: ~/subsites/[PROJECT_CODE_HERE].live.statik.be | ||
http_user: [PROJECT_CODE_HERE]livestatikbe | ||
htaccess_file: htaccess-production | ||
robots_file: robots-production | ||
configFile: ~/.ssh/config | ||
http_host: [PROJECT_CODE_HERE].live.statik.be |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.