roro 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Guardfile +9 -5
  4. data/lib/roro.rb +1 -1
  5. data/lib/roro/cli.rb +5 -1
  6. data/lib/roro/cli/base/base.rb +2 -1
  7. data/lib/roro/cli/base/base_files.rb +1 -7
  8. data/lib/roro/cli/base/check_dependencies.rb +98 -0
  9. data/lib/roro/cli/base/insert_gems.rb +15 -7
  10. data/lib/roro/cli/base/insertions.rb +3 -1
  11. data/lib/roro/cli/configuration.rb +68 -0
  12. data/lib/roro/cli/generate/config.rb +13 -0
  13. data/lib/roro/cli/generate/config/rails.rb +17 -0
  14. data/lib/roro/cli/generate/generate.rb +1 -0
  15. data/lib/roro/cli/generate/generate_keys.rb +79 -0
  16. data/lib/roro/cli/greenfield.rb +15 -16
  17. data/lib/roro/cli/rollon.rb +66 -20
  18. data/lib/roro/cli/rollon/database/database.rb +31 -0
  19. data/lib/roro/cli/rollon/database/with_mysql.rb +22 -0
  20. data/lib/roro/cli/rollon/database/with_postgres.rb +21 -0
  21. data/lib/roro/cli/rollon/stories.rb +3 -3
  22. data/lib/roro/cli/roro_configurator.yml +157 -0
  23. data/{.keep → lib/roro/cli/templates/base/.env/.keep} +0 -0
  24. data/lib/roro/cli/templates/base/.env/database.mysql.env.tt +4 -0
  25. data/lib/roro/cli/templates/base/.env/database.pg.env.tt +5 -0
  26. data/lib/roro/cli/templates/base/.env/web.env.tt +1 -0
  27. data/lib/roro/cli/templates/base/.roro_config.yml +15 -0
  28. data/lib/roro/cli/templates/base/Dockerfile.tt +44 -0
  29. data/lib/roro/cli/templates/base/config/database.mysql.yml +19 -0
  30. data/lib/roro/cli/templates/base/config/{database.yml.pg.tt → database.pg.yml} +0 -0
  31. data/lib/roro/cli/templates/{base/circleci → circleci}/config.yml.tt +0 -0
  32. data/lib/roro/cli/templates/greenfield/Dockerfile.tt +29 -7
  33. data/lib/roro/cli/templates/{base/livereload → livereload}/hosts.example +0 -0
  34. data/lib/roro/cli/templates/{base/roro → roro}/.keep +0 -0
  35. data/lib/roro/cli/templates/{greenfield → roro}/docker-compose.yml.tt +18 -13
  36. data/lib/roro/cli/templates/{base/roro/containers → roro/roro}/.keep +0 -0
  37. data/lib/roro/cli/templates/{base/roro/containers/app → roro/roro/containers}/.keep +0 -0
  38. data/lib/roro/cli/templates/{base/roro/containers/frontend → roro/roro/containers/app}/.keep +0 -0
  39. data/lib/roro/cli/templates/roro/roro/containers/frontend/.keep +0 -0
  40. data/lib/roro/cli/templates/roro/roro/docker-entrypoint.sh.tt +8 -0
  41. data/lib/roro/cli/templates/stories/.keep +0 -0
  42. data/lib/roro/cli/templates/stories/with_mysql/_service.yml +10 -0
  43. data/lib/roro/cli/templates/stories/with_postgresql/.keep +0 -0
  44. data/lib/roro/cli/templates/stories/with_postgresql/_service.yml +7 -0
  45. data/lib/roro/version.rb +1 -1
  46. metadata +33 -25
  47. data/lib/roro/cli/base/configuration.rb +0 -118
  48. data/lib/roro/cli/rollon/rollon_as_dockerize.rb +0 -42
  49. data/lib/roro/cli/rollon/rollon_as_quickstart.rb +0 -17
  50. data/lib/roro/cli/rollon/rollon_as_roro.rb +0 -30
  51. data/lib/roro/cli/templates/base/docker-compose.yml.tt +0 -53
  52. data/lib/roro/cli/templates/base/pg/config/database.yml.pg.tt +0 -20
  53. data/lib/roro/cli/templates/base/pg/database.yml.pg.tt +0 -20
  54. data/lib/roro/cli/templates/base/roro/containers/app/Dockerfile.tt +0 -32
  55. data/lib/roro/cli/templates/base/roro/containers/app/development.env.tt +0 -1
  56. data/lib/roro/cli/templates/base/roro/containers/app/docker-entrypoint.sh +0 -8
  57. data/lib/roro/cli/templates/base/roro/containers/app/test.env.tt +0 -1
  58. data/lib/roro/cli/templates/base/roro/containers/database/development.env.tt +0 -4
  59. data/lib/roro/cli/templates/base/roro/containers/database/test.env.tt +0 -4
  60. data/roro-0.3.4.gem +0 -0
