Ruby 学习:mina,轻量级的服务/app部署工具
一个ruby的部署工具,Blazing fast application deployment tool.
安装
gem install mina
环境准备
❯ mina --version
Mina, version v1.2.3
config/deploy.rb
set :deploy_to, "/www/wwwroot/data/dev.com"
set :repository, "git@github.com:alo7i/demo-dingtalk.git"
set :branch, "master"
set :shared_dirs, ["node_modules"] <特别注意这里的: shared_dirs 而不是 shared_paths>
set :keep_releases, 2 <实际上会备份3个 2 backup + 1 current>
require "mina/rails"
require "mina/git"
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
# require 'mina/rvm' # for rvm support. (https://rvm.io)
# 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)
set :application_name, "demo-dingtalk"
set :domain, "lwb"
set :deploy_to, "/www/wwwroot/data/demo-dingtalk"
set :repository, "git@github.com:alo7i/demo-dingtalk.git"
set :branch, "master"
set :shared_dirs, ["node_modules"]
set :keep_releases, 2
# 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
end
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'
command "npm install"
command "npm run build"
# invoke :'bundle:install'
# invoke :'rails:db_migrate'
# invoke :'rails:assets_precompile'
# invoke :'deploy:cleanup'
end
# you can use `run :local` to run tasks on local machine before of after the deploy scripts
# run(:local){ say 'done' }
end
# For help in making your deploy script, see the Mina documentation:
#
# - https://github.com/mina-deploy/mina/tree/master/docs
几个重要的 tasks
- setup: 初始化项目,即生成
releases/shared
等目录 - deploy: 将目标项目,执行 build 等命令,并
copy
到 releases/current
目录下 - 实际的操作,可以加个
deploy_only_build
省略掉 install 的步骤 - 老的文档里有个方法名为:
queue
现在新方法名为 command
参考