From 5485c718d39cb152cf79b8de63041a05096a40b3 Mon Sep 17 00:00:00 2001 From: Gerhard Seidel Date: Mon, 12 Aug 2019 12:42:23 +0200 Subject: [PATCH] add capistrano --- Capfile | 9 ++++++++ Gemfile | 7 ++++++ Gemfile.lock | 44 +++++++++++++++++++++++++++++++++++ config/deploy.rb | 45 ++++++++++++++++++++++++++++++++++++ config/deploy/deploy.rb.dist | 1 + 5 files changed, 106 insertions(+) create mode 100644 Capfile create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 config/deploy.rb create mode 100644 config/deploy/deploy.rb.dist diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..7c7abca --- /dev/null +++ b/Capfile @@ -0,0 +1,9 @@ +set :deploy_config_path, 'config/deploy.rb' +set :stage_config_path, 'config/deploy' +require 'capistrano/setup' +require 'capistrano/deploy' +require 'capistrano/symfony' +require 'capistrano/file-permissions' +#require 'capistrano/cachetool' +#require 'capistrano/yarn' +Dir.glob('config/capistrano/tasks/*.rake').each { |r| import r } \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a8911c9 --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' +gem 'capistrano', '~> 3.4.0' +gem 'capistrano-symfony', '~> 2.0.0.pre.alfa2' +gem 'capistrano-yarn' +gem 'capistrano-cachetool' +gem 'ed25519' +gem 'bcrypt_pbkdf' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..94cc3dd --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,44 @@ +GEM + remote: https://rubygems.org/ + specs: + bcrypt_pbkdf (1.0.0) + capistrano (3.4.1) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-cachetool (1.0.3) + capistrano-composer (0.0.6) + capistrano (>= 3.0.0.pre) + capistrano-file-permissions (1.0.0) + capistrano (~> 3.0) + capistrano-symfony (2.0.0.pre.alfa2) + capistrano (~> 3.1) + capistrano-composer (~> 0.0.3) + capistrano-file-permissions (~> 1.0) + capistrano-yarn (2.0.2) + capistrano (~> 3.0) + concurrent-ruby (1.1.4) + ed25519 (1.2.4) + i18n (1.5.3) + concurrent-ruby (~> 1.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (5.1.0) + rake (12.3.2) + sshkit (1.18.0) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + +PLATFORMS + ruby + +DEPENDENCIES + bcrypt_pbkdf + capistrano (~> 3.4.0) + capistrano-cachetool + capistrano-symfony (~> 2.0.0.pre.alfa2) + capistrano-yarn + ed25519 + +BUNDLED WITH + 1.12.5 diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..8e59f4f --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,45 @@ +# config valid only for current version of Capistrano +lock '3.4.1' + +set :application, 'enhavo-proxy' +set :repo_url, 'git@github.com:enhavo/enhavo-proxy.git' +set :deploy_to, '/var/www' +set :composer_install_flags, '' +set :linked_dirs, fetch(:linked_dirs, []).push('var/media').push('var/sessions') +set :keep_releases, 5 +set :file_permissions_chmod_mode, "0775" +set :file_permissions_paths, ["var/cache", "var/log", "var", "var/sessions"] +set :file_permissions_groups, ["www-data"] +set :use_sudo, false +set :branch, ENV['BRANCH'] if ENV['BRANCH'] + +SSHKit.config.command_map[:php] = "php" +SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}" +SSHKit.config.command_map[:cachetool] = "php #{shared_path.join("cachetool.phar")}" + +namespace :deploy do + after :starting, 'composer:install_executable' +end + +namespace :deploy do + task :migrate do + on roles(:db) do + symfony_console('doctrine:migrations:migrate', '--no-interaction') + end + end + task :routes do + on roles(:db) do + execute "cd '#{release_path}'; php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json" + end + end + task :webpack do + on roles(:db) do + execute "cd '#{release_path}'; yarn encore prod" + end + end +end + +after 'deploy:updated', 'symfony:assets:install' +after "deploy:updated", "deploy:webpack" +after "deploy:updated", "deploy:routes" +before "deploy:publishing", "deploy:migrate" \ No newline at end of file diff --git a/config/deploy/deploy.rb.dist b/config/deploy/deploy.rb.dist new file mode 100644 index 0000000..d2b1c7b --- /dev/null +++ b/config/deploy/deploy.rb.dist @@ -0,0 +1 @@ +server 'domain.tld', user: 'ssh-user', port: 22 \ No newline at end of file