@@ -1,21 +1,43 @@
1
- FROM ruby:<%= config[:ruby_version] %> AS stage1
1
+ FROM ruby:<%= config['ruby_version'] %> AS builder
2
2
 
3
+ ## Make sure we have yarn properly sourced:
3
4
  RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
4
5
  RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
6
+
7
+ ## Update OS and download yarm from source specified above:
5
8
  RUN apt-get update -qq && apt-get install -y build-essential git nodejs yarn
6
9
 
10
+ ## Set up our workspace directories:
11
+ ENV APP_HOME /usr/src/app/
12
+ RUN mkdir ${APP_HOME}
7
13
 
14
+ ## Tell bundler where to store downloaded gems:
8
15
  ENV BUNDLE_PATH /gems
9
- ENV APP_HOME /usr/src/app/
10
- RUN mkdir $APP_HOME
11
- WORKDIR $APP_HOME
16
+ RUN mkdir ${BUNDLE_PATH}}
17
+
18
+ ## Tell Docker to create volumes for our workspace and gems
19
+ ## so other containers can access them.
20
+ VOLUME ${APP_HOME}
21
+ VOLUME /gems
12
22
 
23
+ ## Create a Gemfile with just the Rails gem inside:
13
24
  RUN echo "source 'https://rubygems.org'\ngem 'rails'" > Gemfile
14
25
 
15
- RUN bundle
16
- RUN bundle exec rails new greenfield --skip-bundle --skip-webpack-install
26
+ ## Bundle to install rails:
27
+ RUN bundle install
28
+
29
+ ## Switch to the the work directory from container root:
30
+ WORKDIR ${APP_HOME}
31
+
32
+ ## Use Rails to generate a new app. We'll configure it later.
33
+ RUN bundle exec rails new . --skip-webpack-install --skip-bundle
34
+
35
+ ## Tell docker not to create a layer:
17
36
  FROM scratch AS export-stage
18
37
 
19
- COPY --from=stage1 /usr/src/app/greenfield .
38
+ ## Copy the generated files onto the host. Note that because we are in a
39
+ ## new container, we don't have access to the previous ${APP_HOME}
40
+ ## variable and so we must hard code it as our source:
41
+ COPY --from=builder /usr/src/app/ .
20
42
 
21
43
 
@@ -1,46 +1,50 @@
1
- version: '3'
1
+ version: '3.2'
2
2
 
3
3
  services:
4
4
 
5
5
  web:
6
- build: .
6
+ build:
7
+ context: .
8
+ dockerfile: roro/containers/app/Dockerfile
7
9
  depends_on:
8
10
  - database
9
- - webpack_dev_server
10
11
  - redis
11
- # entrypoint: ./docker-entrypoint.sh
12
- command: ["bin/rails", "s", "-b", "0.0.0.0"]
13
12
 
13
+ command: ["bin/rails", "s", "-b", "0.0.0.0"]
14
14
  ports:
15
15
  - "3000:3000"
16
16
  - "4000:4000"
17
17
  volumes:
18
- - .:/usr/src/app
18
+ - app:/usr/src/app
19
19
  - gem_cache:/gems
20
20
  env_file:
21
- - .env/development/web
22
- - .env/development/database
21
+ - roro/containers/app/development.env
22
+ - roro/containers/database/development.env
23
23
  environment:
24
24
  - WEBPACKER_DEV_SERVER_HOST=webpack_dev_server
25
25
 
26
26
  webpack_dev_server:
27
- build: .
27
+ build:
28
+ context: .
29
+ dockerfile: roro/containers/app/Dockerfile
30
+
31
+
28
32
  command: ./bin/webpack-dev-server
29
33
  ports:
30
34
  - 3035:3035
31
35
  volumes:
32
- - .:/usr/src/app
36
+ - app:/usr/src/app
33
37
  - gem_cache:/gems
34
38
  env_file:
35
- - .env/development/database
36
- - .env/development/web
39
+ - roro/containers/app/development.env
40
+ - roro/containers/database/development.env
37
41
  environment:
38
42
  - WEBPACKER_DEV_SERVER_HOST=0.0.0.0
39
43
 
40
44
  redis:
41
45
  image: redis
42
46
 
