o2webappizer 0.1.7 → 0.1.8

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -0
  3. data/lib/o2webappizer/app_builder.rb +45 -13
  4. data/lib/o2webappizer/generators/app_generator.rb +1 -0
  5. data/lib/o2webappizer/version.rb +1 -1
  6. data/o2webappizer.gemspec +1 -1
  7. data/templates/.gitignore.tt +1 -0
  8. data/templates/Capfile +19 -0
  9. data/templates/Gemfile.tt +7 -4
  10. data/templates/Vagrantfile.tt +74 -0
  11. data/templates/app/assets/javascripts/application.js.coffee +1 -1
  12. data/templates/app/views/spree/shared/_head.html.erb +2 -2
  13. data/templates/config/Backup/config.rb +124 -0
  14. data/templates/config/Backup/models/db_backup.rb.tt +91 -0
  15. data/templates/config/deploy.rb.tt +92 -0
  16. data/templates/config/deploy/production.rb +66 -0
  17. data/templates/config/deploy/staging.rb +66 -0
  18. data/templates/config/deploy/vagrant.rb +66 -0
  19. data/templates/config/initializers_tt/mail_interceptor.rb +21 -0
  20. data/templates/config/nginx.app.conf.erb +82 -0
  21. data/templates/config/nginx.conf.erb +102 -0
  22. data/templates/config/routes.rb.tt +3 -0
  23. data/templates/config/secrets.yml.tt +10 -0
  24. data/templates/config/sunzi/files/authorized_keys +1 -0
  25. data/templates/config/sunzi/files/sudoers +1 -0
  26. data/templates/config/sunzi/install.sh +14 -0
  27. data/templates/config/sunzi/recipes/libraries.sh +24 -0
  28. data/templates/config/sunzi/recipes/mysql.sh +19 -0
  29. data/templates/config/sunzi/recipes/nodejs.sh +6 -0
  30. data/templates/config/sunzi/recipes/passenger.sh +19 -0
  31. data/templates/config/sunzi/recipes/postgres.sh +14 -0
  32. data/templates/config/sunzi/recipes/ruby.sh +28 -0
  33. data/templates/config/sunzi/recipes/setup.sh +11 -0
  34. data/templates/config/sunzi/recipes/sunzi.sh +99 -0
  35. data/templates/config/sunzi/recipes/sysstat.sh +8 -0
  36. data/templates/config/sunzi/recipes/update.sh +2 -0
  37. data/templates/config/sunzi/recipes/user.sh +23 -0
  38. data/templates/config/sunzi/roles/admin.sh +20 -0
  39. data/templates/config/sunzi/roles/deployer.sh +7 -0
  40. data/templates/config/sunzi/roles/updater.sh +5 -0
  41. data/templates/config/sunzi/sunzi.yml.tt +26 -0
  42. data/templates/db/migrate/20160114191411_add_mail_interceptors_to_settings.rb +12 -0
  43. data/templates/lib/middleware/turbo_dev.rb +40 -0
  44. data/templates/lib/tasks/app.rake +3 -0
  45. data/templates/lib/tasks/db.rake +9 -0
  46. data/templates/schedule.rb +47 -0
  47. data/templates/vendor/assets/javascripts/modernizr.custom.js +3 -0
  48. metadata +37 -10
  49. data/templates/vendor/assets/javascripts/modernizr.js +0 -3
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+
3
+ Model.new(:db_backup, 'Backup for app database') do
4
+ RAILS_ENV = ENV.fetch('RAILS_ENV')
5
+ RAILS_ROOT = ENV.fetch('RAILS_ROOT')
6
+
7
+ ##
8
+ # PostgreSQL [Database]
9
+ #
10
+ database PostgreSQL do |db|
11
+ DB = YAML.load_file("#{RAILS_ROOT}/config/database.yml")[RAILS_ENV]
12
+ # try to get RAILS_ENV variable,
13
+ # if it is not set, use 'production'
14
+ # env = ENV.fetch('RAILS_ENV'){'production'}
15
+ # To dump all databases, set `db.name = :all` (or leave blank)
16
+ db.name = DB['database']
17
+ db.username = DB['username']
18
+ db.password = DB['password']
19
+ db.host = DB['host']
20
+ db.port = 5432
21
+ # db.socket = "/tmp/pg.sock"
22
+ # When dumping all databases, `skip_tables` and `only_tables` are ignored.
23
+ # db.skip_tables = ["skip", "these", "tables"]
24
+ # db.only_tables = ["only", "these", "tables"]
25
+ db.additional_options = ["-xc", "-E=utf8"]
26
+ end
27
+
28
+ ##
29
+ # Local (Copy) [Storage]
30
+ #
31
+ store_with Local do |local|
32
+ local.path = "~/backups/<%= app_name %>/#{RAILS_ENV}"
33
+ local.keep = 40
34
+ end
35
+
36
+ ##
37
+ # Gzip [Compressor]
38
+ #
39
+ compress_with Gzip
40
+
41
+ ##
42
+ # Archive [Archive]
43
+ #
44
+ # Adding a file or directory (including sub-directories):
45
+ # archive.add "/path/to/a/file.rb"
46
+ # archive.add "/path/to/a/directory/"
47
+ #
48
+ # Excluding a file or directory (including sub-directories):
49
+ # archive.exclude "/path/to/an/excluded_file.rb"
50
+ # archive.exclude "/path/to/an/excluded_directory
51
+ #
52
+ # By default, relative paths will be relative to the directory
53
+ # where `backup perform` is executed, and they will be expanded
54
+ # to the root of the filesystem when added to the archive.
55
+ #
56
+ # If a `root` path is set, relative paths will be relative to the
57
+ # given `root` path and will not be expanded when added to the archive.
58
+ #
59
+ # archive.root '/path/to/archive/root'
60
+ #
61
+ # archive :my_archive do |archive|
62
+ # Run the `tar` command using `sudo`
63
+ # archive.use_sudo
64
+ # archive.add "/path/to/a/file.rb"
65
+ # archive.add "/path/to/a/folder/"
66
+ # archive.exclude "/path/to/a/excluded_file.rb"
67
+ # archive.exclude "/path/to/a/excluded_folder"
68
+ # end
69
+
70
+ ##
71
+ # Mail [Notifier]
72
+ #
73
+ # The default delivery method for Mail Notifiers is 'SMTP'.
74
+ # See the documentation for other delivery options.
75
+ #
76
+ # notify_by Mail do |mail|
77
+ # mail.on_success = true
78
+ # mail.on_warning = true
79
+ # mail.on_failure = true
80
+ #
81
+ # mail.from = "xxx@o2web.ca"
82
+ # mail.to = "xxx@o2web.ca"
83
+ # mail.address = "localhost"
84
+ # mail.port = 1025
85
+ # mail.domain = "xxx.xxx.xxx.xxx"
86
+ # mail.user_name = "xxx"
87
+ # mail.password = "xxx"
88
+ # mail.authentication = "plain"
89
+ # mail.encryption = :starttls
90
+ # end
91
+ end
@@ -0,0 +1,92 @@
1
+ # config valid only for current version of Capistrano
2
+ lock '3.4.0'
3
+
4
+ set :repo_url, 'git@git.todo.todo:todo/<%= app_name %>.git' # TODO: NEW_PROJECT
5
+
6
+ set :application, '<%= app_name %>'
7
+ set :ruby_version, IO.read("#{File.dirname(__FILE__)}/../.ruby-version").strip
8
+ set :admin_name, 'ubuntu'
9
+ set :deployer_name, 'deployer'
10
+ set :deploy_to, "/home/#{fetch(:deployer_name)}/#{fetch(:application)}/#{fetch(:stage)}"
11
+
12
+ set :rbenv_type, :user
13
+ set :rbenv_ruby, fetch(:ruby_version)
14
+ set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
15
+ set :rbenv_map_bins, %w{rake gem bundle ruby rails}
16
+
17
+ set :passenger_restart_with_sudo, false
18
+ set :passenger_restart_command, 'rbenv sudo passenger-config restart-app'
19
+
20
+ # default to %W[system]
21
+ <% if options.solidus? -%>
22
+ set :files_public_dirs, fetch(:files_public_dirs, []).push(*%W[
23
+ spree
24
+ ])
25
+ <% else -%>
26
+ # set :files_public_dirs, fetch(:files_public_dirs, []).push(*%W[
27
+ # spree
28
+ # ])
29
+ <% end -%>
30
+ # default to []
31
+ # set :files_private_dirs, fetch(:files_private_dirs, []).push(*%W[
32
+ # ])
33
+
34
+ # set :nginx_workers, 1
35
+ # default to %W[assets system]
36
+ <% if options.solidus? -%>
37
+ set :nginx_assets_dirs, fetch(:nginx_assets_dirs, []).push(*%W[
38
+ spree
39
+ ])
40
+ <% else -%>
41
+ # set :nginx_assets_dirs, fetch(:nginx_assets_dirs, []).push(*%W[
42
+ # spree
43
+ # ])
44
+ <% end -%>
45
+ # set :nginx_max_body_size, '10m'
46
+
47
+ set :pty, true
48
+ set :port, 22
49
+
50
+ set :linked_dirs, fetch(:linked_dirs, []).push(*%W[
51
+ log
52
+ tmp/pids
53
+ tmp/cache
54
+ tmp/sockets
55
+ private
56
+ public/assets
57
+ <% if options.solidus? -%>
58
+ public/spree
59
+ <% end -%>
60
+ public/system
61
+ vendor/bundle
62
+ ])
63
+
64
+ # Default value for :linked_files is []
65
+ # set :linked_files, fetch(:linked_files, []).push(*%W[
66
+ # config/database.yml
67
+ # config/secrets.yml
68
+ # ])
69
+
70
+ # Default value for keep_releases is 5
71
+ # set :keep_releases, 5
72
+
73
+ set :whenever_identifier, ->{ "#{fetch(:application)}-#{fetch(:stage)}" }
74
+
75
+ namespace :deploy do
76
+ after :restart, :clear_cache do
77
+ on roles(:web), in: :groups, limit: 3, wait: 10 do
78
+ # Here we can do anything such as:
79
+ # within release_path do
80
+ # execute :rake, 'cache:clear'
81
+ # end
82
+ end
83
+ end
84
+
85
+ after :deploy, :touch_cron_log do
86
+ on roles :app do
87
+ within shared_path do
88
+ execute :touch, 'log/cron.log'
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,66 @@
1
+ set :stage, :production
2
+ set :branch, 'master'
3
+
4
+ # server-based syntax
5
+ # ======================
6
+ # Defines a single server with a list of roles and multiple properties.
7
+ # You can define all roles on a single server, or split them:
8
+
9
+ # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
10
+ # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
11
+ # server 'db.example.com', user: 'deploy', roles: %w{db}
12
+ set :server, 'todo.todo' # TODO: NEW_PROJECT
13
+ server fetch(:server), user: fetch(:deployer_name), roles: %w[app web db]
14
+
15
+
16
+
17
+ # role-based syntax
18
+ # ==================
19
+
20
+ # Defines a role with one or multiple servers. The primary server in each
21
+ # group is considered to be the first unless any hosts have the primary
22
+ # property set. Specify the username and a domain or IP for the server.
23
+ # Don't use `:all`, it's a meta role.
24
+
25
+ # role :app, %w{deploy@example.com}, my_property: :my_value
26
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
27
+ # role :db, %w{deploy@example.com}
28
+
29
+
30
+
31
+ # Configuration
32
+ # =============
33
+ # You can set any configuration variable like in config/deploy.rb
34
+ # These variables are then only loaded and set in this stage.
35
+ # For available Capistrano configuration variables see the documentation page.
36
+ # http://capistranorb.com/documentation/getting-started/configuration/
37
+ # Feel free to add new variables to customise your setup.
38
+
39
+
40
+
41
+ # Custom SSH Options
42
+ # ==================
43
+ # You may pass any option but keep in mind that net/ssh understands a
44
+ # limited set of options, consult the Net::SSH documentation.
45
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
46
+ #
47
+ # Global options
48
+ # --------------
49
+ # set :ssh_options, {
50
+ # keys: %w(/home/rlisowski/.ssh/id_rsa),
51
+ # forward_agent: false,
52
+ # auth_methods: %w(password)
53
+ # }
54
+ #
55
+ # The server-based syntax can be used to override options:
56
+ # ------------------------------------
57
+ # server 'example.com',
58
+ # user: 'user_name',
59
+ # roles: %w{web app},
60
+ # ssh_options: {
61
+ # user: 'user_name', # overrides user setting above
62
+ # keys: %w(/home/user_name/.ssh/id_rsa),
63
+ # forward_agent: false,
64
+ # auth_methods: %w(publickey password)
65
+ # # password: 'please use keys'
66
+ # }
@@ -0,0 +1,66 @@
1
+ set :stage, :staging
2
+ set :branch, 'staging'
3
+
4
+ # server-based syntax
5
+ # ======================
6
+ # Defines a single server with a list of roles and multiple properties.
7
+ # You can define all roles on a single server, or split them:
8
+
9
+ # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
10
+ # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
11
+ # server 'db.example.com', user: 'deploy', roles: %w{db}
12
+ set :server, 'todo.todo' # TODO: NEW_PROJECT
13
+ server fetch(:server), user: fetch(:deployer_name), roles: %w[app web db]
14
+
15
+
16
+
17
+ # role-based syntax
18
+ # ==================
19
+
20
+ # Defines a role with one or multiple servers. The primary server in each
21
+ # group is considered to be the first unless any hosts have the primary
22
+ # property set. Specify the username and a domain or IP for the server.
23
+ # Don't use `:all`, it's a meta role.
24
+
25
+ # role :app, %w{deploy@example.com}, my_property: :my_value
26
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
27
+ # role :db, %w{deploy@example.com}
28
+
29
+
30
+
31
+ # Configuration
32
+ # =============
33
+ # You can set any configuration variable like in config/deploy.rb
34
+ # These variables are then only loaded and set in this stage.
35
+ # For available Capistrano configuration variables see the documentation page.
36
+ # http://capistranorb.com/documentation/getting-started/configuration/
37
+ # Feel free to add new variables to customise your setup.
38
+
39
+
40
+
41
+ # Custom SSH Options
42
+ # ==================
43
+ # You may pass any option but keep in mind that net/ssh understands a
44
+ # limited set of options, consult the Net::SSH documentation.
45
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
46
+ #
47
+ # Global options
48
+ # --------------
49
+ # set :ssh_options, {
50
+ # keys: %w(/home/rlisowski/.ssh/id_rsa),
51
+ # forward_agent: false,
52
+ # auth_methods: %w(password)
53
+ # }
54
+ #
55
+ # The server-based syntax can be used to override options:
56
+ # ------------------------------------
57
+ # server 'example.com',
58
+ # user: 'user_name',
59
+ # roles: %w{web app},
60
+ # ssh_options: {
61
+ # user: 'user_name', # overrides user setting above
62
+ # keys: %w(/home/user_name/.ssh/id_rsa),
63
+ # forward_agent: false,
64
+ # auth_methods: %w(publickey password)
65
+ # # password: 'please use keys'
66
+ # }
@@ -0,0 +1,66 @@
1
+ set :stage, :vagrant
2
+ set :branch, 'vagrant'
3
+
4
+ set :admin_name, 'vagrant'
5
+
6
+ # server-based syntax
7
+ # ======================
8
+ # Defines a single server with a list of roles and multiple properties.
9
+ # You can define all roles on a single server, or split them:
10
+
11
+ # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
12
+ # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
13
+ # server 'db.example.com', user: 'deploy', roles: %w{db}
14
+ set :server, "#{fetch(:application).dasherize}.dev"
15
+ server fetch(:server), user: fetch(:deployer_name), roles: %w[app web db]
16
+
17
+ # role-based syntax
18
+ # ==================
19
+
20
+ # Defines a role with one or multiple servers. The primary server in each
21
+ # group is considered to be the first unless any hosts have the primary
22
+ # property set. Specify the username and a domain or IP for the server.
23
+ # Don't use `:all`, it's a meta role.
24
+
25
+ # role :app, %w{deploy@example.com}, my_property: :my_value
26
+ # role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
27
+ # role :db, %w{deploy@example.com}
28
+
29
+
30
+
31
+ # Configuration
32
+ # =============
33
+ # You can set any configuration variable like in config/deploy.rb
34
+ # These variables are then only loaded and set in this stage.
35
+ # For available Capistrano configuration variables see the documentation page.
36
+ # http://capistranorb.com/documentation/getting-started/configuration/
37
+ # Feel free to add new variables to customise your setup.
38
+
39
+
40
+
41
+ # Custom SSH Options
42
+ # ==================
43
+ # You may pass any option but keep in mind that net/ssh understands a
44
+ # limited set of options, consult the Net::SSH documentation.
45
+ # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
46
+ #
47
+ # Global options
48
+ # --------------
49
+ # set :ssh_options, {
50
+ # keys: %w(/home/rlisowski/.ssh/id_rsa),
51
+ # forward_agent: false,
52
+ # auth_methods: %w(password)
53
+ # }
54
+ #
55
+ # The server-based syntax can be used to override options:
56
+ # ------------------------------------
57
+ # server 'example.com',
58
+ # user: 'user_name',
59
+ # roles: %w{web app},
60
+ # ssh_options: {
61
+ # user: 'user_name', # overrides user setting above
62
+ # keys: %w(/home/user_name/.ssh/id_rsa),
63
+ # forward_agent: false,
64
+ # auth_methods: %w(publickey password)
65
+ # # password: 'please use keys'
66
+ # }
@@ -0,0 +1,21 @@
1
+ if (Rails.env.staging? || Rails.env.vagrant?)
2
+ options = {
3
+ forward_emails_to: Class.new do
4
+ def self.to_ary
5
+ Class.new do
6
+ def self.flatten
7
+ Class.new do
8
+ def self.uniq
9
+ Setting[:mail_interceptors].split(/[\s,;]/).reject(&:blank?)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ }
17
+
18
+ interceptor = MailInterceptor::Interceptor.new(options)
19
+
20
+ ActionMailer::Base.register_interceptor(interceptor)
21
+ end
@@ -0,0 +1,82 @@
1
+ ##
2
+ # You should look at the following URL's in order to grasp a solid understanding
3
+ # of Nginx configuration files in order to fully unleash the power of Nginx.
4
+ # http://wiki.nginx.org/Pitfalls
5
+ # http://wiki.nginx.org/QuickStart
6
+ # http://wiki.nginx.org/Configuration
7
+ #
8
+ # Generally, you will want to move this file somewhere, and start with a clean
9
+ # file but keep this around for reference. Or just disable in sites-enabled.
10
+ #
11
+ # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
12
+ ##
13
+
14
+ # Default server configuration
15
+ #
16
+ server {
17
+ listen 80 default_server;
18
+ listen [::]:80 default_server ipv6only=on;
19
+
20
+ # SSL configuration
21
+ #
22
+ # listen 443 ssl default_server;
23
+ # listen [::]:443 ssl default_server;
24
+ #
25
+ # Self signed certs generated by the ssl-cert package
26
+ # Don't use them in a production server!
27
+ #
28
+ # include snippets/snakeoil.conf;
29
+
30
+ server_name <%= fetch(:server) %>;
31
+ passenger_enabled on;
32
+ rails_env <%= fetch(:stage) %>;
33
+ root <%= fetch(:deploy_to) %>/current/public;
34
+
35
+ <% if fetch(:stage) == :production %>
36
+ # listen 443 ssl;
37
+ # ssl_certificate /etc/ssl/certs/<%= fetch(:server) %>.chained.crt;
38
+ # ssl_certificate_key /etc/ssl/private/<%= fetch(:server) %>.key;
39
+ <% end %>
40
+
41
+ client_max_body_size <%= fetch(:nginx_max_body_size) %>;
42
+
43
+ error_page 500 502 503 504 /50x.html;
44
+ location = /50x.html {
45
+ root html;
46
+ }
47
+
48
+ # TODO: it doesn't work
49
+ # location ~ ^/(<%= fetch(:nginx_assets_dirs).join('|') %>)/ {
50
+ # root <%= fetch(:deploy_to) %>/current/public;
51
+ # gzip_static on;
52
+ # expires max;
53
+ # add_header Cache-Control public;
54
+ # break;
55
+ # }
56
+ }
57
+
58
+ server {
59
+ listen 80;
60
+
61
+ server_name www.<%= fetch(:server) %>;
62
+ return 301 $scheme://<%= fetch(:server) %>$request_uri;
63
+ }
64
+
65
+ # Virtual Host configuration for example.com
66
+ #
67
+ # You can move that to a different file under sites-available/ and symlink that
68
+ # to sites-enabled/ to enable it.
69
+ #
70
+ #server {
71
+ # listen 80;
72
+ # listen [::]:80;
73
+ #
74
+ # server_name example.com;
75
+ #
76
+ # root /var/www/example.com;
77
+ # index index.html;
78
+ #
79
+ # location / {
80
+ # try_files $uri $uri/ =404;
81
+ # }
82
+ #}