orats 0.9.7 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.rubocop.yml +24 -0
  4. data/.travis.yml +9 -0
  5. data/README.md +103 -194
  6. data/bin/orats +2 -5
  7. data/lib/orats/cli.rb +6 -67
  8. data/lib/orats/cli_help/destroy +11 -0
  9. data/lib/orats/cli_help/new +2 -26
  10. data/lib/orats/commands/new.rb +127 -0
  11. data/lib/orats/common.rb +0 -29
  12. data/lib/orats/templates/base/.dockerignore +5 -0
  13. data/lib/orats/templates/base/.gitignore +22 -0
  14. data/lib/orats/templates/base/.rubocop.yml +29 -0
  15. data/lib/orats/templates/base/Dockerfile +102 -0
  16. data/lib/orats/templates/base/Gemfile +69 -0
  17. data/lib/orats/templates/base/Gemfile.lock +205 -0
  18. data/lib/orats/templates/base/README.md +24 -0
  19. data/lib/orats/templates/base/Rakefile +7 -0
  20. data/lib/orats/templates/base/app/assets/config/manifest.js +3 -0
  21. data/lib/orats/templates/base/app/assets/images/.keep +0 -0
  22. data/lib/orats/templates/base/app/assets/javascripts/application.js +33 -0
  23. data/lib/orats/templates/base/app/assets/javascripts/cable.js +14 -0
  24. data/lib/orats/templates/base/app/assets/javascripts/channels/.keep +0 -0
  25. data/lib/orats/templates/base/app/assets/stylesheets/application.scss +89 -0
  26. data/lib/orats/templates/base/app/channels/application_cable/channel.rb +4 -0
  27. data/lib/orats/templates/base/app/channels/application_cable/connection.rb +4 -0
  28. data/lib/orats/templates/base/app/controllers/application_controller.rb +3 -0
  29. data/lib/orats/templates/base/app/controllers/concerns/.keep +0 -0
  30. data/lib/orats/templates/base/app/controllers/pages_controller.rb +4 -0
  31. data/lib/orats/templates/base/app/helpers/application_helper.rb +31 -0
  32. data/lib/orats/templates/base/app/helpers/pages_helper.rb +2 -0
  33. data/lib/orats/templates/base/app/jobs/application_job.rb +2 -0
  34. data/lib/orats/templates/base/app/mailers/application_mailer.rb +4 -0
  35. data/lib/orats/templates/base/app/models/application_record.rb +3 -0
  36. data/lib/orats/templates/base/app/models/concerns/.keep +0 -0
  37. data/lib/orats/templates/{includes/new/rails → base}/app/views/layouts/_flash.html.erb +1 -1
  38. data/lib/orats/templates/base/app/views/layouts/_footer.html.erb +3 -0
  39. data/lib/orats/templates/{includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb → base/app/views/layouts/_google_analytics.html.erb} +5 -9
  40. data/lib/orats/templates/{includes/new/rails → base}/app/views/layouts/_navigation.html.erb +5 -4
  41. data/lib/orats/templates/base/app/views/layouts/application.html.erb +48 -0
  42. data/lib/orats/templates/base/app/views/layouts/mailer.html.erb +13 -0
  43. data/lib/orats/templates/base/app/views/layouts/mailer.text.erb +1 -0
  44. data/lib/orats/templates/base/app/views/pages/home.html.erb +46 -0
  45. data/lib/orats/templates/base/bin/bundle +3 -0
  46. data/lib/orats/templates/base/bin/rails +4 -0
  47. data/lib/orats/templates/base/bin/rake +4 -0
  48. data/lib/orats/templates/base/bin/setup +34 -0
  49. data/lib/orats/templates/base/bin/update +29 -0
  50. data/lib/orats/templates/base/cable/config.ru +4 -0
  51. data/lib/orats/templates/base/config.ru +5 -0
  52. data/lib/orats/templates/base/config/application.rb +71 -0
  53. data/lib/orats/templates/base/config/boot.rb +3 -0
  54. data/lib/orats/templates/base/config/cable.yml +14 -0
  55. data/lib/orats/templates/base/config/database.yml +13 -0
  56. data/lib/orats/templates/base/config/environment.rb +5 -0
  57. data/lib/orats/templates/base/config/environments/development.rb +49 -0
  58. data/lib/orats/templates/base/config/environments/production.rb +56 -0
  59. data/lib/orats/templates/base/config/environments/staging.rb +6 -0
  60. data/lib/orats/templates/base/config/environments/test.rb +40 -0
  61. data/lib/orats/templates/base/config/initializers/application_controller_renderer.rb +6 -0
  62. data/lib/orats/templates/base/config/initializers/assets.rb +12 -0
  63. data/lib/orats/templates/base/config/initializers/backtrace_silencers.rb +9 -0
  64. data/lib/orats/templates/base/config/initializers/cookies_serializer.rb +5 -0
  65. data/lib/orats/templates/base/config/initializers/filter_parameter_logging.rb +4 -0
  66. data/lib/orats/templates/base/config/initializers/inflections.rb +16 -0
  67. data/lib/orats/templates/base/config/initializers/mime_types.rb +4 -0
  68. data/lib/orats/templates/base/config/initializers/new_framework_defaults.rb +27 -0
  69. data/lib/orats/templates/base/config/initializers/session_store.rb +4 -0
  70. data/lib/orats/templates/{includes/new/rails → base}/config/initializers/sidekiq.rb +1 -4
  71. data/lib/orats/templates/base/config/initializers/timeout.rb +1 -0
  72. data/lib/orats/templates/base/config/initializers/wrap_parameters.rb +15 -0
  73. data/lib/orats/templates/base/config/locales/en.yml +23 -0
  74. data/lib/orats/templates/base/config/puma.rb +60 -0
  75. data/lib/orats/templates/base/config/routes.rb +3 -0
  76. data/lib/orats/templates/{includes/new/rails → base}/config/secrets.yml +3 -2
  77. data/lib/orats/templates/base/config/sidekiq.yml.erb +5 -0
  78. data/lib/orats/templates/base/config/spring.rb +6 -0
  79. data/lib/orats/templates/base/db/seeds.rb +9 -0
  80. data/lib/orats/templates/base/docker-compose.yml +59 -0
  81. data/lib/orats/templates/base/lib/assets/.keep +0 -0
  82. data/lib/orats/templates/base/lib/tasks/.keep +0 -0
  83. data/lib/orats/templates/base/log/.keep +0 -0
  84. data/lib/orats/templates/base/public/404.html +67 -0
  85. data/lib/orats/templates/base/public/422.html +67 -0
  86. data/lib/orats/templates/base/public/500.html +66 -0
  87. data/lib/orats/templates/base/public/apple-touch-icon-precomposed.png +0 -0
  88. data/lib/orats/templates/base/public/apple-touch-icon.png +0 -0
  89. data/lib/orats/templates/base/public/favicon.ico +0 -0
  90. data/lib/orats/templates/base/public/robots.txt +5 -0
  91. data/lib/orats/templates/base/test/controllers/.keep +0 -0
  92. data/lib/orats/templates/base/test/controllers/pages_controller_test.rb +9 -0
  93. data/lib/orats/templates/base/test/fixtures/.keep +0 -0
  94. data/lib/orats/templates/base/test/fixtures/files/.keep +0 -0
  95. data/lib/orats/templates/base/test/helpers/.keep +0 -0
  96. data/lib/orats/templates/base/test/integration/.keep +0 -0
  97. data/lib/orats/templates/base/test/mailers/.keep +0 -0
  98. data/lib/orats/templates/base/test/models/.keep +0 -0
  99. data/lib/orats/templates/base/test/test_helper.rb +11 -0
  100. data/lib/orats/templates/base/tmp/.keep +0 -0
  101. data/lib/orats/templates/base/vendor/assets/javascripts/.keep +0 -0
  102. data/lib/orats/templates/base/vendor/assets/stylesheets/.keep +0 -0
  103. data/lib/orats/ui.rb +5 -5
  104. data/lib/orats/util.rb +14 -0
  105. data/lib/orats/version.rb +1 -1
  106. data/orats.gemspec +3 -2
  107. data/test/integration/cli_test.rb +43 -65
  108. data/test/test_helper.rb +9 -58
  109. metadata +114 -66
  110. data/lib/orats/argv_adjust.rb +0 -61
  111. data/lib/orats/cli_help/nuke +0 -19
  112. data/lib/orats/commands/new/exec.rb +0 -59
  113. data/lib/orats/commands/new/rails.rb +0 -215
  114. data/lib/orats/commands/new/server.rb +0 -67
  115. data/lib/orats/commands/nuke.rb +0 -108
  116. data/lib/orats/postgres.rb +0 -92
  117. data/lib/orats/process.rb +0 -35
  118. data/lib/orats/redis.rb +0 -25
  119. data/lib/orats/shell.rb +0 -12
  120. data/lib/orats/templates/auth.rb +0 -394
  121. data/lib/orats/templates/base.rb +0 -546
  122. data/lib/orats/templates/includes/common/.gitignore +0 -6
  123. data/lib/orats/templates/includes/common/LICENSE +0 -22
  124. data/lib/orats/templates/includes/new/rails/.env +0 -59
  125. data/lib/orats/templates/includes/new/rails/Gemfile +0 -48
  126. data/lib/orats/templates/includes/new/rails/Procfile +0 -3
  127. data/lib/orats/templates/includes/new/rails/README.md +0 -3
  128. data/lib/orats/templates/includes/new/rails/app/assets/favicon/favicon_base.png +0 -0
  129. data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +0 -53
  130. data/lib/orats/templates/includes/new/rails/app/models/account.rb +0 -40
  131. data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +0 -26
  132. data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
  133. data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +0 -10
  134. data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +0 -8
  135. data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +0 -28
  136. data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +0 -26
  137. data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +0 -51
  138. data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +0 -31
  139. data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +0 -39
  140. data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +0 -38
  141. data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +0 -26
  142. data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +0 -19
  143. data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +0 -12
  144. data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +0 -2
  145. data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +0 -15
  146. data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +0 -3
  147. data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +0 -47
  148. data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +0 -58
  149. data/lib/orats/templates/includes/new/rails/config/database.yml +0 -6
  150. data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +0 -5
  151. data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +0 -1
  152. data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +0 -4
  153. data/lib/orats/templates/includes/new/rails/config/puma.rb +0 -39
  154. data/lib/orats/templates/includes/new/rails/config/schedule.rb +0 -3
  155. data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +0 -7
  156. data/lib/orats/templates/includes/new/rails/config/sitemap.rb +0 -20
  157. data/lib/orats/templates/includes/new/rails/config/unicorn.rb +0 -84
  158. data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +0 -48
  159. data/lib/orats/templates/includes/new/rails/public/404.html +0 -13
  160. data/lib/orats/templates/includes/new/rails/public/422.html +0 -13
  161. data/lib/orats/templates/includes/new/rails/public/500.html +0 -13
  162. data/lib/orats/templates/includes/new/rails/public/502.html +0 -13
  163. data/lib/orats/templates/includes/new/rails/public/deploy.html +0 -14
  164. data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +0 -27
  165. data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +0 -46
