From 5de9bc5690197f05bfe018c0c87ae410f9c66610 Mon Sep 17 00:00:00 2001 From: Torsten Date: Tue, 29 Mar 2022 18:48:48 +0300 Subject: [PATCH] mina works --- Gemfile | 4 +- Gemfile.lock | 28 ++--------- config/deploy.rb | 94 +++++++++++++++++++++++++------------ config/deploy/production.rb | 10 ---- 4 files changed, 70 insertions(+), 66 deletions(-) delete mode 100644 config/deploy/production.rb diff --git a/Gemfile b/Gemfile index ca53a65..3268f14 100644 --- a/Gemfile +++ b/Gemfile @@ -27,9 +27,7 @@ end group :development do gem "web-console" gem "rack-mini-profiler" - gem "capistrano", "~> 3.17", require: false - gem 'capistrano-rbenv' , require: false - gem "capistrano-rails", require: false + gem "mina" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 6b32538..8549296 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,25 +68,10 @@ GEM tzinfo (~> 2.0) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) - airbrussh (1.4.0) - sshkit (>= 1.6.1, != 1.7.0) bindex (0.8.1) bootsnap (1.11.1) msgpack (~> 1.2) builder (3.2.4) - capistrano (3.17.0) - airbrussh (>= 1.0.0) - i18n - rake (>= 10.0.0) - sshkit (>= 1.9.0) - capistrano-bundler (2.0.1) - capistrano (~> 3.1) - capistrano-rails (1.6.2) - capistrano (~> 3.1) - capistrano-bundler (>= 1.1, < 3) - capistrano-rbenv (2.2.0) - capistrano (~> 3.1) - sshkit (~> 1.3) capybara (3.36.0) addressable matrix @@ -139,6 +124,9 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mina (1.2.4) + open4 (~> 1.3.4) + rake mini_mime (1.1.2) minitest (5.15.0) msgpack (1.4.5) @@ -153,8 +141,6 @@ GEM net-protocol (0.1.2) io-wait timeout - net-scp (3.0.0) - net-ssh (>= 2.6.5, < 7.0.0) net-smtp (0.3.1) digest net-protocol @@ -163,6 +149,7 @@ GEM nio4r (2.5.8) nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) + open4 (1.3.4) passenger (6.0.12) rack rake (>= 0.8.1) @@ -228,9 +215,6 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.4.2) - sshkit (1.21.2) - net-scp (>= 1.1.2) - net-ssh (>= 2.8.0) stimulus-rails (1.0.4) railties (>= 6.0.0) strscan (3.0.1) @@ -261,13 +245,11 @@ PLATFORMS DEPENDENCIES bootsnap - capistrano (~> 3.17) - capistrano-rails - capistrano-rbenv capybara debug haml-rails importmap-rails + mina net-ssh passenger (>= 5.3.2) rack-mini-profiler diff --git a/config/deploy.rb b/config/deploy.rb index 7373d62..623b9e8 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,41 +1,75 @@ -# config valid for current version and patch releases of Capistrano -lock "~> 3.17.0" +require 'mina/rails' +require 'mina/git' +require 'mina/rbenv' # for rbenv support. (https://rbenv.org) -set :application, "gateway" -set :repo_url, "https://github.com/rubydesign/gateway.git" +# Basic settings: +# domain - The hostname to SSH to. +# deploy_to - Path to deploy into. +# repository - Git repo to clone from. (needed by mina/git) +# branch - Branch name to deploy. (needed by mina/git) -# Default branch is :master -set :branch, :main +set :application_name, 'gateway' +set :domain, 'web-server.local' +set :deploy_to, '/home/feenix/gateway' +set :repository, "https://github.com/rubydesign/gateway.git" +set :branch, 'main' -# Default deploy_to directory is /var/www/my_app_name -set :deploy_to, "/home/feenix/gateway" +# Optional settings: +set :user, 'feenix' # Username in the server to SSH to. +# set :port, '30000' # SSH port number. +# set :forward_agent, true # SSH forward_agent. -# Default value for :format is :airbrussh. -# set :format, :airbrussh +# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step. +# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more +# run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files` +# set :shared_dirs, fetch(:shared_dirs, []).push('public/assets') +# set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml') -# You can configure the Airbrussh format using :format_options. -# These are the defaults. -# set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto +# This task is the environment that is loaded for all remote run commands, such as +# `mina deploy` or `mina rake`. +task :remote_environment do + # If you're using rbenv, use this to load the rbenv environment. + # Be sure to commit your .ruby-version or .rbenv-version to your repository. + # invoke :'rbenv:load' -# Default value for :pty is false -# set :pty, true + # For those using RVM, use this to load an RVM version@gemset. + # invoke :'rvm:use', 'ruby-2.5.3@default' +end -# Default value for :linked_files is [] -append :linked_files, 'config/master.key' -#"config/database.yml", +# Put any custom commands you need to run at setup +# All paths in `shared_dirs` and `shared_paths` will be created on their own. +task :setup do + # command %{rbenv install 2.5.3 --skip-existing} + # command %{rvm install ruby-2.5.3} + # command %{gem install bundler} +end -# Default value for linked_dirs is [] -append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/webpacker", "public/system", "vendor", "storage" +desc "Deploys the current version to the server." +task :deploy do + # uncomment this line to make sure you pushed your local branch to the remote origin + # invoke :'git:ensure_pushed' + deploy do + # Put things that will set up an empty directory into a fully set-up + # instance of your project. + invoke :'git:clone' + invoke :'deploy:link_shared_paths' + invoke :'bundle:install' + invoke :'rails:db_migrate' + invoke :'rails:assets_precompile' + invoke :'deploy:cleanup' -# Default value for default_env is {} -# set :default_env, { path: "/opt/ruby/bin:$PATH" } + on :launch do + in_path(fetch(:current_path)) do + command %{mkdir -p tmp/} + command %{touch tmp/restart.txt} + end + end + end -# Default value for local_user is ENV['USER'] -# set :local_user, -> { `git config user.name`.chomp } + # you can use `run :local` to run tasks on local machine before of after the deploy scripts + # run(:local){ say 'done' } +end -# Default value for keep_releases is 5 -# set :keep_releases, 5 - -# Uncomment the following to require manually verifying the host key before first deploy. -# set :ssh_options, verify_host_key: :secure -set :rbenv_ruby, '3.0.3' +# For help in making your deploy script, see the Mina documentation: +# +# - https://github.com/mina-deploy/mina/tree/master/docs diff --git a/config/deploy/production.rb b/config/deploy/production.rb deleted file mode 100644 index 7ffdc6c..0000000 --- a/config/deploy/production.rb +++ /dev/null @@ -1,10 +0,0 @@ - -# The server-based syntax can be used to override options: -# ------------------------------------ - server "web-server.local", - user: "feenix", - roles: %w{web app db}, - ssh_options: { -# auth_methods: %w(publickey) - # password: "please use keys" - }