lib/cide/dockerfile_template.erb in cide-0.2.0 vs lib/cide/dockerfile_template.erb in cide-0.4.0
- old
+ new
@@ -2,44 +2,56 @@
USER root
RUN useradd -m -U -d <%= CIDE_DIR %> cide
# Install system build dependencies here
-<% as_root.each do |cmd| -%>
+<% if as_root -%>
+ <% as_root.add.each do |file| -%>
+ADD <%= file.src.join(' ') %> <%= file.dest %>
+ <% end -%>
+ <% as_root.env.each_pair do |key, value| -%>
+ENV <%= key %> <%= value %>
+ <% end -%>
+ <% as_root.run.each do |cmd| -%>
RUN <%= cmd %>
+ <% end -%>
<% end -%>
# Common
ENV HOME <%= CIDE_DIR %>
WORKDIR <%= CIDE_SRC_DIR %>
# SSH config
+
<% if use_ssh -%>
-ADD ssh_config <%= File.expand_path('config', CIDE_SSH_DIR) %>
-RUN chmod 400 <%= File.expand_path('config', CIDE_SSH_DIR) %>
+RUN mkdir <%= CIDE_SSH_DIR %>
+RUN echo StrictHostKeyChecking no > <%= File.join(CIDE_SSH_DIR, 'config') %>
+RUN chmod 400 <%= File.join(CIDE_SSH_DIR, 'config') %>
-ADD <%= TEMP_SSH_KEY %> <%= File.expand_path('id_rsa', CIDE_SSH_DIR) %>
+ADD <%= TEMP_SSH_KEY %> <%= File.join(CIDE_SSH_DIR, 'id_rsa') %>
RUN chmod 400 <%= File.expand_path('id_rsa', CIDE_SSH_DIR) %>
-RUN chmod 755 <%= CIDE_SSH_DIR %>
RUN chown -R cide:cide <%= CIDE_DIR %>
-<% end %>
+<% end -%>
# Before
<% if before -%>
- <% before.forward_env.each do |key| -%>
-ENV <%= key %> <%= ENV[key] %>
- <% end %>
<% before.add.each do |file| -%>
-ADD <%= file %> <%= File.expand_path(file, CIDE_SRC_DIR) %>
+ADD <%= file.src.join(' ') %> <%= file.dest %>
<% end %>
RUN chown -R cide:cide <%= CIDE_DIR %>
+ <% before.env.each_pair do |key, value| -%>
+ENV <%= key %> <%= value %>
+ <% end %>
USER cide
-RUN <%= before.run %>
-USER root
+ <% before.run.each do |cmd| -%>
+RUN <%= cmd %>
+ <% end %>
<% end -%>
# Add project data
+USER root
ADD . <%= CIDE_SRC_DIR %>
RUN chown -R cide:cide <%= CIDE_DIR %>
+USER cide