dockerfile-rails 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5146ba972235a473c3018799f3b75bc7856dad4c7c1e1b34a9fc0e87aa0de196
4
- data.tar.gz: f9848a9d5103550a9fe7e1be7ee3820d4f99cee50ec39cc53933f568ffe29357
3
+ metadata.gz: 90f5f36199b97da2a9a8cb8d787970846a8b50c17d68cd8192e335684d80dfd2
4
+ data.tar.gz: dc1106eb805b3d1640cc2fb7bbf292e512209f33367a91ba563e781fbca6e1f8
5
5
  SHA512:
6
- metadata.gz: 14b6231959a35395703f0019a2c4e38062dd6b8d37d2c5c936dad2920c120118f7c95ad80a4c4d6591449bc2c79fc86c4ffd35bf3ac107ca6894291906ddd23b
7
- data.tar.gz: d62ba6ea16c3705de8bc1606d8c1adbca6c91e591ff949d0d132f7f47b315662cc2659919a25febe9628dce5b7a9c34e5215dba0081b79525f6dae99b0fe4c3b
6
+ metadata.gz: 7bf221c15c7041792a736296d90732949bd31c27b660a06fc0ee743cf295516b0db874be835e7263c57836df8b748cb73548264b92aeb6383327226e513a3d38
7
+ data.tar.gz: abb6c6468353f3ea793d145c503e807ba301f752d227fec8406040989e303d1ad60372758fac3bc7a053f56f01bbf378197302710e6587ad9aac334816c1db5c
data/DEMO.md CHANGED
@@ -10,10 +10,12 @@ cd welcome
10
10
  echo 'Rails.application.routes.draw { root "rails/welcome#index" }' > config/routes.rb
11
11
  bundle add dockerfile-rails --group development
12
12
  bin/rails generate dockerfile
13
- docker buildx build . -t rails-welcome # add --load to save the image to local Docker
13
+ docker buildx build . -t rails-welcome
14
14
  docker run -p 3000:3000 -e RAILS_MASTER_KEY=$(cat config/master.key) rails-welcome
15
15
  ```
16
16
 
17
+ Add `--load` to the `buildx` command if you want to save the image to local Docker.
18
+
17
19
  # Demo 2 - Action Cable and Active Record
18
20
 
19
21
  Real applications involve a network of services. The following demo makes use of PostgreSQL and Redis to display a welcome screen with a live, updating, visitors counter. Once done, take a look at the `docker-compose.yml` file produced.
@@ -101,7 +103,7 @@ node moddules and ruby gems in parallel.
101
103
  ```bash
102
104
  rails new welcome --api
103
105
  cd welcome
104
- npx create-react-app client
106
+ npx -y create-react-app client
105
107
 
106
108
  bin/rails generate controller Api versions
107
109
 
data/README.md CHANGED
@@ -4,6 +4,7 @@ Provides a Rails generator to produce Dockerfiles and related files. This is be
4
4
 
5
5
  * Supports all [Rails supported releases](https://guides.rubyonrails.org/maintenance_policy.html), not just Rails 7.1, and likely works with a number of previous releases.
6
6
  * Can be customized using flags on the `generate dockerfile` command, and rerun to produce a custom tailored dockerfile based on detecting the actual features used by your application.
7
+ * Will set `.node_version`, `packageManager` and install gems if needed to deploy your application.
7
8
  * Can produce a `docker-compose.yml` file for locally testing your configuration before deploying.
8
9
 
9
10
  ## Usage
@@ -87,6 +87,8 @@ class DockerfileGenerator < Rails::Generators::Base
87
87
 
88
88
  scan_rails_app
89
89
 
90
+ Bundler.with_original_env { install_gems }
91
+
90
92
  template 'Dockerfile.erb', 'Dockerfile'
91
93
  template 'dockerignore.erb', '.dockerignore'
92
94
 
@@ -97,7 +99,7 @@ class DockerfileGenerator < Rails::Generators::Base
97
99
 
98
100
  template 'docker-compose.yml.erb', 'docker-compose.yml' if options.compose
99
101
 
100
- template 'dockerfile.yml.erb', 'config/dockerfile.yml'
102
+ template 'dockerfile.yml.erb', 'config/dockerfile.yml', force: true
101
103
  end
102
104
 
103
105
  private
@@ -156,6 +158,20 @@ private
156
158
  @keeps = !Dir['**/.keep']
157
159
  end
158
160
 
161
+ def install_gems
162
+ if options.postgresql? or @postgresql
163
+ system "bundle add pg" unless @gemfile.include? 'pg'
164
+ end
165
+
166
+ if options.mysql? or @mysql
167
+ system "bundle add mysql2" unless @gemfile.include? 'mysql2'
168
+ end
169
+
170
+ if options.redis? or using_redis?
171
+ system "bundle add redis" unless @gemfile.include? 'redis'
172
+ end
173
+ end
174
+
159
175
  def build_packages
160
176
  # start with the essentials
161
177
  packages = %w(build-essential)
@@ -163,13 +179,13 @@ private
163
179
  # add databases: sqlite3, postgres, mysql
164
180
  packages << 'pkg-config' if options.sqlite3? or @sqlite3
165
181
  packages << 'libpq-dev' if options.postgresql? or @postgresql
166
- packages << 'default-libmysqlclient-dev' if options.mysql or @mysql
182
+ packages << 'default-libmysqlclient-dev' if options.mysql? or @mysql
167
183
 
168
184
  # add git if needed to install gems
169
185
  packages << 'git' if @git
170
186
 
171
187
  # add redis in case Action Cable, caching, or sidekiq are added later
172
- packages << "redis" if using_redis?
188
+ packages << "redis" if options.redis? or using_redis?
173
189
 
174
190
  # ActiveStorage preview support
175
191
  packages << "libvips" if @gemfile.include? 'ruby-vips'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerfile-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-26 00:00:00.000000000 Z
11
+ date: 2023-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails