rail_pass 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +20 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/rail_pass/application.js +15 -0
  5. data/app/assets/stylesheets/rail_pass/application.css +13 -0
  6. data/app/controllers/rail_pass/application_controller.rb +4 -0
  7. data/app/controllers/rail_pass/styleguide_controller.rb +7 -0
  8. data/app/helpers/rail_pass/application_helper.rb +4 -0
  9. data/app/views/rail_pass/styleguide/index.html.haml +104 -0
  10. data/config/routes.rb +3 -0
  11. data/lib/generators/rail_pass/install_generator.rb +220 -0
  12. data/lib/generators/templates/Procfile +1 -0
  13. data/lib/generators/templates/app/assets/javascripts/application.js +17 -0
  14. data/lib/generators/templates/app/assets/javascripts/html5.js +14 -0
  15. data/lib/generators/templates/app/assets/javascripts/polyfills.js +14 -0
  16. data/lib/generators/templates/app/assets/javascripts/responsive.js +14 -0
  17. data/lib/generators/templates/app/assets/javascripts/scripts.js.coffee +0 -0
  18. data/lib/generators/templates/app/assets/stylesheets/application.css.scss +26 -0
  19. data/lib/generators/templates/app/assets/stylesheets/base/_colors.scss +1 -0
  20. data/lib/generators/templates/app/assets/stylesheets/base/_defaults.scss +27 -0
  21. data/lib/generators/templates/app/assets/stylesheets/base/_forms.scss +0 -0
  22. data/lib/generators/templates/app/assets/stylesheets/base/_settings.scss +0 -0
  23. data/lib/generators/templates/app/assets/stylesheets/base/_typography.scss +3 -0
  24. data/lib/generators/templates/app/assets/stylesheets/layout/_containers.scss +18 -0
  25. data/lib/generators/templates/app/assets/stylesheets/layout/_footer.scss +1 -0
  26. data/lib/generators/templates/app/assets/stylesheets/layout/_header.scss +1 -0
  27. data/lib/generators/templates/app/assets/stylesheets/layout/_settings.scss +1 -0
  28. data/lib/generators/templates/app/assets/stylesheets/modules/_buttons.scss +15 -0
  29. data/lib/generators/templates/app/controllers/pages_controller.rb +2 -0
  30. data/lib/generators/templates/app/helpers/application_helper.rb +87 -0
  31. data/lib/generators/templates/app/views/errors/404.html.haml +3 -0
  32. data/lib/generators/templates/app/views/layouts/application.html.haml +124 -0
  33. data/lib/generators/templates/app/views/pages/index.html.haml +0 -0
  34. data/lib/generators/templates/config/deploy.rb +34 -0
  35. data/lib/generators/templates/config/initializers/dev_environment.rb +6 -0
  36. data/lib/generators/templates/config/initializers/new_relic.rb +5 -0
  37. data/lib/generators/templates/config/mongoid.yml +68 -0
  38. data/lib/generators/templates/config/newrelic.yml +255 -0
  39. data/lib/generators/templates/config/recipes/base.rb +86 -0
  40. data/lib/generators/templates/config/recipes/check.rb +13 -0
  41. data/lib/generators/templates/config/recipes/mongodb/install-outdated.rb +41 -0
  42. data/lib/generators/templates/config/recipes/mongodb/install.rb +45 -0
  43. data/lib/generators/templates/config/recipes/mongodb/manage.rb +27 -0
  44. data/lib/generators/templates/config/recipes/mongodb.rb +73 -0
  45. data/lib/generators/templates/config/recipes/mysql.rb +152 -0
  46. data/lib/generators/templates/config/recipes/nginx.rb +25 -0
  47. data/lib/generators/templates/config/recipes/nodejs.rb +9 -0
  48. data/lib/generators/templates/config/recipes/postgresql.rb +34 -0
  49. data/lib/generators/templates/config/recipes/rbenv.rb +29 -0
  50. data/lib/generators/templates/config/recipes/redis.rb +18 -0
  51. data/lib/generators/templates/config/recipes/ruby.rb +93 -0
  52. data/lib/generators/templates/config/recipes/templates/foreman.erb +2 -0
  53. data/lib/generators/templates/config/recipes/templates/gitlab.yml.erb +29 -0
  54. data/lib/generators/templates/config/recipes/templates/mongoid.yml.erb +10 -0
  55. data/lib/generators/templates/config/recipes/templates/mysql.yml.erb +7 -0
  56. data/lib/generators/templates/config/recipes/templates/nginx_unicorn.erb +27 -0
  57. data/lib/generators/templates/config/recipes/templates/postgresql.yml.erb +8 -0
  58. data/lib/generators/templates/config/recipes/templates/unicorn.rb.erb +8 -0
  59. data/lib/generators/templates/config/recipes/templates/unicorn_init.erb +84 -0
  60. data/lib/generators/templates/config/recipes/unicorn.rb +28 -0
  61. data/lib/generators/templates/config/recipes/utilities.rb +144 -0
  62. data/lib/generators/templates/config/unicorn.rb +2 -0
  63. data/lib/generators/templates/public/422.html +54 -0
  64. data/lib/generators/templates/public/500.html +54 -0
  65. data/lib/generators/templates/spec/spec_helper.rb +41 -0
  66. data/lib/generators/templates/vendor/assets/fonts/fontawesome/fontawesome-webfont.eot +0 -0
  67. data/lib/generators/templates/vendor/assets/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
  68. data/lib/generators/templates/vendor/assets/fonts/fontawesome/fontawesome-webfont.woff +0 -0
  69. data/lib/generators/templates/vendor/assets/fonts/icomoon/icomoon.eot +0 -0
  70. data/lib/generators/templates/vendor/assets/fonts/icomoon/icomoon.svg +36 -0
  71. data/lib/generators/templates/vendor/assets/fonts/icomoon/icomoon.ttf +0 -0
  72. data/lib/generators/templates/vendor/assets/fonts/icomoon/icomoon.woff +0 -0
  73. data/lib/generators/templates/vendor/assets/javascripts/jquery.ui.touch-punch.min.js +11 -0
  74. data/lib/generators/templates/vendor/assets/javascripts/polyfills/html5shim.js +3 -0
  75. data/lib/generators/templates/vendor/assets/javascripts/polyfills/modernizr.js +4 -0
  76. data/lib/generators/templates/vendor/assets/javascripts/polyfills/respond.js +15 -0
  77. data/lib/generators/templates/vendor/assets/javascripts/polyfills/selectivizr.js +560 -0
  78. data/lib/generators/templates/vendor/assets/stylesheets/font-awesome.scss +493 -0
  79. data/lib/generators/templates/vendor/assets/stylesheets/icomoon.scss +22 -0
  80. data/lib/rail_pass/engine.rb +5 -0
  81. data/lib/rail_pass/version.rb +3 -0
  82. data/lib/rail_pass.rb +4 -0
  83. data/lib/tasks/rail_pass_tasks.rake +4 -0
  84. metadata +146 -0
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../utilities')
2
+ require File.expand_path(File.dirname(__FILE__) + '/manage')
3
+
4
+ Capistrano::Configuration.instance(true).load do
5
+ set :mongodb_data_path, "/data/db"
6
+ set :mongodb_bin_path, "/opt/mongo"
7
+
8
+ namespace :mongodb do
9
+ desc "Installs mongodb binaries and all dependencies"
10
+ task :install, :role => :app do
11
+ utilities.apt_install "tcsh scons g++ libpcre++-dev"
12
+ utilities.apt_install "libboost1.37-dev libreadline-dev xulrunner-dev"
13
+ mongodb.make_spidermonkey
14
+ mongodb.make_mongodb
15
+ # mongodb.setup_db_path
16
+ end
17
+ # after "deploy:install", "mongodb:install"
18
+
19
+ task :make_spidermonkey, :role => :app do
20
+ run "mkdir -p ~/tmp"
21
+ run "cd ~/tmp; wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz"
22
+ run "cd ~/tmp; tar -zxvf js-1.7.0.tar.gz"
23
+ run "cd ~/tmp/js/src; export CFLAGS=\"-DJS_C_STRINGS_ARE_UTF8\""
24
+ run "cd ~/tmp/js/src; #{sudo} make -f Makefile.ref"
25
+ run "cd ~/tmp/js/src; #{sudo} JS_DIST=/usr make -f Makefile.ref export"
26
+ end
27
+
28
+ task :make_mongodb, :role => :app do
29
+ sudo "rm -rf ~/tmp/mongo"
30
+ run "cd ~/tmp; git clone git://github.com/mongodb/mongo.git"
31
+ run "cd ~/tmp/mongo; #{sudo} scons all"
32
+ run "cd ~/tmp/mongo; #{sudo} scons --prefix=#{mongodb_bin_path} install"
33
+ end
34
+
35
+ task :setup_db_path, :role => :app do
36
+ sudo "mkdir -p #{mongodb_data_path}"
37
+ mongodb.start
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,45 @@
1
+ # # require File.expand_path(File.dirname(__FILE__) + '/../utilities')
2
+ # # require File.expand_path(File.dirname(__FILE__) + '/manage')
3
+ #
4
+ # # set :mongodb_data_path, "/data/db"
5
+ # # set :mongodb_bin_path, "/opt/mongo"
6
+ #
7
+ # namespace :mongodb do
8
+ # desc "Installs mongodb via apt repository"
9
+ # task :install, :role => :app do
10
+ # run "#{sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10"
11
+ # run "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen"
12
+ # run "#{sudo} apt-get -y update"
13
+ # run "#{sudo} apt-get -y install mongodb-10gen"
14
+ #
15
+ # # utilities.apt_install "tcsh scons g++ libpcre++-dev"
16
+ # # utilities.apt_install "libboost1.37-dev libreadline-dev xulrunner-dev"
17
+ # # mongodb.make_spidermonkey
18
+ # # mongodb.make_mongodb
19
+ #
20
+ # # mongodb.setup_db_path
21
+ # end
22
+ # after "deploy:install", "mongodb:install"
23
+ #
24
+ # # task :make_spidermonkey, :role => :app do
25
+ # # run "mkdir -p ~/tmp"
26
+ # # run "cd ~/tmp; wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz"
27
+ # # run "cd ~/tmp; tar -zxvf js-1.7.0.tar.gz"
28
+ # # run "cd ~/tmp/js/src; export CFLAGS=\"-DJS_C_STRINGS_ARE_UTF8\""
29
+ # # run "cd ~/tmp/js/src; #{sudo} make -f Makefile.ref"
30
+ # # run "cd ~/tmp/js/src; #{sudo} JS_DIST=/usr make -f Makefile.ref export"
31
+ # # end
32
+ # #
33
+ # # task :make_mongodb, :role => :app do
34
+ # # sudo "rm -rf ~/tmp/mongo"
35
+ # # run "cd ~/tmp; git clone git://github.com/mongodb/mongo.git"
36
+ # # run "cd ~/tmp/mongo; #{sudo} scons all"
37
+ # # run "cd ~/tmp/mongo; #{sudo} scons --prefix=#{mongodb_bin_path} install"
38
+ # # end
39
+ #
40
+ # # task :setup_db_path, :role => :app do
41
+ # # sudo "mkdir -p #{mongodb_data_path}"
42
+ # # mongodb.start
43
+ # # end
44
+ #
45
+ # end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../utilities')
2
+ require File.expand_path(File.dirname(__FILE__) + '/install')
3
+
4
+ Capistrano::Configuration.instance(true).load do
5
+ set :mongodb_log, "/var/log/mongodb.log"
6
+
7
+ namespace :mongodb do
8
+ desc "Starts the mongodb server"
9
+ task :start, :role => :app do
10
+ sudo "#{mongodb_bin_path}/bin/mongod --fork --logpath #{mongodb_log} --logappend --dbpath #{mongodb_data_path}"
11
+ end
12
+
13
+ desc "Stop the mongodb server"
14
+ task :stop, :role => :app do
15
+ pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
16
+ sudo "kill -INT #{pid}" unless pid.strip.empty?
17
+ end
18
+
19
+ desc "Restart the mongodb server"
20
+ task :restart, :role => :app do
21
+ pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
22
+ mongodb.stop unless pid.strip.empty?
23
+ mongodb.start
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,73 @@
1
+ # Dir[File.join(File.dirname(__FILE__), 'mongodb/*.rb')].sort.each { |lib| require lib }
2
+
3
+ set_default(:mongodb_host, "localhost")
4
+ set_default(:mongodb_user) { application }
5
+ set_default(:mongodb_password) { Capistrano::CLI.password_prompt "MongoDB Password: " }
6
+ set_default(:mongodb_database) { "#{application}_production" }
7
+
8
+ namespace :mongodb do
9
+ desc "Installs mongodb via apt repository"
10
+ task :install, :role => :app do
11
+ run "#{sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10"
12
+ run "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' >> /tmp/mongodb.list"
13
+ run "#{sudo} cp /tmp/mongodb.list /etc/apt/sources.list.d/"
14
+ run "rm /tmp/mongodb.list"
15
+ run "#{sudo} apt-get -y update"
16
+ run "#{sudo} apt-get -y install mongodb-10gen"
17
+ end
18
+ after "deploy:install", "mongodb:install"
19
+
20
+
21
+ # Setup
22
+ desc "Create a database for this application."
23
+ task :create_database, roles: :db, only: {primary: true} do
24
+ run "mongo #{mongodb_database} --eval 'db.addUser(\"#{mongodb_user}\", \"#{mongodb_password}\")'"
25
+ end
26
+ after "deploy:setup", "mongodb:create_database"
27
+
28
+
29
+ # Create YML
30
+ desc "Generate the mongoid.yml configuration file."
31
+ task :setup, roles: :app do
32
+ run "mkdir -p #{shared_path}/config"
33
+ template "mongoid.yml.erb", "#{shared_path}/config/mongoid.yml"
34
+ end
35
+ after "deploy:setup", "mongodb:setup"
36
+ after "mongodb:create_database", "mongodb:setup"
37
+
38
+
39
+ # Symlink YML
40
+ desc "Symlink mongoid.yml"
41
+ task :symlink, roles: :app do
42
+ run "ln -nfs #{shared_path}/config/mongoid.yml #{release_path}/config/mongoid.yml"
43
+ end
44
+ after "deploy:finalize_update", "mongodb:symlink"
45
+
46
+
47
+ # Services
48
+ desc "Starts the mongodb server"
49
+ task :start, :role => :app do
50
+ # sudo "#{mongodb_bin_path}/bin/mongod --fork --logpath #{mongodb_log} --logappend --dbpath #{mongodb_data_path}"
51
+ run "#{sudo} sudo service mongodb start"
52
+ end
53
+
54
+
55
+ desc "Stop the mongodb server"
56
+ task :stop, :role => :app do
57
+ # pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
58
+ # sudo "kill -INT #{pid}" unless pid.strip.empty?
59
+ run "#{sudo} sudo service mongodb stop"
60
+ end
61
+
62
+
63
+ desc "Restart the mongodb server"
64
+ task :restart, :role => :app do
65
+ # pid = capture("ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'")
66
+ # mongodb.stop unless pid.strip.empty?
67
+ # mongodb.start
68
+ run "#{sudo} sudo service mongodb restart"
69
+ end
70
+ after "deploy:setup", "mongodb:restart"
71
+
72
+
73
+ end
@@ -0,0 +1,152 @@
1
+ require 'erb'
2
+
3
+ set_default(:mysql_host, "localhost")
4
+ set_default(:mysql_user) { application }
5
+ set_default(:mysql_password) { Capistrano::CLI.password_prompt "Enter #{environment} database password:" }
6
+ set_default(:mysql_database) { "#{application}_production" }
7
+
8
+
9
+ namespace :mysql do
10
+
11
+ desc <<-EOF
12
+ Performs a compressed database dump. \
13
+ WARNING: This locks your tables for the duration of the mysqldump.
14
+ Don't run it madly!
15
+ EOF
16
+ task :dump, :roles => :db, :only => { :primary => true } do
17
+ prepare_from_yaml
18
+ run "mysqldump --user=#{mysql_user} -p --host=#{mysql_host} #{mysql_database} | bzip2 -z9 > #{db_remote_file}" do |ch, stream, out|
19
+ ch.send_data "#{mysql_password}\n" if out =~ /^Enter password:/
20
+ puts out
21
+ end
22
+ end
23
+
24
+
25
+ desc "Restores the database from the latest compressed dump"
26
+ task :restore, :roles => :db, :only => { :primary => true } do
27
+ prepare_from_yaml
28
+ run "bzcat #{db_remote_file} | mysql --user=#{mysql_user} -p --host=#{mysql_host} #{mysql_database}" do |ch, stream, out|
29
+ ch.send_data "#{mysql_password}\n" if out =~ /^Enter password:/
30
+ puts out
31
+ end
32
+ end
33
+
34
+
35
+ desc "Downloads the compressed database dump to this machine"
36
+ task :fetch_dump, :roles => :db, :only => { :primary => true } do
37
+ prepare_from_yaml
38
+ download db_remote_file, db_local_file, :via => :scp
39
+ end
40
+
41
+
42
+ desc "Installs MySQL via apt-get"
43
+ task :install, role: :db do
44
+ # run "#{sudo} apt-get -y update"
45
+ run "#{sudo} apt-get -y install mysql-server"
46
+ end
47
+ # after "deploy:install", "mysql:install"
48
+
49
+
50
+ desc "Create MySQL database and user for this environment using prompted values"
51
+ task :setup, :roles => :db, :only => { :primary => true } do
52
+ prepare_for_db_command
53
+
54
+ sql = <<-SQL
55
+ CREATE DATABASE #{mysql_database};
56
+ GRANT ALL PRIVILEGES ON #{mysql_database}.* TO #{mysql_user}@localhost IDENTIFIED BY '#{mysql_password}';
57
+ SQL
58
+
59
+ run "mysql --user=#{db_admin_user} -p --execute=\"#{sql}\"" do |channel, stream, data|
60
+ if data =~ /^Enter password:/
61
+ pass = Capistrano::CLI.password_prompt "Enter database password for '#{db_admin_user}':"
62
+ channel.send_data "#{pass}\n"
63
+ end
64
+ end
65
+ end
66
+ after "deploy:setup", "mysql:setup"
67
+
68
+
69
+ desc "Create database.yml in shared path with settings for current stage and test env"
70
+ task :create_yaml do
71
+ # Original 'set' -----
72
+ # set(:mysql_user) { Capistrano::CLI.ui.ask "Enter #{environment} database username:" }
73
+ # set(:mysql_password) { Capistrano::CLI.password_prompt "Enter #{environment} database password:" }
74
+ # Custom 'set' -----
75
+ # set_default(:postgresql_user) { application }
76
+ # set_default(:mysql_password) { Capistrano::CLI.password_prompt "Enter #{environment} database password:" }
77
+
78
+ template "mysql.yml.erb", "#{shared_path}/config/database.yml"
79
+ # TODO move this into ERB template, it's broken
80
+ # db_config = ERB.new <<-EOF
81
+ # base: &base
82
+ # adapter: mysql2
83
+ # encoding: utf8
84
+ # username: #{mysql_user}
85
+ # password: #{mysql_password}
86
+ #
87
+ # #{environment}:
88
+ # database: #{application}_#{environment}
89
+ # <<: *base
90
+ #
91
+ # test:
92
+ # database: #{application}_test
93
+ # <<: *base
94
+ # EOF
95
+
96
+ # put db_config.result, "#{shared_path}/config/database.yml"
97
+ end
98
+ after "deploy:setup", "mysql:create_yaml"
99
+
100
+
101
+ desc "Symlink the database.yml file into latest release"
102
+ task :symlink, roles: :app do
103
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
104
+ end
105
+ before "deploy:assets:precompile", "mysql:symlink"
106
+ after "deploy", "mysql:symlink"
107
+
108
+
109
+ # Sets database variables from remote database.yaml
110
+ def prepare_from_yaml
111
+ set(:db_file) { "#{application}-dump.sql.bz2" }
112
+ set(:db_remote_file) { "#{shared_path}/backup/#{db_file}" }
113
+ set(:db_local_file) { "tmp/#{db_file}" }
114
+ set(:mysql_user) { db_config[rails_env]["username"] }
115
+ set(:mysql_password) { db_config[rails_env]["password"] }
116
+ set(:mysql_host) { db_config[rails_env]["host"] }
117
+ set(:mysql_database) { db_config[rails_env]["database"] }
118
+ end
119
+
120
+
121
+ def db_config
122
+ @db_config ||= fetch_db_config
123
+ end
124
+
125
+
126
+ def fetch_db_config
127
+ require 'yaml'
128
+ file = capture "cat #{shared_path}/config/database.yml"
129
+ db_config = YAML.load(file)
130
+ end
131
+
132
+ end
133
+
134
+
135
+
136
+
137
+ def prepare_for_db_command
138
+ # set :mysql_database, "#{application}_#{environment}"
139
+ set(:db_admin_user) { Capistrano::CLI.ui.ask "Username with priviledged database access (to create db):" }
140
+ # set(:mysql_user) { Capistrano::CLI.ui.ask "Enter #{environment} database username:" }
141
+ # set(:mysql_password) { Capistrano::CLI.password_prompt "Enter #{environment} database password:" }
142
+ end
143
+
144
+ desc "Populates the database with seed data"
145
+ task :seed do
146
+ Capistrano::CLI.ui.say "Populating the database..."
147
+ run "cd #{current_path}; rake RAILS_ENV=#{variables[:rails_env]} db:seed"
148
+ end
149
+
150
+ # after "deploy:setup" do
151
+ # db.create_yaml if Capistrano::CLI.ui.agree("Create database.yml in app's shared path? [Yn]")
152
+ # end
@@ -0,0 +1,25 @@
1
+ namespace :nginx do
2
+ desc "Install latest stable release of nginx"
3
+ task :install, roles: :web do
4
+ run "#{sudo} add-apt-repository ppa:nginx/stable --yes"
5
+ run "#{sudo} apt-get -y update"
6
+ run "#{sudo} apt-get -y install nginx"
7
+ end
8
+ after "deploy:install", "nginx:install"
9
+
10
+ desc "Setup nginx configuration for this application"
11
+ task :setup, roles: :web do
12
+ template "nginx_unicorn.erb", "/tmp/nginx_conf"
13
+ run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}"
14
+ run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
15
+ restart
16
+ end
17
+ after "deploy:setup", "nginx:setup"
18
+
19
+ %w[start stop restart].each do |command|
20
+ desc "#{command} nginx"
21
+ task command, roles: :web do
22
+ run "#{sudo} service nginx #{command}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ namespace :nodejs do
2
+ desc "Install the latest relase of Node.js"
3
+ task :install, roles: :app do
4
+ run "#{sudo} add-apt-repository ppa:chris-lea/node.js --yes"
5
+ run "#{sudo} apt-get -y update"
6
+ run "#{sudo} apt-get -y install nodejs"
7
+ end
8
+ after "deploy:install", "nodejs:install"
9
+ end
@@ -0,0 +1,34 @@
1
+ set_default(:postgresql_host, "localhost")
2
+ set_default(:postgresql_user) { application }
3
+ set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
4
+ set_default(:postgresql_database) { "#{application}_production" }
5
+
6
+ namespace :postgresql do
7
+ desc "Install the latest stable release of PostgreSQL."
8
+ task :install, roles: :db, only: {primary: true} do
9
+ run "#{sudo} add-apt-repository ppa:pitti/postgresql --yes"
10
+ run "#{sudo} apt-get -y update"
11
+ run "#{sudo} apt-get -y install postgresql libpq-dev"
12
+ end
13
+ after "deploy:install", "postgresql:install"
14
+
15
+ desc "Create a database for this application."
16
+ task :create_database, roles: :db, only: {primary: true} do
17
+ run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
18
+ run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
19
+ end
20
+ after "deploy:setup", "postgresql:create_database"
21
+
22
+ desc "Generate the database.yml configuration file."
23
+ task :setup, roles: :app do
24
+ run "mkdir -p #{shared_path}/config"
25
+ template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
26
+ end
27
+ after "deploy:setup", "postgresql:setup"
28
+
29
+ desc "Symlink the database.yml file into latest release"
30
+ task :symlink, roles: :app do
31
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
32
+ end
33
+ after "deploy:finalize_update", "postgresql:symlink"
34
+ end
@@ -0,0 +1,29 @@
1
+ set_default :ruby_version, "1.9.3-p194"
2
+ set_default :rbenv_bootstrap, "bootstrap-ubuntu-11-10"
3
+
4
+ namespace :rbenv do
5
+ desc "Install rbenv, Ruby, and the Bundler gem"
6
+ task :install, roles: :app do
7
+ run "#{sudo} apt-get -y install curl git-core"
8
+ run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
9
+ bashrc = <<-BASHRC
10
+ if [ -d $HOME/.rbenv ]; then
11
+ export PATH="$HOME/.rbenv/bin:$PATH"
12
+ eval "$(rbenv init -)"
13
+ fi
14
+ BASHRC
15
+ put bashrc, "/tmp/rbenvrc"
16
+ run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
17
+ run "mv ~/.bashrc.tmp ~/.bashrc"
18
+ run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
19
+ run %q{eval "$(rbenv init -)"}
20
+ # run "rbenv #{rbenv_bootstrap}"
21
+ # Manual bootstrap
22
+ run "#{sudo} apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev"
23
+ run "rbenv install #{ruby_version}"
24
+ run "rbenv global #{ruby_version}"
25
+ run "gem install bundler --no-ri --no-rdoc"
26
+ run "rbenv rehash"
27
+ end
28
+ after "deploy:install", "rbenv:install"
29
+ end
@@ -0,0 +1,18 @@
1
+ namespace :redis do
2
+
3
+ desc "Installs Redis via apt-get"
4
+ task :install, role: :app do
5
+ # run "rake redis:install dtach:install"
6
+ # run "#{sudo} apt-get -y update"
7
+ run "#{sudo} apt-get -y install redis-server"
8
+ end
9
+ after "deploy:install", "redis:install"
10
+
11
+
12
+ desc "Creates Upstart file"
13
+ task :setup, role: :app do
14
+ # create upstart file if necessary
15
+ end
16
+
17
+
18
+ end
@@ -0,0 +1,93 @@
1
+ # System Ruby -- Available via sudo for Foreman
2
+
3
+ set_default :yaml_version, "yaml-0.1.4"
4
+ set_default :ruby_system_version, "1.9.3-p194"
5
+ set_default :ruby_system_url, "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{ruby_system_version}.tar.gz"
6
+ set_default :rubygems_version, "rubygems-1.8.24"
7
+ set_default :rubygems_url, "http://rubyforge.org/frs/download.php/76073/#{rubygems_version}.tgz"
8
+
9
+
10
+ namespace :ruby do
11
+
12
+ desc "Install libyamlfor sudo user (needed for Foreman)"
13
+ task :install_libyaml, roles: :app do
14
+ run "mkdir -p ~/.data"
15
+ run "cd ~/.data"
16
+ run "wget http://pyyaml.org/download/libyaml/#{yaml_version}.tar.gz"
17
+ run "tar xzvf #{yaml_version}.gz"
18
+ run "rm #{yaml_version}.tar.gz"
19
+ run "cd #{yaml_version}"
20
+ run "./configure --prefix=/usr/local"
21
+ run "make"
22
+ run "#{sudo} make install"
23
+ end
24
+ after "deploy:install", "ruby:install_libyaml"
25
+
26
+
27
+ desc "Install Ruby for sudo user (needed for Foreman)"
28
+ task :install_ruby, roles: :app do
29
+ run "mkdir -p ~/.data"
30
+ run "cd ~/.data"
31
+ run "wget #{ruby_system_url}"
32
+ run "tar xzvf ruby-#{ruby_system_version}.tar.gz"
33
+ run "rm ruby-#{ruby_system_version}.tar.gz"
34
+ run "cd ruby-#{ruby_system_version}"
35
+ run "./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib"
36
+ run "make"
37
+ run "#{sudo} make install"
38
+ end
39
+ after "deploy:install", "ruby:install_ruby"
40
+
41
+
42
+ desc "Install Rubygems, and the Bundler gem for sudo user (needed for Foreman)"
43
+ task :install_rubygems, roles: :app do
44
+ # Rubygems
45
+ run "mkdir -p ~/.data"
46
+ run "cd ~/.data"
47
+ run "wget #{rubygems_url}"
48
+ run "tar xzvf #{rubygems_url}"
49
+ run "rm #{rubygems_version}.tgz"
50
+ run "cd #{rubygems_version}"
51
+ run "#{sudo} ruby setup.rb"
52
+ # Bundler
53
+ run "sudo gem install bundler --no-rdoc --no-ri"
54
+ end
55
+ after "deploy:install", "ruby:install_rubygems"
56
+
57
+ end
58
+
59
+
60
+
61
+
62
+
63
+ # # YAML (psych)
64
+ # wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
65
+ # tar xzvf yaml-0.1.4.tar.gz
66
+ # cd yaml-0.1.4
67
+ # ./configure --prefix=/usr/local
68
+ # make
69
+ # sudo make install
70
+ #
71
+ #
72
+ # # Ruby
73
+ # wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
74
+ # tar xzvf ruby-1.9.3-p0.tar.gz
75
+ # cd ruby-1.9.3-p0
76
+ # ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
77
+ # make
78
+ # sudo make install
79
+ #
80
+ #
81
+ # # Ruby Notes
82
+ # ---------------
83
+ # # Thanks for the useful tip. I found that instead of
84
+ # —with-opt-dir=/usr/local/lib
85
+ # # I need to run ./configure with
86
+ # —with-opt-dir=/usr/local
87
+ # # (without the lib). Otherwise, strace shows the loader trying to load the libyaml library from /usr/local/lib/lib.
88
+
89
+
90
+
91
+
92
+
93
+
@@ -0,0 +1,2 @@
1
+ Cmnd_Alias FOREMAN = /usr/local/bin/bundle exec foreman export upstart /etc/init*, /sbin/start <%= application %>, /sbin/stop <%= application %>, /sbin/restart <%= application %>
2
+ admin ALL=(ALL) NOPASSWD: FOREMAN
@@ -0,0 +1,29 @@
1
+ # Gitlab application config file
2
+
3
+ # Email used for notification
4
+ # about new issues, comments
5
+ email:
6
+ from: <%= gitlab_email %>
7
+ host: <%= gitlab_email_host %>
8
+
9
+ # Protocol used for links in email letters
10
+ # Value can be http or https
11
+ protocol: <%= gitlab_email_protocol %> # or https
12
+
13
+ # Git Hosting congiguration
14
+ git_host:
15
+ system: gitolite
16
+ admin_uri: git@localhost:gitolite-admin
17
+ base_path: /home/git/repositories/
18
+ host: localhost
19
+ git_user: git
20
+ # port: 22
21
+
22
+ # Git settings
23
+ # Use default values unless you understand it
24
+ git:
25
+ # Max size of git object like commit, in bytes
26
+ # This value can be increased if you have a very large commits
27
+ git_max_size: 5242880 # 5.megabytes
28
+ # Git timeout to read commit, in seconds
29
+ git_timeout: 10
@@ -0,0 +1,10 @@
1
+ production:
2
+ host: <%= mongodb_host %>
3
+ username: <%= mongodb_user %>
4
+ password: <%= mongodb_password %>
5
+ database: <%= mongodb_database %>
6
+ # slaves:
7
+ # - host: slave1.local
8
+ # port: 27018
9
+ # - host: slave2.local
10
+ # port: 27019
@@ -0,0 +1,7 @@
1
+ production:
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ database: <%= mysql_database %>
5
+ username: <%= mysql_user %>
6
+ password: <%= mysql_password %>
7
+ host: <%= mysql_host %>
@@ -0,0 +1,27 @@
1
+ upstream unicorn {
2
+ server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
3
+ }
4
+
5
+ server {
6
+ listen 80 default deferred;
7
+ # server_name example.com;
8
+ root <%= current_path %>/public;
9
+
10
+ location ^~ /assets/ {
11
+ gzip_static on;
12
+ expires max;
13
+ add_header Cache-Control public;
14
+ }
15
+
16
+ try_files $uri/index.html $uri @unicorn;
17
+ location @unicorn {
18
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
+ proxy_set_header Host $http_host;
20
+ proxy_redirect off;
21
+ proxy_pass http://unicorn;
22
+ }
23
+
24
+ error_page 500 502 503 504 /500.html;
25
+ client_max_body_size 4G;
26
+ keepalive_timeout 10;
27
+ }
@@ -0,0 +1,8 @@
1
+ production:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: <%= postgresql_database %>
5
+ pool: 5
6
+ username: <%= postgresql_user %>
7
+ password: <%= postgresql_password %>
8
+ host: <%= postgresql_host %>
@@ -0,0 +1,8 @@
1
+ working_directory "<%= current_path %>"
2
+ pid "<%= unicorn_pid %>"
3
+ stderr_path "<%= unicorn_log %>"
4
+ stdout_path "<%= unicorn_log %>"
5
+
6
+ listen "/tmp/unicorn.<%= application %>.sock"
7
+ worker_processes <%= unicorn_workers %>
8
+ timeout 30