@@ -57,6 +57,11 @@ defmodule MixDocker do
5757 publish ( args )
5858 end
5959
60+ def customize ( [ ] ) do
61+ try_copy_dockerfile @ dockerfile_build
62+ try_copy_dockerfile @ dockerfile_release
63+ end
64+
6065 defp git_head_sha do
6166 { sha , 0 } = System . cmd "git" , [ "rev-parse" , "HEAD" ]
6267 String . slice ( sha , 0 , 10 )
@@ -109,26 +114,36 @@ defmodule MixDocker do
109114 system! "docker" , [ "push" , image ]
110115 end
111116
112-
113117 defp with_dockerfile ( name , fun ) do
114118 if File . exists? ( name ) do
115119 fun . ( )
116120 else
117- app = Mix.Project . get . project [ :app ]
118-
119121 try do
120- content = [ @ dockerfile_path , name ]
121- |> Path . join
122- |> File . read!
123- |> String . replace ( "${APP}" , to_string ( app ) )
124- File . write! ( name , content )
122+ copy_dockerfile ( name )
125123 fun . ( )
126124 after
127125 File . rm ( name )
128126 end
129127 end
130128 end
131129
130+ defp copy_dockerfile ( name ) do
131+ app = Mix.Project . get . project [ :app ]
132+ content = [ @ dockerfile_path , name ]
133+ |> Path . join
134+ |> File . read!
135+ |> String . replace ( "${APP}" , to_string ( app ) )
136+ File . write! ( name , content )
137+ end
138+
139+ defp try_copy_dockerfile ( name ) do
140+ if File . exists? ( name ) do
141+ Logger . warn ( "#{ name } already exists" )
142+ else
143+ copy_dockerfile ( name )
144+ end
145+ end
146+
132147 defp system ( cmd , args ) do
133148 Logger . debug "$ #{ cmd } #{ args |> Enum . join ( " " ) } "
134149 System . cmd ( cmd , args , into: IO . stream ( :stdio , :line ) )
0 commit comments