modulorails 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +14 -0
  3. data/.gitignore +3 -0
  4. data/.travis.yml +23 -4
  5. data/Appraisals +18 -0
  6. data/CHANGELOG.md +37 -0
  7. data/Dockerfile.ruby25 +34 -0
  8. data/Dockerfile.ruby26 +28 -0
  9. data/Dockerfile.ruby27 +25 -0
  10. data/Dockerfile.ruby30 +25 -0
  11. data/Dockerfile.ruby31 +25 -0
  12. data/Gemfile.lock +61 -54
  13. data/README.md +16 -4
  14. data/Rakefile +1 -1
  15. data/docker-compose.yml +37 -0
  16. data/entrypoints/appraisal_test.sh +7 -0
  17. data/gemfiles/rails_52.gemfile +9 -0
  18. data/gemfiles/rails_60.gemfile +9 -0
  19. data/gemfiles/rails_61.gemfile +9 -0
  20. data/gemfiles/rails_70.gemfile +9 -0
  21. data/lib/generators/modulorails/docker/docker_generator.rb +19 -0
  22. data/lib/generators/modulorails/docker/templates/Dockerfile.prod.tt +57 -0
  23. data/lib/generators/modulorails/docker/templates/Dockerfile.tt +26 -0
  24. data/lib/generators/modulorails/docker/templates/config/database.yml.tt +32 -0
  25. data/lib/generators/modulorails/docker/templates/docker-compose.prod.yml.tt +50 -0
  26. data/lib/generators/modulorails/docker/templates/docker-compose.yml.tt +71 -0
  27. data/lib/generators/modulorails/docker/templates/entrypoints/docker-entrypoint.sh.tt +20 -0
  28. data/lib/generators/modulorails/docker/templates/entrypoints/webpack-entrypoint.sh.tt +7 -0
  29. data/lib/generators/modulorails/gitlabci/gitlabci_generator.rb +34 -0
  30. data/lib/generators/modulorails/gitlabci/templates/.gitlab-ci.yml.tt +118 -0
  31. data/lib/generators/modulorails/gitlabci/templates/.modulorails-gitlab-ci +6 -0
  32. data/lib/generators/modulorails/gitlabci/templates/config/database-ci.yml.tt +8 -0
  33. data/lib/generators/modulorails/healthcheck/health_check_generator.rb +41 -0
  34. data/lib/generators/modulorails/healthcheck/templates/.modulorails-health_check +6 -0
  35. data/lib/generators/modulorails/healthcheck/templates/config/initializers/health_check.rb.tt +100 -0
  36. data/lib/generators/modulorails/self_update/self_update_generator.rb +32 -0
  37. data/lib/modulorails/configuration.rb +8 -2
  38. data/lib/modulorails/data.rb +23 -3
  39. data/lib/modulorails/railtie.rb +18 -3
  40. data/lib/modulorails/validators/database_configuration.rb +1 -1
  41. data/lib/modulorails/version.rb +1 -1
  42. data/lib/modulorails.rb +34 -21
  43. data/modulorails.gemspec +2 -0
  44. metadata +69 -17
  45. data/lib/generators/gitlabci_generator.rb +0 -132
  46. data/lib/generators/templates/.gitlab-ci.yml +0 -72
  47. data/lib/generators/templates/.modulorails-gitlab-ci +0 -3
  48. data/lib/generators/templates/config/database-ci.yml +0 -7
  49. data/lib/modulorails/updater.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92b2390033b3083f0829661ac44665f58f8eb438fb095d32c803ae5cea51c488
4
- data.tar.gz: 5e13ccdb0a64f7b32ac594601f4f2415f081a16284e9c73cb1953c3e5cc47497
3
+ metadata.gz: f695c4454203bb2d22353b7cff523da2315c7ce5472300208f1774d6aed2be5a
4
+ data.tar.gz: f02062f1a5878154caa982fbf70dd5d584cdd1b07a90f5614aa4e01d27b79b20
5
5
  SHA512:
