dockerfile-rails 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/generators/dockerfile_generator.rb +19 -2
- data/lib/generators/templates/Dockerfile.erb +40 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b317d73db1dda4043a0cf7ad8bc237cc909cf6fe08550960e57190651fe15f5a
|
4
|
+
data.tar.gz: 15454b9d5fee80e253dff57fe4f708f9e2c0bc729a1c1b506e2e96a7f1c13666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff075f1ab57a0a7bf5a6f084bc8c552f5a9a4b2e16a9452fec6d07b5f245dd7e8cc56e74d447af3083906926747fb868e0a76a99da8f0cba20c61273fd7f7010
|
7
|
+
data.tar.gz: c6306db9e351812343158cad19c59da387889f1fb449006e73806329d8b375d3ff8534e9f4c358c9b34368f1ea9e98d3e0b23d5833067477ccf6a68fe744bf9b
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Provide Rails generators to produce Dockerfiles and related files.
|
|
5
5
|
## Usage
|
6
6
|
|
7
7
|
```
|
8
|
-
bundle add dockerfile-rails
|
8
|
+
bundle add dockerfile-rails --group development
|
9
9
|
bin/rails generate dockerfile
|
10
10
|
```
|
11
11
|
|
@@ -26,4 +26,10 @@ additional support may be needed:
|
|
26
26
|
* `--mysql` - add mysql libraries
|
27
27
|
* `--posgresql` - add posgresql libraries
|
28
28
|
* `--redis` - add redis libraries
|
29
|
-
* `--sqlite3` - add sqlite3 libraries
|
29
|
+
* `--sqlite3` - add sqlite3 libraries
|
30
|
+
|
31
|
+
Links:
|
32
|
+
|
33
|
+
* [Demos](./DEMO.md)
|
34
|
+
* [Preparations for Rails 7.1](https://community.fly.io/t/preparations-for-rails-7-1/9512)
|
35
|
+
* [Rails Dockerfile futures](https://discuss.rubyonrails.org/t/rails-dockerfile-futures/82091/1)
|
@@ -163,13 +163,13 @@ private
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def node_version
|
166
|
-
|
166
|
+
`node --version`[/\d+\.\d+\.\d+/]
|
167
167
|
rescue
|
168
168
|
"lts"
|
169
169
|
end
|
170
170
|
|
171
171
|
def yarn_version
|
172
|
-
|
172
|
+
`yarn --version`[/\d+\.\d+\.\d+/]
|
173
173
|
rescue
|
174
174
|
"latest"
|
175
175
|
end
|
@@ -182,6 +182,23 @@ private
|
|
182
182
|
Rails.application.config.api_only
|
183
183
|
end
|
184
184
|
|
185
|
+
def api_client_dir
|
186
|
+
return unless api_only?
|
187
|
+
|
188
|
+
file = Dir['*/package.json'].find do |file|
|
189
|
+
JSON.load_file(file).dig('scripts', 'build')
|
190
|
+
end
|
191
|
+
|
192
|
+
file && File.dirname(file)
|
193
|
+
end
|
194
|
+
|
195
|
+
def api_client_files
|
196
|
+
client = api_client_dir
|
197
|
+
return unless client
|
198
|
+
|
199
|
+
Dir["#{client}/{package.json,package-lock.json,yarn.lock}"]
|
200
|
+
end
|
201
|
+
|
185
202
|
def dbprep_command
|
186
203
|
if Rails::VERSION::MAJOR >= 6
|
187
204
|
'db:prepare'
|
@@ -1,7 +1,40 @@
|
|
1
1
|
# syntax = docker/dockerfile:1
|
2
2
|
|
3
|
-
# Make sure
|
3
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
4
4
|
ARG RUBY_VERSION=<%= Gem.ruby_version %>
|
5
|
+
<% if api_client_dir -%>
|
6
|
+
ARG NODE_VERSION=<%= node_version %>
|
7
|
+
|
8
|
+
FROM node:$NODE_VERSION-slim as client
|
9
|
+
|
10
|
+
WORKDIR /rails/<%= api_client_dir %>
|
11
|
+
|
12
|
+
ENV NODE_ENV=production
|
13
|
+
|
14
|
+
# Install node modules
|
15
|
+
COPY <%= api_client_files.join(' ') %> .
|
16
|
+
<% if api_client_files.join.include? 'yarn' -%>
|
17
|
+
<% if options.cache? -%>
|
18
|
+
RUN --mount=type=cache,id=bld-yarn-cache,target=/root/.yarn \
|
19
|
+
YARN_CACHE_FOLDER=/root/.yarn yarn install
|
20
|
+
<% else -%>
|
21
|
+
RUN yarn install
|
22
|
+
<% end -%>
|
23
|
+
<% else -%>
|
24
|
+
<% if options.cache? -%>
|
25
|
+
RUN --mount=type=cache,id=bld-yarn-cache,target=/root/.npm \
|
26
|
+
npm install
|
27
|
+
<% else -%>
|
28
|
+
RUN npm install
|
29
|
+
<% end -%>
|
30
|
+
<% end -%>
|
31
|
+
|
32
|
+
# build client application
|
33
|
+
COPY <%= api_client_dir %> .
|
34
|
+
RUN npm run build
|
35
|
+
|
36
|
+
|
37
|
+
<% end -%>
|
5
38
|
FROM ruby:$RUBY_VERSION-slim as base
|
6
39
|
|
7
40
|
# Rails app lives here
|
@@ -122,11 +155,16 @@ RUN apt-get update -qq && \
|
|
122
155
|
<% end -%>
|
123
156
|
<% end -%>
|
124
157
|
|
125
|
-
# Copy built application from
|
158
|
+
# Copy built application from previous stage
|
126
159
|
<% if options.ci? -%>
|
127
160
|
COPY --from=build /usr/local/bundle /usr/local/bundle
|
128
161
|
<% end -%>
|
129
162
|
COPY --from=build /rails /rails
|
163
|
+
<% if api_client_dir -%>
|
164
|
+
|
165
|
+
# Copy built client
|
166
|
+
COPY --from=client /rails/<%= api_client_dir %>/build /rails/public
|
167
|
+
<% end -%>
|
130
168
|
|
131
169
|
# Deployment options
|
132
170
|
ENV RAILS_LOG_TO_STDOUT="1" \
|
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2023-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|