43
- <%= config[:database_service] %>
47
+ <%= yaml_from_template("stories/with_#{config['database_vendor']}/_service.yml") %>
44
48
 
45
49
  system_tests:
46
50
  image: selenium/standalone-chrome-debug
@@ -53,3 +57,4 @@ services:
53
57
  volumes:
54
58
  db_data:
55
59
  gem_cache:
60
+ app:
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Remove a potentially pre-existing server.pid for Rails.
5
+ rm -f /usr/src/app/tmp/pids/server.pid
6
+
7
+ # Then exec the container's main process (what's set as CMD in the Dockerfile).
8
+ exec "$@"
File without changes
@@ -0,0 +1,10 @@
1
+ database:
2
+ image: mysql:5.7
3
+ env_file:
4
+ - roro/containers/database/development.env
5
+ - roro/containers/app/development.env
6
+ volumes:
7
+ - db_data:/var/lib/mysql
8
+ restart: always
9
+ ports:
10
+ - '3307:3306'
@@ -0,0 +1,7 @@
1
+ database:
2
+ image: postgres
3
+ env_file:
4
+ - roro/containers/database/development.env
5
+ - roro/containers/app/development.env
6
+ volumes:
7
+ - db_data:/var/lib/postgresql/data
@@ -1,3 +1,3 @@
1
1
  module Roro
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - schadenfred
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -147,7 +147,6 @@ extensions: []
147
147
  extra_rdoc_files: []
148
148
  files:
149
149
  - ".gitignore"
150
- - ".keep"
151
150
  - ".ruby-gemset"
152
151
  - ".travis.yml"
153
152
  - CODE_OF_CONDUCT.md
@@ -163,39 +162,38 @@ files:
163
162
  - lib/roro/cli.rb
164
163
  - lib/roro/cli/base/base.rb
165
164
  - lib/roro/cli/base/base_files.rb
166
- - lib/roro/cli/base/configuration.rb
165
+ - lib/roro/cli/base/check_dependencies.rb
167
166
  - lib/roro/cli/base/continuous_integration.rb
168
167
  - lib/roro/cli/base/insert_gems.rb
169
168
  - lib/roro/cli/base/insertions.rb
170
169
  - lib/roro/cli/base/utilities.rb
170
+ - lib/roro/cli/configuration.rb
171
171
  - lib/roro/cli/expose.rb
172
+ - lib/roro/cli/generate/config.rb
173
+ - lib/roro/cli/generate/config/rails.rb
174
+ - lib/roro/cli/generate/generate.rb
175
+ - lib/roro/cli/generate/generate_keys.rb
172
176
  - lib/roro/cli/generate_keys.rb
173
177
  - lib/roro/cli/greenfield.rb
174
178
  - lib/roro/cli/obfuscate.rb
175
179
  - lib/roro/cli/rollon.rb
176
- - lib/roro/cli/rollon/rollon_as_dockerize.rb
177
- - lib/roro/cli/rollon/rollon_as_quickstart.rb
178
- - lib/roro/cli/rollon/rollon_as_roro.rb
180
+ - lib/roro/cli/rollon/database/database.rb
181
+ - lib/roro/cli/rollon/database/with_mysql.rb
182
+ - lib/roro/cli/rollon/database/with_postgres.rb
179
183
  - lib/roro/cli/rollon/stories.rb
184
+ - lib/roro/cli/roro_configurator.yml
180
185
  - lib/roro/cli/ruby_gem.rb
181
186
  - lib/roro/cli/templates/base/.dockerignore
187
+ - lib/roro/cli/templates/base/.env/.keep
188
+ - lib/roro/cli/templates/base/.env/database.mysql.env.tt
189
+ - lib/roro/cli/templates/base/.env/database.pg.env.tt
190
+ - lib/roro/cli/templates/base/.env/web.env.tt
182
191
  - lib/roro/cli/templates/base/.keep
