Skip to content

Commit

Permalink
Add an example
Browse files Browse the repository at this point in the history
  • Loading branch information
komazarari committed Jun 23, 2015
1 parent 46f5f32 commit cb6f838
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
/pkg/
/spec/reports/
/tmp/

.vagrant
/vagrant_example/Gemfile.lock
/vagrant_example/.bundle/
/vagrant_example/vendor/
/vagrant_example/tmp/
21 changes: 21 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"

config.vm.provision "shell", inline: <<-SHELL
if ! dpkg -l | grep ruby2.2 > /dev/null; then
apt-add-repository ppa:brightbox/ruby-ng
apt-get update
apt-get install ruby2.2 -y
fi
gem install bundler --no-ri --no-rdoc
cp /vagrant/vagrant_example/.insecure_private_key /home/vagrant/.ssh/insecure_key
chmod 400 /home/vagrant/.ssh/insecure_key
chown vagrant:vagrant /home/vagrant/.ssh/insecure_key
if ! grep "`ssh-keygen -y -f .ssh/insecure_key`" /home/vagrant/.ssh/authorized_keys ;then
ssh-keygen -y -f .ssh/insecure_key >> .ssh/authorized_keys
fi
SHELL
end
27 changes: 27 additions & 0 deletions vagrant_example/.insecure_private_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
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M751U/95P9t88EDacDI/Z2OwnuFQHCPDF
llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ
kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH
+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ
NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
-----END RSA PRIVATE KEY-----
27 changes: 27 additions & 0 deletions vagrant_example/Capfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require 'capistrano/rvm'
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
# require 'capistrano/bundler'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
# require 'capistrano/passenger'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
5 changes: 5 additions & 0 deletions vagrant_example/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A sample Gemfile
source "https://rubygems.org"

gem "capistrano"
gem "capistrano-s3_archive", path: '/vagrant'
50 changes: 50 additions & 0 deletions vagrant_example/config/deploy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'my_app_name'

set :repo_url, 's3://<YOUR_BUCKET>/<PREFIX>'
set :s3_client_options, { region: 'ap-northeast-1' } # and credentials, etc if needed

# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/vagrant/my_app_name'

# Default value for :scm is :git
set :scm, :s3_archive

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')

# Default value for linked_dirs is []
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

end
7 changes: 7 additions & 0 deletions vagrant_example/config/deploy/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server 'localhost',
user: 'vagrant',
roles: ['web', 'app'],
ssh_options: {
auth_methods: ['publickey'],
keys: '/home/vagrant/.ssh/insecure_key'
}

0 comments on commit cb6f838

Please sign in to comment.