bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.97k stars 402 forks source link

RFC: Do not dereference symlinks when archiving release #533

Open argl opened 6 years ago

argl commented 6 years ago

Steps to reproduce

A config provider configured like this:

set config_providers: [
  {Mix.Releases.Config.Providers.Elixir, ["${RELEASE_ROOT_DIR}/config.exs"]}
]
set overlays: [
  {:link, "/etc/appconfig/config", "config.exs"}
]

I would expect that the unpacked release has a symlink config.exs->/etc/appconfig/config

Alas, I end up with a normal file (no symlink) at config.exs

Verbose Logs

Paste the output of the release command you ran with the --verbose flag below in the summary tags (this helps keep the issue easy to navigate):

``` ... ==> Applying link overlay src: /etc/appconfig/config.exs dst: config.exs ... ```

Description of issue

It seems that along the way of building/packaging the symlink information gets lost? Probably somewhere down :systools.make_tar it dereferences all symlinks it includes in that tarball?

For an overlay :link I think it also should not matter if the file the link points to is present at build time or not. But maybe this is intentionally enforced by the mighty erlang release tools. With the current behaviour, I can see no difference between :copy or :link overlays.

Disclaimer

I probably did not understand correctly how the overlay link stuff is supposed to work, documentation seems a bit sparse on that matter. So apologies for any blindness on my part. Distillery is exceptional work!

bitwalker commented 6 years ago

This behavior was intentional, but we can probably remove the :dereference option when building the tarball, I can't recall if that was added for a specific reason or not. I will make this a TODO and test it out to see if there are any issues, and if not, make it part of the next release.

salsa-dev commented 5 years ago

@bitwalker it could be usefull indeed! My use case is to create a link releases/current to the currently build release.

  set overlays: [
    {:link, "<%= release_version %>", "releases/current"}
  ]

For now it doesn't work as expected because the link is dereferenced during tarball creation making copy of the referenced directory in the tarball.