@@ -0,0 +1,11 @@
1
+ Destroy the target path and optionally all Docker data associated to it.
2
+
3
+ Options:
4
+
5
+ `--rm-docker` to delete Docker specific data for this project [false]
6
+
7
+ In order to use `--rm-docker` you must be running orats from a terminal
8
+ capable of connecting to Docker.
9
+
10
+ When set, it will delete all Docker images, containers, volumes and networks
11
+ associated to this project.
@@ -1,29 +1,5 @@
1
- Create a new shiny rails app with quite a few best practices and opinions.
2
-
3
- Development server credentials:
4
-
5
- `--pg-location` to supply a custom postgres location [localhost]
6
-
7
- `--pg-username` to supply a custom postgres username [postgres]
8
-
9
- `--pg-password` to supply your postgres password to run migrations []
10
-
11
- `--redis-location` to supply a custom redis location [localhost]
12
-
13
- `--redis-password` to supply your redis password []
1
+ Create a shiny Dockerized Rails application
14
2
 
15
3
  Options:
16
4
 
17
- `--rc` to supply an .oratsrc file path to automatically populate credentials []
18
-
19
- Template features:
20
-
21
- `--template` to mix in an official orats template by supplying its name []
22
-
23
- `--custom` to add your own template at the very end, a url or file is ok []
24
-
25
- Project features:
26
-
27
- `--backend` to switch to a different server backend, ie. puma
28
-
29
- `--skip-server-start` to skip automatically running puma and sidekiq [false]
5
+ `--template` to supply the template name to use [base]
@@ -0,0 +1,127 @@
1
+ require 'pathname'
2
+
3
+ require 'orats/common'
4
+ require 'orats/util'
5
+ require 'orats/version'
6
+
7
+ module Orats
8
+ module Commands
9
+ class New < Common
10
+ AVAILABLE_TEMPLATES = {
11
+ base: 'dockerized production ready application'
12
+ }.freeze
13
+
14
+ def initialize(target_path = '', options = {})
15
+ super
16
+ end
17
+
18
+ def init
19
+ check_exit_conditions
20
+ create_template
21
+ personalize_template
22
+ what_to_do_next
23
+ end
24
+
25
+ def available_templates
26
+ puts
27
+ log 'templates',
28
+ 'Add `-t TEMPLATE` to the new command to use a template',
29
+ :magenta
30
+ puts
31
+
32
+ AVAILABLE_TEMPLATES.each_pair do |key, value|
33
+ log key, value, :cyan
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def check_exit_conditions
40
+ exit_if_path_exists
41
+ exit_if_invalid_template
42
+ end
43
+
44
+ def exit_if_invalid_template
45
+ template = @options[:template] || ''
46
+ task 'Check if template exists'
47
+
48
+ return if template.empty? || template_exist?
49
+
50
+ error 'Cannot find template',
51
+ "'#{template}' is not a valid template name"
52
+
53
+ available_templates
54
+ exit 1
55
+ end
56
+
57
+ def template_exist?
58
+ AVAILABLE_TEMPLATES.include?(@options[:template].to_sym)
59
+ end
60
+
61
+ def create_template
62
+ task "Create '#{@options[:template]}' project"
63
+ log 'path', @target_path, :cyan
64
+
65
+ source = "#{base_path}/templates/#{@options[:template]}"
66
+
67
+ FileUtils.copy_entry source, @target_path
68
+ end
69
+
70
+ def personalize_template
71
+ template_replacements = set_template_replacements
72
+
73
+ Dir.glob("#{@target_path}/**/*", File::FNM_DOTMATCH) do |file|
74
+ next if file == '.' || file == '..' || File.directory?(file)
75
+
76
+ text = File.read(file)
77
+
78
+ template_replacements.each do |key, value|
79
+ text.gsub!(key.to_s, value)
80
+ end
81
+
82
+ File.open(file, 'w') { |f| f.puts text }
83
+ end
84
+ end
85
+
86
+ def set_template_replacements
87
+ project_name = Pathname.new(@target_path).basename.to_s
88
+
89
+ {
90
+ 'orats_base' => Util.underscore(project_name),
91
+ 'OratsBase' => Util.classify(project_name),
92
+ 'VERSION' => VERSION
93
+ }
94
+ end
95
+
96
+ def what_to_do_next
97
+ prepare_and_run_everything
98
+ init_the_database
99
+ visit_the_page
100
+ end
101
+
102
+ def prepare_and_run_everything
103
+ task 'Prepare and run everything'
104
+ log 'open', 'carefully read and edit the `.env` file', :cyan
105
+ log 'move', "cd #{@target_path}", :cyan
106
+ log 'run', 'docker-compose up --build', :cyan
107
+ end
108
+
109
+ def init_the_database
110
+ run = 'docker-compose exec --user "$(id -u):$(id -g)" website rails'
111
+
112
+ task 'Initialize the database in a 2nd Docker-enabled terminal'
113
+ log 'note', 'OSX / Windows users can skip the --user flag', :yellow
114
+ log 'run', "#{run} db:reset", :cyan
115
+ log 'run', "#{run} db:migrate", :cyan
116
+ end
117
+
118
+ def visit_the_page
119
+ task 'Visit the page in your browser'
120
+ log 'visit', 'Running Docker natively? http://localhost:3000', :cyan
121
+ log 'visit',
122
+ 'Running Docker with the Toolbox? http://192.168.99.100:3000',
123
+ :cyan
124
+ end
125
+ end
126
+ end
127
+ end
data/lib/orats/common.rb CHANGED
@@ -1,7 +1,3 @@
1
- require 'orats/postgres'
2
- require 'orats/process'
3
- require 'orats/redis'
4
- require 'orats/shell'
5
1
  require 'orats/ui'
