File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -197,17 +197,28 @@ defmodule Terrarium.Runtime do
197197 String . starts_with? ( p , otp_lib ) or String . starts_with? ( p , elixir_lib )
198198 end )
199199
200- # Deploy entire app directories (app-version/) to preserve the ebin/priv structure.
201- # This allows Application.app_dir/1 to find priv/ directories on the remote.
200+ # Deploy entire app directories to preserve the ebin/priv structure.
201+ # Group by parent directory so each -C is followed by all its basenames,
202+ # avoiding the issue where repeated -C to the same parent causes tar to
203+ # only include the last basename.
202204 app_dirs =
203205 ebin_paths
204206 |> Enum . map ( & Path . dirname / 1 )
207+ |> Enum . reject ( & ( & 1 == "." ) )
205208 |> Enum . uniq ( )
206209
210+ grouped =
211+ app_dirs
212+ |> Enum . group_by ( & Path . dirname / 1 , & Path . basename / 1 )
213+
207214 Logger . debug ( "Creating tarball from #{ length ( app_dirs ) } app dirs" , sandbox_id: sandbox . id )
208215
209216 tarball_path = Path . join ( System . tmp_dir! ( ) , "terrarium_deploy_#{ System . unique_integer ( [ :positive ] ) } .tar.gz" )
210- file_args = Enum . flat_map ( app_dirs , fn dir -> [ "-C" , Path . dirname ( dir ) , Path . basename ( dir ) ] end )
217+
218+ file_args =
219+ Enum . flat_map ( grouped , fn { parent , basenames } ->
220+ [ "-C" , parent | basenames ]
221+ end )
211222
212223 try do
213224 case System . cmd ( "tar" , [ "czf" , tarball_path | file_args ] , stderr_to_stdout: true ) do
You can’t perform that action at this time.
0 commit comments