Skip to content

Latest commit

 

History

History
190 lines (157 loc) · 5.54 KB

default_plugins.md

File metadata and controls

190 lines (157 loc) · 5.54 KB

Default Plugins

mina comes with a variety of plugins for you to use out of the box. As mina is primarely written in ruby and for rails, it has ruby plugins, but it can be used to deploy any other application (static, js, php, etc)

To use a plugin you only need to require it in your deploy.rb. Most of the plugins come with a set of their own variables which are usable, chengable and overwritable.

Example:

require 'mina/rails'

set :rails_env, 'staging'

You can also override a variable from command line like:

$ mina deploy rails_env=development

Default

require 'mina/default'

Variables

  :repository             #=> nil
  :domain                 #=> nil
  :port                   #=> 22
  :deploy_to              #=> nil
  :execution_mode         #=> :pretty ## Can be [:exec, :pretty, :printer, :system]

Execution mode

See Execution mode

Tasks

  local_environment       #=> Task to be run before all local tasks
  remote_environment      #=> Task to be run before all remote tasks
  ssh_keyscan_domain      #=> Adds repository host to the known hosts
  ssh_keyscan_repo        #=> Adds domain to the known hosts
  run                     #=> Runs a command on the server; Example: `$ mina 'run[rake db:migrate]'`
  ssh                     #=> Open an ssh session to the server and cd to deploy_to folder

Deploy

require 'mina/deploy'

loads:

  • mina/default

Variables

  :releases_path          #=> "#{fetch(:deploy_to)}/releases"
  :shared_path            #=> "#{fetch(:deploy_to)}/shared"
  :current_path           #=> "#{fetch(:deploy_to)}/current"
  :lock_file              #=> 'deploy.lock'
  :deploy_script          #=> Mina.root_path('data/deploy.sh.erb')
  :keep_releases          #=> 5
  :version_scheme         #=> :sequence ## Can be [:sequence, :datetime]
  :shared_dirs            #=> []
  :shared_fiels           #=> []

Tasks

  # deploy:* tasks are not meant to be run outside `deploy do` block
  deploy:force_unlock      #=> Removes .force_unlock file
  deploy:link_shared_paths #=> Link paths set in `:shared_dirs` and `:shared_files`
  deploy:cleanup           #=> Cleans up old releases

  rollback                 #=> Rollbacks the latest release; does not rollback database
  setup                    #=> Sets up the site

Version scheme

:version_scheme variable sets the naming for your release folders.

# :sequence
.
├── releases
│   ├── 87
│   ├── 88
│   ├── 89
│   ├── 90
│   ├── 91
│   └── 92

# :datetime
.
├── releases
│   ├── 20170701123242
│   ├── 20170704131253
│   ├── 20170708032142
│   ├── 20170710082353
│   └── 20170720012031

Git

require 'mina/git'

loads:

  • mina/default

Variables

  :branch                 #=> 'master'
  :remove_git_dir         #=> true
  :remote                 #=> 'origin'
  :git_not_pushed_message #=> "Your branch #{fetch(:branch)} needs to be pushed to #{fetch(:remote)} before deploying"

Tasks

  # git:clone is not meant to be run outside `deploy do` block
  git:clone               #=> Clones the Gir repository to the current path
  git:revision            #=> Prints out current revision
  git:ensure_pushed       #=> Ensures local repository is pushed to remote

Bundler

require 'mina/bundler'

loads:

  • mina/default

Variables

  :bundle_bin             #=> 'bundle'
  :bundle_path            #=> 'vendor/bundle'
  :bundle_withouts        #=> 'development test'
  :bundle_options         #=> "--without #{fetch(:bundle_withouts)} --path "#{fetch(:bundle_path)}" --deployment"
  :shared_dirs            #=> fetch(:shared_dirs, []).push(fetch(:bundle_path)) ## Add `bundle_path` to `shared_dirs`

Tasks

  bundle:install          #=> Install gem dependencies using Bundler
  bundle:clean            #=> Cleans up unused gems in your bundler directory

Rails

require 'mina/rails'

loads:

  • mina/deploy
  • mina/bundler

Variables

  :rails_env              #=> 'production'
  :bundle_prefix          #=> %{RAILS_ENV="#{fetch(:rails_env)}" #{fetch(:bundle_bin)} exec}
  :rake                   #=> "#{fetch(:bundle_prefix)} rake"
  :rails                  #=> "#{fetch(:bundle_prefix)} rails"
  :compiled_asset_path    #=> 'public/assets'
  :asset_dirs             #=> ['vendor/assets/', 'app/assets/']
  :migration_dirs         #=> ['db/migrate']
  :force_migrate          #=> false
  :force_asset_precompile #=> false

Tasks

  console                 #=> Starts and interactive console
  log                     #=> Tail log from server
  rails[command]          #=> Runs rails command; example `$ mina 'rails[console]'`
  rake[command]           #=> Runs rake command; example `$ mina 'rake[db:migrate]'`

  # rails:* tasks are not meant to be run outside of `deploy do` block. Please use the tasks above.
  rails:db_migrate        #=> Checks for changes in `:migration_dirs` and runs `db:migrate` if needed. Can be forced with `:force_migrate` variable
  rails:assets_precompile #=> Checks for changes in `:asset_dirs` and runs `assets:precomile` if needed. Can be fored with `:force_asset_precompile` variable
  rails:db_create         #=> Runs `db:create`
  rails:db_rollback       #=> Runs `db:rollback`
  rails:assets_clean      #=> Runs `assets:clean`
  rails:db_schema_load    #=> Runs `db:schema:load`