dockerfile-rails 1.0.18 → 1.1.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.
@@ -22,10 +22,13 @@ LABEL <%= key =~ /^\w[.\w]*$/ ? key : key.inspect %>=<%= value.inspect %>
22
22
  # Rails app lives here
23
23
  WORKDIR /rails
24
24
 
25
+ <% unless base_args.empty? -%>
26
+ # Base build arguments
27
+ ARG <%= base_args.map {|key, value| "#{key}=#{value.inspect}"}.join(" \\\n ") %>
28
+
29
+ <% end -%>
25
30
  # Set production environment
26
- ENV RAILS_ENV="production" \
27
- BUNDLE_PATH="vendor/bundle" \
28
- BUNDLE_WITHOUT="<%= options.ci? ? 'development' : 'development:test' %>"
31
+ ENV <%= base_env.join(" \\\n ") %>
29
32
 
30
33
  # Update gems and preinstall the desired version of bundler
31
34
  ARG BUNDLER_VERSION=<%= Bundler::VERSION %>
@@ -68,6 +71,16 @@ FROM prebuild as node
68
71
 
69
72
  FROM prebuild as build
70
73
 
74
+ <% end -%>
75
+ <% unless build_args.empty? -%>
76
+ # Build arguments
77
+ ARG <%= build_args.map {|key, value| "#{key}=#{value.inspect}"}.join(" \\\n ") %>
78
+
79
+ <% end -%>
80
+ <% unless build_env.empty? -%>
81
+ # Deployment options
82
+ ENV <%= build_env.join(" \\\n ") %>
83
+
71
84
  <% end -%>
72
85
  # Install application gems
73
86
  COPY Gemfile Gemfile.lock ./
@@ -125,9 +138,9 @@ RUN SECRET_KEY_BASE<%= Rails::VERSION::MAJOR<7 || Rails::VERSION::STRING.start_w
125
138
  FROM base
126
139
 
127
140
  <% end -%>
128
- <% unless run_as_root? -%>
129
- # add a non-root user
130
- RUN useradd rails
141
+ <% unless deploy_args.empty? -%>
142
+ # Deployment build arguments
143
+ ARG <%= deploy_args.map {|key, value| "#{key}=#{value.inspect}"}.join(" \\\n ") %>
131
144
 
132
145
  <% end -%>
133
146
  <% unless deploy_packages.empty? -%>
@@ -141,6 +154,19 @@ RUN useradd rails
141
154
  <% elsif procfile.size > 1 -%>
142
155
  RUN gem install foreman
143
156
 
157
+ <% end -%>
158
+ <% unless run_as_root? -%>
159
+ # # Run and own the application files as a non-root user for security
160
+ <% if options.compose? -%>
161
+ ARG UID=1000 \
162
+ GID=1000
163
+ RUN groupadd -f -g $GID rails && \
164
+ useradd -u $UID -g $GID rails
165
+ <% else -%>
166
+ RUN useradd rails
167
+ <% end -%>
168
+ USER rails
169
+
144
170
  <% end -%>
145
171
  <% unless options.precompile == "defer" -%>
146
172
  # Copy built application from previous stage
@@ -1,7 +1,16 @@
1
1
  version: "3.8"
2
2
  services:
3
3
  web:
4
+ <% if all_args.empty? -%>
4
5
  build: .
6
+ <% else -%>
7
+ build:
8
+ context: .
9
+ args:
10
+ <% all_args.each do |name, value| -%>
11
+ <%= name %>: <%= value.html_safe? ? value : "\"#{Shellwords.escape(value)}\"" %>
12
+ <% end -%>
13
+ <% end -%>
5
14
  ports:
6
15
  - "3000:3000"
7
16
  environment:
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: 1.0.18
4
+ version: 1.1.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-02-16 00:00:00.000000000 Z
11
+ date: 2023-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -32,6 +32,7 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - DEMO.md
34
34
  - MIT-LICENSE
35
+ - MOTIVATION.md
35
36
  - README.md
36
37
  - Rakefile
37
38
  - lib/dockerfile-rails.rb