LOADING

Follow me

Deploy Node Application in Docker with Capistrano【zoues.com】
十二月 31, 2016|DockerPaaS

Deploy Node Application in Docker with Capistrano【zoues.com】

Deploy Node Application in Docker with Capistrano【zoues.com】

Deploy Node Application in Docker with Capistrano

之前有尝试过shipit,不过其方式,插件和 bug,都蛮让人失望的。

Prepare

$ bundle init 

修改 Gemfile 内容为以下:

source "http://ruby.taobao.org"  gem 'capistrano' 

初始化当前目录为 Cap:

$ bundle exec cap install 

会生成下面的一个目录结构(为简单,修改为prod.rb):

. ├── Capfile ├── config │   ├── deploy │   │   ├── prod.rb │   │   └── staging.rb │   └── deploy.rb └── lib     └── capistrano             └── tasks 

Cap Config

deploy.rb 文件主要是配置所有发布环境的公共配置

config/deploy.rb
set :application, 'd2labs_beta' set :deploy_user, 'deploy' set :repo_url, 'git@github.org:lanvige/test.git' 

除了公共配置文件外,每个环境都有自己的配置文件:

config/depoly/prod.rb
set :stage, :production set :branch, 'master'  # Extended Server Syntax server '10.10.10.1', user: 'deploy', roles: %w{web app db}  # used in case we're deploying multiple versions of the same # app side by side. Also provides quick sanity checks when looking # at filepaths set :full_app_name, "#{fetch(:application)}"  ## where to put the app set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}" 

在Deploy 前,我们还需要添加一些功能,将 site-enabled/nginx.conf 的配置文件添加到Remote Server下。

no comments
Share

发表评论