Reputation: 2554
I have 3 umbrella projects:
I have the following config in root mix.exs
:
releases: [
web: [
applications: [web_project: :permanent]
],
api: [
applications: [rest_api_project: :permanent]
]
]
The problem is that every time I run mix release release_name
the runtime config is loaded from the root project, not from the projects specified.
I even tried to load other configs the following way:
for config <- "../apps/*/config/releases.exs" |> Path.expand(__DIR__) |> Path.wildcard() do
import_config config
end
However it doesn't seem to work, it is using the compile-time config.
Upvotes: 1
Views: 669
Reputation: 2554
I have chosen to take a different path, since overlays don't provide any flexibility to using steps
:
web: [
applications: [my_app: :permanent],
config_providers: [
{Config.Reader, {:system, "RELEASE_ROOT", "apps/my_app/config/releases.exs"}},
{Config.Reader, {:system, "RELEASE_ROOT", "apps/another_app/config/releases.exs"}},
],
steps: [:assemble, ©_configs/1]
]
This way I can extract the path
and config_providers
and move them to the releases folder:
defp copy_configs(%{path: path, config_providers: config_providers} = release) do
for {_module, {_context, _root, file_path}} <- config_providers do
# Creating new path
new_path = path <> Path.dirname(file_path)
# Removing possible leftover files from previous builds
File.rm_rf!(new_path)
# Creating directory if it doesn't exist
File.mkdir_p!(new_path)
# Copying files to the directory with the same name
File.cp!(Path.expand(file_path), new_path <> "/" <> Path.basename(file_path))
end
release
end
Upvotes: 2
Reputation: 2554
After finding a similar issue opened, the proposed solution by José Valim is to use overlays. The only problem currently with overlays is that you can only point at a specific folder, opposite to the flexibility you have with Disitllery Overlays.
The final solution is the following:
releases: [
web: [
applications: [my_app: :permanent],
config_providers: [{Config.Reader, {:system, "RELEASE_ROOT", "/releases.exs"}}],
overlays: "apps/my_app/config"
]
]
Upvotes: 1