183
- - lib/roro/cli/templates/base/circleci/config.yml.tt
184
- - lib/roro/cli/templates/base/config/database.yml.pg.tt
185
- - lib/roro/cli/templates/base/docker-compose.yml.tt
186
- - lib/roro/cli/templates/base/livereload/hosts.example
187
- - lib/roro/cli/templates/base/pg/config/database.yml.pg.tt
188
- - lib/roro/cli/templates/base/pg/database.yml.pg.tt
189
- - lib/roro/cli/templates/base/roro/.keep
190
- - lib/roro/cli/templates/base/roro/containers/.keep
191
- - lib/roro/cli/templates/base/roro/containers/app/.keep
192
- - lib/roro/cli/templates/base/roro/containers/app/Dockerfile.tt
193
- - lib/roro/cli/templates/base/roro/containers/app/development.env.tt
194
- - lib/roro/cli/templates/base/roro/containers/app/docker-entrypoint.sh
195
- - lib/roro/cli/templates/base/roro/containers/app/test.env.tt
196
- - lib/roro/cli/templates/base/roro/containers/database/development.env.tt
197
- - lib/roro/cli/templates/base/roro/containers/database/test.env.tt
198
- - lib/roro/cli/templates/base/roro/containers/frontend/.keep
192
+ - lib/roro/cli/templates/base/.roro_config.yml
193
+ - lib/roro/cli/templates/base/Dockerfile.tt
194
+ - lib/roro/cli/templates/base/config/database.mysql.yml
195
+ - lib/roro/cli/templates/base/config/database.pg.yml
196
+ - lib/roro/cli/templates/circleci/config.yml.tt
199
197
  - lib/roro/cli/templates/dockerize/.env/.keep
200
198
  - lib/roro/cli/templates/dockerize/.env/development/.keep
201
199
  - lib/roro/cli/templates/dockerize/.env/development/database
@@ -205,7 +203,6 @@ files:
205
203
  - lib/roro/cli/templates/dockerize/docker-compose.yml.tt
206
204
  - lib/roro/cli/templates/dockerize/docker-entrypoint.sh
207
205
  - lib/roro/cli/templates/greenfield/Dockerfile.tt
208
- - lib/roro/cli/templates/greenfield/docker-compose.yml.tt
209
206
  - lib/roro/cli/templates/jumpstart/.env/.keep
210
207
  - lib/roro/cli/templates/jumpstart/.env/development/.keep
211
208
  - lib/roro/cli/templates/jumpstart/.env/development/database
@@ -214,10 +211,18 @@ files:
214
211
  - lib/roro/cli/templates/jumpstart/Dockerfile.tt
215
212
  - lib/roro/cli/templates/jumpstart/docker-compose.yml
216
213
  - lib/roro/cli/templates/jumpstart/docker-entrypoint.sh
214
+ - lib/roro/cli/templates/livereload/hosts.example
217
215
  - lib/roro/cli/templates/quickstart/Dockerfile.tt
218
216
  - lib/roro/cli/templates/quickstart/database.yml
219
217
  - lib/roro/cli/templates/quickstart/docker-compose.yml
220
218
  - lib/roro/cli/templates/quickstart/entrypoint.sh
219
+ - lib/roro/cli/templates/roro/.keep
220
+ - lib/roro/cli/templates/roro/docker-compose.yml.tt
221
+ - lib/roro/cli/templates/roro/roro/.keep
222
+ - lib/roro/cli/templates/roro/roro/containers/.keep
223
+ - lib/roro/cli/templates/roro/roro/containers/app/.keep
224
+ - lib/roro/cli/templates/roro/roro/containers/frontend/.keep
225
+ - lib/roro/cli/templates/roro/roro/docker-entrypoint.sh.tt
221
226
  - lib/roro/cli/templates/ruby_gem/.gitignore
222
227
  - lib/roro/cli/templates/ruby_gem/config.yml
223
228
  - lib/roro/cli/templates/ruby_gem/docker-compose.yml
@@ -225,9 +230,12 @@ files:
225
230
  - lib/roro/cli/templates/ruby_gem/docker/env_files/.keep
226
231
  - lib/roro/cli/templates/ruby_gem/docker/keys/.keep
227
232
  - lib/roro/cli/templates/ruby_gem/setup-gem-credentials.sh
233
+ - lib/roro/cli/templates/stories/.keep
234
+ - lib/roro/cli/templates/stories/with_mysql/_service.yml
235
+ - lib/roro/cli/templates/stories/with_postgresql/.keep
236
+ - lib/roro/cli/templates/stories/with_postgresql/_service.yml
228
237
  - lib/roro/version.rb
229
238
  - lib/tasks/deploy.rake
230
- - roro-0.3.4.gem
231
239
  - roro.gemspec
232
240
  - vendor/bundle/.keep
233
241
  - vendor/cache/actionpack-6.0.3.2.gem