6
2
 
7
3
  module Orats
@@ -10,11 +6,7 @@ module Orats
10
6
  include Thor::Base
11
7
  include Thor::Shell
12
8
  include Thor::Actions
13
- include Shell
14
9
  include UI
15
- include Process
16
- include Postgres
17
- include Redis
18
10
 
19
11
  def initialize(target_path = '', options = {})
20
12
  @target_path = target_path
@@ -28,13 +20,6 @@ module Orats
28
20
  File.join(File.expand_path(File.dirname(__FILE__)))
29
21
  end
30
22
 
31
- def url_to_string(url)
32
- open(url).read
33
- rescue *[OpenURI::HTTPError, SocketError] => ex
34
- error 'Unable to access URL', ex
35
- exit 1
36
- end
37
-
38
23
  def file_to_string(path)
39
24
  if File.exist?(path) && File.file?(path)
40
25
  IO.read path
@@ -58,19 +43,5 @@ module Orats
58
43
  error 'Path already exists', extended_path
59
44
  exit 1
60
45
  end
61
-
62
- def exit_if_invalid_system
63
- exit_if_process :not_found, 'rails', 'git', 'psql', 'redis-cli'
64
- exit_if_process :not_running, 'postgres', 'redis'
65
-
66
- exit_if_postgres_unreachable
67
- exit_if_redis_unreachable
68
- end
69
-
70
- def run_rake(command)
71
- task 'Run rake command'
72
-
73
- run_from @target_path, "bundle exec rake #{command}"
74
- end
75
46
  end
