Merge branch '1578-api-server-in-docker' of git.clinicalfuture.com:arvados into 1578...
[arvados.git] / docker / config.rb
index 9a4a4197a9745832107a349a5b2554f563d045f2..793a6ff35d6c784d667b6e0239b49624100a0dbc 100755 (executable)
@@ -31,10 +31,21 @@ end
 # For each *.in file in the docker directories, substitute any
 # @@variables@@ found in the file with the appropriate config
 # variable. Support up to 10 levels of nesting.
+# 
+# TODO(twp): add the *.in files directory to the source tree, and
+# when expanding them, add them to the "generated" directory with
+# the same tree structure as in the original source. Then all
+# the files can be added to the docker container with a single ADD.
+
+Dir.glob('*/generated/*') do |stale_file|
+  File.delete(stale_file)
+end
 
 Dir.glob('*/*.in') do |template_file|
-  output_path = template_file.sub(/\.in$/, '')
-  output = File.open(output_path, 'w')
+  generated_dir = File.join(File.dirname(template_file), 'generated')
+  Dir.mkdir(generated_dir) unless Dir.exists? generated_dir
+  output_path = File.join(generated_dir, File.basename(template_file, '.in'))
+  output = File.open(output_path, "w")
   File.open(template_file) do |input|
     input.each_line do |line|