lib/generators/templates/Dockerfile.erb in dockerfile-rails-1.0.17 vs lib/generators/templates/Dockerfile.erb in dockerfile-rails-1.0.18
- old
+ new
@@ -123,10 +123,15 @@
# Final stage for app image
FROM base
<% end -%>
+<% unless run_as_root? -%>
+# add a non-root user
+RUN useradd rails
+
+<% end -%>
<% unless deploy_packages.empty? -%>
# Install packages needed for deployment
<%= render partial: 'apt_install', locals: {packages: deploy_packages, clean: true, repos: deploy_repos} %>
<% end -%>
@@ -137,14 +142,14 @@
RUN gem install foreman
<% end -%>
<% unless options.precompile == "defer" -%>
# Copy built application from previous stage
-COPY --from=build /rails /rails
+COPY --from=build <% unless run_as_root? %>--chown=rails:rails <% end %>/rails /rails
<% if api_client_dir -%>
# Copy built client
-COPY --from=client /rails/<%= api_client_dir %>/build /rails/public
+COPY --from=client <% unless run_as_root? %>--chown=rails:rails <% end %>/rails/<%= api_client_dir %>/build /rails/public
<% end -%>
<% end -%>
<% unless deploy_env.empty? -%>
# Deployment options