Skip to content
Snippets Groups Projects

Capistrano deploy

Closed gitlab-qa-bot requested to merge github/fork/mikew/capistrano-deploy into master

Created by: mikew

Capfile.example and config/deploy.rb.example for a capistrano deployment with support for sub-uri, as discussed in #2546 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
2 set :db_adapter, 'mysql' # or postgres
3 set :mount_point, '/'
4 set :application, 'gitlabhq'
5 set :user, 'gitlab'
6 set :rails_env, 'production'
7 set :deploy_to, "/home/#{user}/apps/#{application}"
8 set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
9 set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=#{mount_point.sub /\/+\Z/, ''}"
10
11 set :use_sudo, false
12 default_run_options[:pty] = true
13
14 # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
15 set :scm, :git
16 set :repository, "git@#{domain}:#{application}.git"
17 set :deploy_via, :remote_cache
  • Created by: zzet

    mb default repo - from github?

    By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

    By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 2 set :db_adapter, 'mysql' # or postgres
    3 set :mount_point, '/'
    4 set :application, 'gitlabhq'
    5 set :user, 'gitlab'
    6 set :rails_env, 'production'
    7 set :deploy_to, "/home/#{user}/apps/#{application}"
    8 set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
    9 set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=#{mount_point.sub /\/+\Z/, ''}"
    10
    11 set :use_sudo, false
    12 default_run_options[:pty] = true
    13
    14 # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
    15 set :scm, :git
    16 set :repository, "git@#{domain}:#{application}.git"
    17 set :deploy_via, :remote_cache
    • Created by: zzet

      Application name and repo name is {{application}}? hm....

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 1 set :domain, 'set application domain here'
    2 set :db_adapter, 'mysql' # or postgres
    3 set :mount_point, '/'
    4 set :application, 'gitlabhq'
    5 set :user, 'gitlab'
    6 set :rails_env, 'production'
    7 set :deploy_to, "/home/#{user}/apps/#{application}"
    8 set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
  • gitlab-qa-bot
  • 17 set :deploy_via, :remote_cache
    18
    19 # Alternatively, you can deploy via copy, if you don't have gitlab in git
    20 #set :scm, :none
    21 #set :repository, '.'
    22 #set :deploy_via, :copy
    23
    24 server domain, :app, :web, :db, primary: true
    25
    26 namespace :foreman do
    27 desc 'Export the Procfile to Ubuntu upstart scripts'
    28 task :export, roles: :app do
    29 foreman_export = "foreman export upstart /etc/init -f Procfile -a #{application} -u #{user} -l #{shared_path}/log/foreman"
    30 run "cd #{release_path} && #{sudo} #{fetch :bundle_cmd, 'bundle'} exec #{foreman_export}"
    31 end
    32
    • Created by: zzet

      I like runit with runit-man and unicorn stop task with auto restart application %). nothing personal) Just for example :)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: zzet

      try to add some as

      namespace :deploy do
        desc "Symlinks the database.yml"
        task :symlink_db, :roles => :app do
          run "ln -nfs #{release_path}/config/database.yml.{db_adapter} #{release_path}/config/database.yml"
        end
        desc "Seed database data"
        task :seed_data do
          run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} db:seed"
        end
        desc "Symlinks the gitlab.yml"
        task :symlink_gitlab, :roles => :app do
          run "ln -nfs #{release_path}/config/gitlab.yml.{example} #{release_path}/config/gitlab.yml"
        end
        desc "Symlinks the resque.yml"
        task :symlink_resque, :roles => :app do
          run "ln -nfs #{release_path}/config/resque.yml.{example} #{release_path}/config/resque.yml"
        end
        desc "Symlinks the unicorn.rb"
        task :symlink_unicorn, :roles => :app do
          run "ln -nfs #{release_path}/config/unicorn.rb.{example} #{release_path}/config/unicorn.rb"
        end
      end
      
      before 'deploy:finalize_update',
             'deploy:symlink_db',
             'deploy:symlink_gitlab',
             'deploy:symlink_resque',
             'deploy:symlink_unicorn'

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 17 set :deploy_via, :remote_cache
    18
    19 # Alternatively, you can deploy via copy, if you don't have gitlab in git
    20 #set :scm, :none
    21 #set :repository, '.'
    22 #set :deploy_via, :copy
    23
    24 server domain, :app, :web, :db, primary: true
    25
    26 namespace :foreman do
    27 desc 'Export the Procfile to Ubuntu upstart scripts'
    28 task :export, roles: :app do
    29 foreman_export = "foreman export upstart /etc/init -f Procfile -a #{application} -u #{user} -l #{shared_path}/log/foreman"
    30 run "cd #{release_path} && #{sudo} #{fetch :bundle_cmd, 'bundle'} exec #{foreman_export}"
    31 end
    32
    • Created by: mikew

      gitlab ships with a Procfile so I went the foreman route.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: mikew

      1. I thought gitlab used seed_fu?
      2. they dropped resque, so deploy:symlink_resque isn't needed
      3. aren't these files usually edited by hand before deployment anyways?

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 1 set :domain, 'set application domain here'
    2 set :db_adapter, 'mysql' # or postgres
    3 set :mount_point, '/'
    4 set :application, 'gitlabhq'
    5 set :user, 'gitlab'
    6 set :rails_env, 'production'
    7 set :deploy_to, "/home/#{user}/apps/#{application}"
    8 set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
    • Created by: mikew

      people are free to integrate capistrano-multistage, this is an example after all. I could at least wrap domain in a block on lines 25:27 to save users from having to do it.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: zzet

      1. if desired
      2. see our example ) Read {example} as example
      3. WTF???? I sincerely sympathy.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 1 set :domain, 'set application domain here'
    2 set :db_adapter, 'mysql' # or postgres
    3 set :mount_point, '/'
    4 set :application, 'gitlabhq'
    5 set :user, 'gitlab'
    6 set :rails_env, 'production'
    7 set :deploy_to, "/home/#{user}/apps/#{application}"
    8 set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
    • Created by: zzet

      yes %) Yes, this is one great example of that in practice heavily rewritten. And that is why - it was easier to just mention readme file about capistrano ))) I think, that example must be easy integrated with minimal rewriting %) no more. I show your another examples. No more.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: mikew

      WTF???? I sincerely sympathy.

      pardon my ignorance, but that is how I've been deploying gitlab since the start:

      • clone to development machine
      • copy example files
      • edit as needed

      honestly I just deploy via copy. I don't keep gitlab in a git repository, just sync to upstream each major release.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: zzet

      In this case you can deploy from github repo

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: mikew

      then don't you run the risk of people having an exposed default password?

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: zzet

      As you with every time editing %) very bad way

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: mikew

      Why would you need to edit it every time? you set it once, and either store it in git on a private server or deploy via copy. I've only set it the one time, hardly a hassle

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: zzet

      I do not want to discuss it) You already confused in his words and contradict what was said earlier. In fact, this configuration looks like rsync or scp. I use chef for sever configuration, runit as supervisor for example, but I do not mean that all use it )))

      had a task before me to show you that the suggested configuration is not universal and it has a few drawbacks. look at the config files that are in the network. You see there are many examples of use. Restrict the user, and not the more experienced guide in a bad way - does not paint you.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
    • Created by: mikew

      it's capistrano, choose to deploy via git/scp/whatever. getting the code to the server is akin to an implementation detail (for lack of a better term). I too use chef, but that has nothing to do with this.

      earlier when I said I don't keep gitlab in a repository I meant I don't keep it in a centralized repository. apologies for that.

      I really fail to see how this is any more "restrictive" (or restrictive at all) than yours. should this pull request get merged there would be nothing stopping you from doing your team's regular changes. just like any project that comes with an example deploy script.

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • gitlab-qa-bot
  • 35 run "#{sudo} service #{application} start"
    36 end
    37
    38 desc 'Stop the application services'
    39 task :stop, roles: :app do
    40 run "#{sudo} service #{application} stop"
    41 end
    42
    43 desc 'Restart the application services'
    44 task :restart, roles: :app do
    45 run "#{sudo} service #{application} restart"
    46 end
    47 end
    48
    49 namespace :deploy do
    50 desc 'Start the application services'
  • Created by: dzaporozhets

    @zzet can you please make a PR with your version of capistrano deploy? So we can choose a better one. I'd like to have one in core.

    By Administrator on 2013-01-27T16:58:13 (imported from GitLab project)

    By Administrator on 2013-01-27T16:58:13 (imported from GitLab)

  • Created by: zzet

    @randx ok.

    By Administrator on 2013-01-27T19:00:34 (imported from GitLab project)

    By Administrator on 2013-01-27T19:00:34 (imported from GitLab)

  • gitlab-qa-bot
  • 11 set :use_sudo, false
    12 default_run_options[:pty] = true
    13
    14 # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
    15 set :scm, :git
    16 set :repository, "git@#{domain}:#{application}.git"
    17 set :deploy_via, :remote_cache
    18
    19 # Alternatively, you can deploy via copy, if you don't have gitlab in git
    20 #set :scm, :none
    21 #set :repository, '.'
    22 #set :deploy_via, :copy
    23
    24 server domain, :app, :web, :db, primary: true
    25
    26 namespace :foreman do
    • Created by: koenpunt

      To simplify you could use:

      server domain, :app, :web, :db, :primary => true

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab project)

      By Administrator on 2013-01-31T22:08:46 (imported from GitLab)

  • Created by: mikew

    pulled the latest gitlabhq/master changes into the branch. maybe I shouldn't have? that's a lot of noise up there.

    By Administrator on 2013-01-31T22:11:52 (imported from GitLab project)

    By Administrator on 2013-01-31T22:11:52 (imported from GitLab)

  • Created by: koenpunt

    You should rebase your branch instead of pulling the changes.

    By Administrator on 2013-02-03T17:48:08 (imported from GitLab project)

    By Administrator on 2013-02-03T17:48:08 (imported from GitLab)

  • Created by: dzaporozhets

    sorry but this one unreviewable. Please rebase and open new one. I close this one.

    By Administrator on 2013-02-19T09:51:19 (imported from GitLab project)

    By Administrator on 2013-02-19T09:51:19 (imported from GitLab)

  • Created by: mikew

    figured. will do that now

    By Administrator on 2013-02-20T03:21:05 (imported from GitLab project)

    By Administrator on 2013-02-20T03:21:05 (imported from GitLab)

  • Please register or sign in to reply
    Loading