6
- metadata.gz: 1e9e8885a9c648e7de6af49c3fa66ab59243714eda2449cd8398f4c09efa2fa5f744d71db7aa68f91a8f9912282c416e6e91f8c665b1035ea376974702251924
7
- data.tar.gz: c15837070582d0a901fdfeee1c1d0be86a67f5fe69efbcca39fb14921e2ee1c527dadca48ab0c89691679d8bcc9144586a2ab4309773b4a8e8771369cb8ef5c7
6
+ metadata.gz: 93943d5cd4726cce846e10c09149ff39b19adadbdf823a3ffc4032e524184ebd1fd50a83be07286ea50938062995df3a6166edd206461efeb400b85e00101d31
7
+ data.tar.gz: 92b4689741e9468f395656200ff35096553e332e84958892adaedccfb6b14fb674f01078ae3a8588d104838d9e080422de7ae414224add37ed0c9a533aaf0508
data/.dockerignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ *.gem
13
+ gemfiles/*.lock
14
+ Gemfile.lock
data/.gitignore CHANGED
@@ -9,3 +9,6 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
13
+ gemfiles/*.lock
14
+ /config/database.yml
data/.travis.yml CHANGED
@@ -1,9 +1,28 @@
1
1
  ---
2
2
  language: ruby
3
3
  cache: bundler
4
- rvm:
5
- - 2.5
6
- - 2.6
7
- - 2.7
4
+
5
+ ruby:
6
+ - '2.5'
7
+ - '2.6'
8
+ - '2.7'
9
+ - '3.0'
10
+ - '3.1'
11
+
8
12
  before_install:
9
13
  - gem install bundler -v 2.1.4
14
+
15
+ gemfile:
16
+ - gemfiles/rails_52.gemfile
17
+ - gemfiles/rails_60.gemfile
18
+ - gemfiles/rails_61.gemfile
19
+ - gemfiles/rails_70.gemfile
20
+
21
+ matrix:
22
+ exclude:
23
+ - gemfile: gemfiles/rails_70.gemfile
24
+ ruby: 2.5
25
+ - gemfile: gemfiles/rails_70.gemfile
26
+ ruby: 2.6
27
+
28
+ script: bundle exec rake spec
data/Appraisals ADDED
@@ -0,0 +1,18 @@
1
+ appraise "rails-52" do
2
+ gem 'rails', '~> 5.2', '>= 5.2.6'
3
+ end
4
+
5
+ appraise "rails-60" do
6
+ gem 'rails', '~> 6.0', '>= 6.0.4.4'
7
+ end
8
+
9
+ appraise "rails-61" do
10
+ gem 'rails', '~> 6.1', '>= 6.1.4.4'
11
+ end
12
+
13
+ # Rails 7 requires at least Ruby 2.7
14
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
15
+ appraise "rails-70" do
16
+ gem 'rails', '~> 7.0'
17
+ end
18
+ end
data/CHANGELOG.md CHANGED
@@ -2,6 +2,43 @@
2
2
 
3
3
  This file is used to list changes made in each version of the gem.
4
4
 
5
+ # 0.4.0
6
+
7
+ Fixes, updates and health_check release.
8
+
9
+ - Update generators for Docker and Gitlab CI.
10
+ - Move all generators under the `modulorails` namespace.
11
+ - Add dependency to `health_check` gem.
12
+ - Fix error on database configuration validator when no database.yml exists.
13
+ - Rescue if httparty can't post to configuration.endpoint.
14
+ - Add dockerfiles to test on many Ruby versions.
15
+ - Add appraisal to test on many Rails versions.
16
+
17
+ # 0.3.0
18
+
19
+ Docker release.
20
+
21
+ - Add generator for Docker.
22
+ - Use templates for Gitlabci generator.
23
+
24
+ # 0.2.3
25
+
26
+ Gitlab-ci generator.
27
+
28
+ - Fixes the Ruby version put in the generated `.gitlab-ci.yml`.
29
+
30
+ # 0.2.2
31
+
32
+ Auto-update fixes.
33
+
34
+ - Run `bundle install` to update the `Gemfile.lock` on auto-update.
35
+
36
+ # 0.2.1
37
+
38
+ Minor fixes.
39
+
40
+ - Fixes some errors occuring on a project where database can not be accessed.
41
+
5
42
  # 0.2.0
6
43
 
7
44
  Auto-update release.
data/Dockerfile.ruby25 ADDED
@@ -0,0 +1,34 @@
1
+ #
2
+ # BUILD IMAGE
3
+ #
4
+ FROM ruby:2.5-alpine
5
+
6
+ WORKDIR /app
7
+
8
+ RUN apk add --update --no-cache \
9
+ alpine-sdk \
10
+ tzdata
11
+
12
+ RUN gem install bundler
13
+
14
+ # Your RubyGems version (3.0.3)) has a bug that prevents `required_ruby_version` from working for
15
+ # Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support
16
+ # for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning
17
+ # by running `gem update --system 3.2.3`
18
+ RUN gem update --system 3.2.3
19
+
20
+ COPY . .
21
+
22
+ RUN bundle config set specific_platform true
23
+
24
+ # Ensure the use of a Gemfile working with Ruby 2.5
25
+ RUN sed -e 's/"..\/"/".\/"/' gemfiles/rails_52.gemfile > Gemfile
26
+
27
+ # Install the basic dependencies
28
+ RUN bundle install
29
+
30
+ # Install dependencies for all supported Rails versions
31
+ RUN bundle exec appraisal install
32
+
33
+ # Run the tests
34
+ CMD ['./entrypoints/appraisal_test.sh']
data/Dockerfile.ruby26 ADDED
@@ -0,0 +1,28 @@
1
+ #
2
+ # BUILD IMAGE
3
+ #
4
+ FROM ruby:2.6-alpine
5
+
6
+ WORKDIR /app
7
+
8
+ RUN apk add --update --no-cache \
9
+ alpine-sdk \
10
+ tzdata
11
+
12
+ RUN gem install bundler
13
+
14
+ COPY . .
15
+
16
+ RUN bundle config set specific_platform true
17
+
18
+ # Ensure the use of a Gemfile working with Ruby 2.6
19
+ RUN sed -e 's/"..\/"/".\/"/' gemfiles/rails_52.gemfile > Gemfile
20
+
21
+ # Install the basic dependencies
22
+ RUN bundle install
23
+
24
+ # Install dependencies for all supported Rails versions
25
+ RUN bundle exec appraisal install
26
+
27
+ # Run the tests
28
+ CMD ['./entrypoints/appraisal_test.sh']
data/Dockerfile.ruby27 ADDED
@@ -0,0 +1,25 @@
1
+ #
2
+ # BUILD IMAGE
3
+ #
4
+ FROM ruby:2.7-alpine
5
+
6
+ WORKDIR /app
7
+
8
+ RUN apk add --update --no-cache \
9
+ alpine-sdk \
10
+ tzdata
11
+
12
+ RUN gem install bundler
13
+
14
+ COPY . .
15
+
16
+ RUN bundle config set specific_platform true
17
+
18
+ # Install the basic dependencies
19
+ RUN bundle install
20
+
21
+ # Install dependencies for all supported Rails versions
22
+ RUN bundle exec appraisal install
23
+
24
+ # Run the tests
25
+ CMD ['./entrypoints/appraisal_test.sh']
data/Dockerfile.ruby30 ADDED
@@ -0,0 +1,25 @@
1
+ #
2
+ # BUILD IMAGE
3
+ #
4
+ FROM ruby:3.0-alpine
5
+
6
+ WORKDIR /app
7
+
8
+ RUN apk add --update --no-cache \
9
+ alpine-sdk \
10
+ tzdata
11
+
12
+ RUN gem install bundler
13
+
14
+ COPY . .
15
+
16
+ RUN bundle config set specific_platform true
17
+
18
+ # Install the basic dependencies
19
+ RUN bundle install
20
+
21
+ # Install dependencies for all supported Rails versions
22
+ RUN bundle exec appraisal install
23
+
24
+ # Run the tests
25
+ CMD ['./entrypoints/appraisal_test.sh']
data/Dockerfile.ruby31 ADDED
@@ -0,0 +1,25 @@
1
+ #
2
+ # BUILD IMAGE
3
+ #
4
+ FROM ruby:3.1-alpine
5
+
6
+ WORKDIR /app
7
+
8
+ RUN apk add --update --no-cache \
9
+ alpine-sdk \
10
+ tzdata
11
+
12
+ RUN gem install bundler
13
+
14
+ COPY . .
15
+
16
+ RUN bundle config set specific_platform true
17
+
18
+ # Install the basic dependencies
19
+ RUN bundle install
20
+
21
+ # Install dependencies for all supported Rails versions
22
+ RUN bundle exec appraisal install
23
+
24
+ # Run the tests
25
+ CMD ['./entrypoints/appraisal_test.sh']
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- modulorails (0.2.0)
4
+ modulorails (0.4.0)
5
5
  git (~> 1.7, >= 1.7.0)
6
+ health_check (~> 3.1)
6
7
  httparty
7
8
  i18n
8
9
  railties (>= 4.2.0)
@@ -10,97 +11,103 @@ PATH
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- actionpack (6.0.3.2)
14
- actionview (= 6.0.3.2)
15
- activesupport (= 6.0.3.2)
16
- rack (~> 2.0, >= 2.0.8)
14
+ actionpack (7.0.0)
15
+ actionview (= 7.0.0)
16
+ activesupport (= 7.0.0)
17
+ rack (~> 2.0, >= 2.2.0)
17
18
  rack-test (>= 0.6.3)
18
19
  rails-dom-testing (~> 2.0)
19
20
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.0.3.2)
21
- activesupport (= 6.0.3.2)
21
+ actionview (7.0.0)
22
+ activesupport (= 7.0.0)
22
23
  builder (~> 3.1)
23
24
  erubi (~> 1.4)
24
25
  rails-dom-testing (~> 2.0)
25
26
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activemodel (6.0.3.2)
27
- activesupport (= 6.0.3.2)
28
- activerecord (6.0.3.2)
29
- activemodel (= 6.0.3.2)
30
- activesupport (= 6.0.3.2)
31
- activesupport (6.0.3.2)
27
+ activemodel (7.0.0)
28
+ activesupport (= 7.0.0)
29
+ activerecord (7.0.0)
30
+ activemodel (= 7.0.0)
31
+ activesupport (= 7.0.0)
32
+ activesupport (7.0.0)
32
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
- i18n (>= 0.7, < 2)
34
- minitest (~> 5.1)
35
- tzinfo (~> 1.1)
36
- zeitwerk (~> 2.2, >= 2.2.2)
34
+ i18n (>= 1.6, < 2)
35
+ minitest (>= 5.1)
36
+ tzinfo (~> 2.0)
37
+ appraisal (2.4.1)
38
+ bundler
39
+ rake
40
+ thor (>= 0.14.0)
37
41
  builder (3.2.4)
38
- concurrent-ruby (1.1.7)
42
+ concurrent-ruby (1.1.9)
39
43
  crass (1.0.6)
40
- diff-lcs (1.4.4)
41
- erubi (1.9.0)
42
- git (1.7.0)
44
+ diff-lcs (1.5.0)
45
+ erubi (1.10.0)
46
+ git (1.10.2)
43
47
  rchardet (~> 1.8)
44
- httparty (0.18.1)
48
+ health_check (3.1.0)
49
+ railties (>= 5.0)
50
+ httparty (0.20.0)
45
51
  mime-types (~> 3.0)
46
52
  multi_xml (>= 0.5.2)
47
- i18n (1.8.5)
53
+ i18n (1.8.11)
48
54
  concurrent-ruby (~> 1.0)
49
- loofah (2.7.0)
55
+ loofah (2.13.0)
50
56
  crass (~> 1.0.2)
51
57
  nokogiri (>= 1.5.9)
52
58
  method_source (1.0.0)
53
- mime-types (3.3.1)
59
+ mime-types (3.4.1)
54
60
  mime-types-data (~> 3.2015)
55
- mime-types-data (3.2020.0512)
56
- mini_portile2 (2.4.0)
57
- minitest (5.14.1)
61
+ mime-types-data (3.2022.0105)
62
+ minitest (5.15.0)
58
63
  multi_xml (0.6.0)
59
- nokogiri (1.10.10)
60
- mini_portile2 (~> 2.4.0)
64
+ nokogiri (1.13.1-aarch64-linux)
65
+ racc (~> 1.4)
66
+ racc (1.6.0)
61
67
  rack (2.2.3)
62
68
  rack-test (1.1.0)
63
69
  rack (>= 1.0, < 3)
64
70
  rails-dom-testing (2.0.3)
65
71
  activesupport (>= 4.2.0)
66
72
  nokogiri (>= 1.6)
67
- rails-html-sanitizer (1.3.0)
73
+ rails-html-sanitizer (1.4.2)
68
74
  loofah (~> 2.3)
69
- railties (6.0.3.2)
70
- actionpack (= 6.0.3.2)
71
- activesupport (= 6.0.3.2)
75
+ railties (7.0.0)
76
+ actionpack (= 7.0.0)
77
+ activesupport (= 7.0.0)
72
78
  method_source
73
- rake (>= 0.8.7)
74
- thor (>= 0.20.3, < 2.0)
79
+ rake (>= 12.2)
80
+ thor (~> 1.0)
81
+ zeitwerk (~> 2.5)
75
82
  rake (12.3.3)
76
83
  rchardet (1.8.0)
77
- rspec (3.9.0)
78
- rspec-core (~> 3.9.0)
79
- rspec-expectations (~> 3.9.0)
80
- rspec-mocks (~> 3.9.0)
81
- rspec-core (3.9.2)
82
- rspec-support (~> 3.9.3)
83
- rspec-expectations (3.9.2)
84
+ rspec (3.10.0)
85
+ rspec-core (~> 3.10.0)
86
+ rspec-expectations (~> 3.10.0)
87
+ rspec-mocks (~> 3.10.0)
88
+ rspec-core (3.10.1)
89
+ rspec-support (~> 3.10.0)
90
+ rspec-expectations (3.10.1)
84
91
  diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.9.0)
86
- rspec-mocks (3.9.1)
92
+ rspec-support (~> 3.10.0)
93
+ rspec-mocks (3.10.2)
87
94
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.9.0)
89
- rspec-support (3.9.3)
90
- thor (1.0.1)
91
- thread_safe (0.3.6)
92
- tzinfo (1.2.7)
93
- thread_safe (~> 0.1)
94
- zeitwerk (2.4.0)
95
+ rspec-support (~> 3.10.0)
96
+ rspec-support (3.10.3)
97
+ thor (1.2.1)
98
+ tzinfo (2.0.4)
99
+ concurrent-ruby (~> 1.0)
100
+ zeitwerk (2.5.3)
95
101
 
96
102
  PLATFORMS
97
- ruby
103
+ aarch64-linux
98
104
 
99
105
  DEPENDENCIES
100
106
  activerecord (>= 4.2.0)
107
+ appraisal
101
108
  modulorails!
102
109
  rake (~> 12.0)
103
110
  rspec (~> 3.0)
104
111
 
105
112
  BUNDLED WITH
106
- 2.1.4
113
+ 2.3.3
data/README.md CHANGED
@@ -10,7 +10,7 @@ provides templates for the common configurations and defines common dependencies
10
10
  Add this line to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
- gem 'modulorails', git: 'git://github.com/moduloTech/modulorails.git'
13
+ gem 'modulorails'
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -33,9 +33,21 @@ end
33
33
 
34
34
  ## Development
35
35
 
36
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
37
-
38
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+ There are tests in `spec`. To run tests:
37
+ - Build Docker images using `docker compose build`.
38
+ - You can run tests on all supported Ruby versions using `docker compose up`.
39
+ - Or you can run test on a specific Ruby version using one of the following commands:
40
+ - Ruby 2.5: `docker compose run ruby25`
41
+ - Ruby 2.6: `docker compose run ruby26`
42
+ - Ruby 2.7: `docker compose run ruby27`
43
+ - Ruby 3.0: `docker compose run ruby30`
44
+ - Ruby 3.1: `docker compose run ruby31`
45
+
46
+ [Appraisal](https://github.com/thoughtbot/appraisal) is used to test the gem against many supported Rails versions:
47
+ - Rails 5.2, 6.0 and 6.1 on Ruby 2.5 and 2.6.
48
+ - Rails 5.2, 6.0, 6.1 and 7.0 on Ruby 2.7, 3.0 and 3.1.
49
+
50
+ Travis CI is configured to automatically run tests in all supported Ruby versions and dependency sets after each push.
39
51
 
40
52
  ## Contributing
41
53
 
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -0,0 +1,37 @@
1
+ version: '3.7'
2
+
3
+ services:
4
+ ruby25:
5
+ image: modulotechgroup/modulorails:testruby25
6
+ build:
7
+ context: .
8
+ dockerfile: Dockerfile.ruby25
9
+ command: ./entrypoints/appraisal_test.sh
10
+
11
+ ruby26:
12
+ image: modulotechgroup/modulorails:testruby26
13
+ build:
14
+ context: .
15
+ dockerfile: Dockerfile.ruby26
16
+ command: ./entrypoints/appraisal_test.sh
17
+
18
+ ruby27:
19
+ image: modulotechgroup/modulorails:testruby27
20
+ build:
21
+ context: .
22
+ dockerfile: Dockerfile.ruby27
23
+ command: ./entrypoints/appraisal_test.sh
24
+
25
+ ruby30:
26
+ image: modulotechgroup/modulorails:testruby30
27
+ build:
28
+ context: .
29
+ dockerfile: Dockerfile.ruby30
30
+ command: ./entrypoints/appraisal_test.sh
31
+
32
+ ruby31:
33
+ image: modulotechgroup/modulorails:testruby31
34
+ build:
35
+ context: .
36
+ dockerfile: Dockerfile.ruby31
37
+ command: ./entrypoints/appraisal_test.sh
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # Exit immediately if a command exits with a non-zero status
4
+ set -e
5
+
6
+ # Launch the tests
7
+ bundle exec appraisal rake spec
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rails", "~> 5.2", ">= 5.2.6"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rails", "~> 6.0", ">= 6.0.4.4"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rails", "~> 6.1", ">= 6.1.4.4"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 12.0"
6
+ gem "rspec", "~> 3.0"
7
+ gem "rails", "~> 7.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators'
4
+
5
+ class Modulorails::DockerGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+ desc 'This generator creates Dockerfiles for an app'
8
+
9
+ def create_config_file
10
+ template 'Dockerfile'
11
+ template 'Dockerfile.prod'
12
+ template 'docker-compose.yml'
13
+ template 'docker-compose.prod.yml'
14
+ template 'entrypoints/docker-entrypoint.sh'
15
+ template 'config/database.yml'
16
+ rescue StandardError => e
17
+ $stderr.puts("[Modulorails] Error: cannot generate Docker configuration: #{e.message}")
18
+ end
19
+ end
@@ -0,0 +1,57 @@
1
+ # BUILD IMAGE
2
+ FROM ruby:<%= Modulorails.data.ruby_version %>-alpine as builder
3
+
4
+ ENV RAILS_ENV=production
5
+ WORKDIR /app
6
+
7
+ RUN apk add --update --no-cache \
8
+ alpine-sdk \
9
+ nodejs \
10
+ tzdata \
11
+ yarn \
12
+ shared-mime-info \
13
+ <%- adapter = Modulorails.data.adapter -%>
14
+ <%- if adapter =~ /mysql/ -%>
15
+ mysql-dev
16
+ <%- else -%>
17
+ postgresql-dev
18
+ <%- end -%>
19
+ RUN gem install bundler -v <%= Modulorails.data.bundler_version %>
20
+
21
+ COPY Gemfile Gemfile.lock ./
22
+ RUN bundle check || bundle install --deployment --jobs=2 \
23
+ && rm -rf vendor/bundle/ruby/*/cache/*
24
+
25
+ COPY package.json yarn.lock ./
26
+ RUN yarn install
27
+
28
+ COPY . .
29
+ RUN bundle exec rake assets:precompile
30
+
31
+ # FINAL IMAGE
32
+ FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
33
+
34
+ WORKDIR /app
35
+
36
+ RUN apk add --update --no-cache \
37
+ curl \
38
+ git \
39
+ nodejs \
40
+ tzdata \
41
+ shared-mime-info \
42
+ <%- adapter = Modulorails.data.adapter -%>
43
+ <%- if adapter =~ /mysql/ -%>
44
+ mysql-dev \
45
+ <%- else -%>
46
+ postgresql-dev \
47
+ <%- end -%>
48
+ && rm -rf .git/
49
+
50
+ COPY --from=builder /app .
51
+
52
+ RUN bundle config --local path vendor/bundle \
53
+ && bundle config --local without development:test:assets
54
+
55
+ EXPOSE 3000
56
+
57
+ ENTRYPOINT ["./entrypoints/docker-entrypoint.sh"]
@@ -0,0 +1,26 @@
1
+ FROM ruby:<%= Modulorails.data.ruby_version %>-alpine
2
+
3
+ ENV RAILS_ENV=development
4
+ WORKDIR /app
5
+
6
+ RUN apk add --update --no-cache \
7
+ alpine-sdk \
8
+ nodejs \
9
+ yarn \
10
+ tzdata \
11
+ <%- adapter = Modulorails.data.adapter -%>
12
+ <%- if adapter =~ /mysql/ -%>
13
+ mysql-dev
14
+ <%- else -%>
15
+ postgresql-dev
16
+ <%- end -%>
17
+ RUN gem install bundler -v <%= Modulorails.data.bundler_version %>
18
+
19
+ COPY Gemfile Gemfile.lock ./
20
+ RUN bundle install --jobs=2
21
+
22
+ COPY . .
23
+
24
+ EXPOSE 3000
25
+
26
+ ENTRYPOINT ["./entrypoints/docker-entrypoint.sh"]