76
47
  end
@@ -0,0 +1,5 @@
1
+ .git
2
+ .dockerignore
3
+ .byebug_history
4
+ /log/*
5
+ /tmp/*
@@ -0,0 +1,22 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring
2
+ # files.
3
+ #
4
+ # If you find yourself ignoring temporary files generated by your text editor
5
+ # or operating system, you probably want to add a global ignore instead:
6
+ # git config --global core.excludesfile '~/.gitignore_global'
7
+
8
+ # Ignore bundler config.
9
+ /.bundle
10
+
11
+ # Ignore all logfiles and tempfiles.
12
+ /log/*
13
+ /tmp/*
14
+ !/log/.keep
15
+ !/tmp/.keep
16
+
17
+ # Ignore Byebug command history file.
18
+ .byebug_history
19
+
20
+ /vendor/bundle
21
+ /public/assets/*
22
+ .env
@@ -0,0 +1,29 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.0
3
+
4
+ Exclude:
5
+ - 'db/**/*'
6
+ - 'log/**/*'
7
+ - 'tmp/**/*'
8
+
9
+ Documentation:
10
+ # Skips checking to make sure top level modules / classes have a comment.
11
+ Enabled: false
12
+
13
+ Style/ClassAndModuleChildren:
14
+ # Skips checking the style of children definitions at classes and modules.
15
+ #
16
+ # Basically there are two different styles:
17
+ #
18
+ # `nested` - have each child on a separate line
19
+ # class Foo
20
+ # class Bar
21
+ # end
22
+ # end
23
+ #
24
+ # `compact` - combine definitions as much as possible
25
+ # class Foo::Bar
26
+ # end
27
+ #
28
+ # With it disabled, either or is valid.
29
+ Enabled: false
@@ -0,0 +1,102 @@
1
+ FROM ruby:2.3-slim
2
+ # Docker images can start off with nothing, but it's extremely
3
+ # common to pull in from a base image. In our case we're pulling
4
+ # in from the slim version of the official Ruby 2.3 image.
5
+ #
6
+ # Details about this image can be found here:
7
+ # https://hub.docker.com/_/ruby/
8
+ #
9
+ # Slim is pulling in from the official Debian Jessie image.
10
+ #
11
+ # You can tell it's using Debian Jessie by clicking the
12
+ # Dockerfile link next to the 2.3-slim bullet on the Docker hub.
13
+ #
14
+ # The Docker hub is the standard place for you to find official
15
+ # Docker images. Think of it like GitHub but for Docker images.
16
+
17
+ MAINTAINER Nick Janetakis <nick.janetakis@gmail.com>
18
+ # It is good practice to set a maintainer for all of your Docker
19
+ # images. It's not necessary but it's a good habit.
20
+
21
+ RUN apt-get update && apt-get install -qq -y --no-install-recommends \
22
+ build-essential nodejs libpq-dev
23
+ # Ensure that our apt package list is updated and install a few
24
+ # packages to ensure that we can compile assets (nodejs) and
25
+ # communicate with PostgreSQL (libpq-dev).
26
+
27
+ ENV INSTALL_PATH /my_dockerized_app
28
+ # The name of the application is my_dockerized_app and while there
29
+ # is no standard on where your project should live inside of the Docker
30
+ # image, I like to put it in the root of the image and name it
31
+ # after the project.
32
+ #
33
+ # We don't even need to set the INSTALL_PATH variable, but I like
34
+ # to do it because we're going to be referencing it in a few spots
35
+ # later on in the Dockerfile.
36
+ #
37
+ # The variable could be named anything you want.
38
+
39
+ RUN mkdir -p $INSTALL_PATH
40
+ # This just creates the folder in the Docker image at the
41
+ # install path we defined above.
42
+
43
+ WORKDIR $INSTALL_PATH
44
+ # We're going to be executing a number of commands below, and
45
+ # having to CD into the /my_dockerized_app folder every time would be
46
+ # lame, so instead we can set the WORKDIR to be /my_dockerized_app.
47
+ #
48
+ # By doing this, Docker will be smart enough to execute all
49
+ # future commands from within this directory.
50
+
51
+ COPY Gemfile Gemfile.lock ./
52
+ # This is going to copy in the Gemfile and Gemfile.lock from our
53
+ # work station at a path relative to the Dockerfile to the
54
+ # my_dockerized_app/ path inside of the Docker image.
55
+ #
56
+ # It copies it to /my_dockerized_app because of the WORKDIR being set.
57
+ #
58
+ # We copy in our Gemfile before the main app because Docker is
59
+ # smart enough to cache "layers" when you build a Docker image.
60
+ #
61
+ # You see, each command we have in the Dockerfile is going to be
62
+ # ran and then saved as a separate layer. Docker is smart enough
63
+ # to only re-build pieces that change, in order from top to bottom.
64
+ #
65
+ # This is an advanced concept but it means that we'll be able to
66
+ # cache all of our gems so that if we make an application code
67
+ # change, it won't re-run bundle install unless a gem changed.
68
+
69
+ RUN bundle install --binstubs
70
+ # We want binstubs to be available so we can directly call sidekiq and
71
+ # potentially other binaries as command overrides without depending on
72
+ # bundle exec.
73
+ # This is mainly due for production compatibility assurance.
74
+
75
+ COPY . .
76
+ # This might look a bit alien but it's copying in everything from
77
+ # the current directory relative to the Dockerfile, over to the
78
+ # /my_dockerized_app folder inside of the Docker image.
79
+ #
80
+ # We can get away with using the . for the second argument because
81
+ # this is how the unix command cp (copy) works. It stands for the
82
+ # current directory.
83
+
84
+ RUN bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname ACTION_CABLE_ALLOWED_REQUEST_ORIGINS=foo,bar SECRET_TOKEN=dummytoken assets:precompile
85
+ # Provide a dummy DATABASE_URL and more to Rails so it can pre-compile
86
+ # assets. The values do not need to be real, just valid syntax.
87
+ #
88
+ # If you're saving your assets to a CDN and are working with multiple
89
+ # app instances, you may want to remove this step and deal with asset
90
+ # compilation at a different stage of your deployment.
91
+
92
+ VOLUME ["$INSTALL_PATH/public"]
93
+ # In production you will very likely reverse proxy Rails with nginx.
94
+ # This sets up a volume so that nginx can read in the assets from
95
+ # the Rails Docker image without having to copy them to the Docker host.
96
+
97
+ CMD puma -C config/puma.rb
98
+ # This is the command that's going to be ran by default if you run the
99
+ # Docker image without any arguments.
100
+ #
101
+ # In our case, it will start the Puma app server while passing in
102
+ # its config file.
@@ -0,0 +1,69 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Looking to use the Edge version? gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '~> 5.0.0'
5
+
6
+ # Use Puma as the app server
7
+ gem 'puma', '~> 3.0'
8
+
9
+ # Use Rack Timeout. Read more: https://github.com/heroku/rack-timeout
10
+ gem 'rack-timeout', '~> 0.4'
11
+
12
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13
+ gem 'jbuilder', '~> 2.5'
14
+
15
+ # Use PostgreSQL as the database for Active Record
16
+ gem 'pg', '~> 0.18'
17
+
18
+ # Use Redis Rails to set up a Redis backed Cache and / or Session
19
+ gem 'redis-rails', '~> 5.0.0.pre'
20
+
21
+ # Use Sidekiq as a background job processor through Active Job
22
+ gem 'sidekiq', '~> 4.1'
23
+
24
+ # Use Clockwork for recurring background tasks without needing cron
25
+ # gem 'clockwork', '~> 2.0'
26
+
27
+ # Use Kaminari for pagination
28
+ # gem 'kaminari', '~> 0.16'
29
+
30
+ # Use SCSS for stylesheets
31
+ gem 'sass-rails', '~> 5.0'
32
+
33
+ # Use Uglifier as the compressor for JavaScript assets
34
+ gem 'uglifier', '>= 1.3.0'
35
+
36
+ # Use jQuery as the JavaScript library
37
+ gem 'jquery-rails'
38
+
39
+ # Use Turbolinks. Read more: https://github.com/turbolinks/turbolinks
40
+ gem 'turbolinks', '~> 5'
41
+
42
+ # Use Bootstrap SASS for Bootstrap support
43
+ gem 'bootstrap-sass', '~> 3.3'
44
+
45
+ # Use Font Awesome Rails for Font Awesome icons
46
+ gem 'font-awesome-rails', '~> 4.6'
47
+
48
+ group :development, :test do
49
+ # Call 'byebug' anywhere in your code to drop into a debugger console
50
+ gem 'byebug', platform: :mri
51
+ end
52
+
53
+ group :development do
54
+ # Enable a debug toolbar to help profile your application
55
+ gem 'rack-mini-profiler', '~> 0.10'
56
+
57
+ # Access an IRB console on exception pages or by using <%= console %>
58
+ gem 'web-console'
59
+
60
+ # Get notified of file changes. Read more: https://github.com/guard/listen
61
+ gem 'listen', '~> 3.0.5'
62
+
63
+ # Use Spring. Read more: https://github.com/rails/spring
64
+ gem 'spring'
65
+ gem 'spring-watcher-listen', '~> 2.0.0'
66
+ end
67
+
68
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
69
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]