@@ -1,118 +0,0 @@
1
-
2
- module Roro
3
-
4
- class CLI < Thor
5
-
6
- no_commands do
7
-
8
- def get_configuration_variables(hash={})
9
- options["interactive"] ? set_interactively : set_from_defaults
10
- hash.each { |k,v| @env_hash[k] = v } unless hash.nil?
11
- @env_hash[:deploy_tag] = "${CIRCLE_SHA1:0:7}"
12
- @env_hash[:server_port] = "22"
13
- @env_hash[:server_user] = "root"
14
- @env_hash
15
- end
16
-
17
- def set_from_defaults
18
- @env_hash = configuration_hash
19
- @env_hash.map do |key, hash|
20
- @env_hash[key] = hash.values.last
21
- end
22
- @env_hash
23
- end
24
-
25
- def set_interactively
26
- @env_hash = configuration_hash
27
- @env_hash.map do |key, prompt|
28
- answer = ask("Please provide #{prompt.keys.first} or hit enter to accept: \[ #{prompt.values.first} \]")
29
- @env_hash[key] = (answer == "") ? prompt.values.first : answer
30
- end
31
- end
32
-
33
- def confirm_dependencies
34
- dependencies = [
35
- {
36
- system_query: "which docker",
37
- warning: "Docker isn't installed",
38
- suggestion: "https://docs.docker.com/install/"
39
- }, {
40
- system_query: "which docker-compose",
41
- warning: "Docker Compose isn't installed",
42
- suggestion: "https://docs.docker.com/compose/install/"
43
-
44
- }, {
45
- system_query: "docker info",
46
- warning: "the Docker daemon isn't running",
47
- suggestion: "https://docs.docker.com/config/daemon/#start-the-daemon-manually"
48
- }
49
- ]
50
-
51
- dependencies.each do |dependency|
52
- confirm_dependency(dependency)
53
- end
54
- end
55
-
56
-
57
-
58
- def confirm_dependency(options)
59
- msg = []
60
- msg << ""
61
- msg << delineator
62
- msg << "It looks like #{options[:warning]}. The following bash command returns false:"
63
- msg << "\t$ #{options[:system_query]}"
64
- msg << "Please try these instructions:"
65
- msg << ("\t" + options[:suggestion])
66
- msg << delineator
67
- conditional = options[:conditional] ? eval(options[:conditional]) : system(options[:system_query])
68
- if conditional == false
69
- raise(Roro::Error.new(msg.join("\n\n")))
70
- end
71
- end
72
-
73
-
74
- private
75
-
76
- def configuration_hash
77
- {
78
- app_name: {
79
- "the name of your app" => `pwd`.split('/').last.strip!
80
- },
81
- ruby_version: {
82
- "the version of ruby you'd like" => `ruby -v`.scan(/\d.\d/).first
83
- },
84
- server_host: {
85
- "the ip address of your server" => "ip-address-of-your-server"
86
- },
87
- database_container: {
88
- "the name of your database container" => "database"
89
- },
90
- frontend_container: {
91
- "the name of your frontend container" => "frontend"
92
- },
93
- server_container: {
94
- "the name of your server container" => "nginx"
95
- },
96
- dockerhub_email: {
97
- "your Docker Hub email" => "your-docker-hub-email"
98
- },
99
- dockerhub_user: {
100
- "your Docker Hub username" => "your-docker-hub-user-name"
101
- },
102
- dockerhub_org: {
103
- "your Docker Hub organization name" => "your-docker-hub-org-name"
104
- },
105
- dockerhub_password: {
106
- "your Docker Hub password" => "your-docker-hub-password"
107
- },
108
- postgres_user: {
109
- "your Postgres username" => "postgres"
110
- },
111
- postgres_password: {
112
- "your Postgres password" => "your-postgres-password"
113
- }
114
- }
115
- end
116
- end
117
- end
118
- end
@@ -1,42 +0,0 @@
1
- module Roro
2
-
3
- class CLI < Thor
4
-
5
- no_commands do
6
-
7
- def rollon_as_dockerize
8
- rollon_dockerize_files
9
- system 'docker-compose build'
10
- system 'docker-compose run --no-deps web bin/rails webpacker:install'
11
- system 'docker-compose up'
12
- end
13
-
14
- def
15
-
16
- def configure_for_pg
17
- service = [
18
- " database:",
19
- " image: postgres",
20
- " env_file:",
21
- " - .env/development/database",
22
- " volumes:",
23
- " - db_data:var/lib/postgresql/data"
24
- ].join("\n")
25
-
26
- @env_hash[:database_service] = service
27
- end
28
-
29
- def rollon_dockerize_files
30
- directory 'dockerize', '.', @env_hash
31
- copy_dockerignore
32
- if ask('Configure $stdout.sync for docker?', choices).eql?('y')
33
- config_std_out_true
34
- end
35
- if ask('Configure your app to use Postgresql?', choices).eql?('y')
36
- copy_database_yml_pg
37
- insert_pg_gem_into_gemfile
38
- end
39
- end
40
- end
41
- end
42
- end