Closed froy001 closed 5 years ago
I want to add the core
app mix.exs since it might be relevant, as the core
application is dependent on all the umbrella applications. One issue could be that distillery 2.0 is somehow ignoring the only:
flag.:
defmodule Core.MixProject do
use Mix.Project
def project do
[
app: :core,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps()
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_env), do: ["lib"]
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger, :sentry],
mod: {Core.Application, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:quantum, "~> 2.3"},
{:sentry, "~> 6.4"},
{:dealor_data_layer, in_umbrella: true},
{:mqtt_manager, in_umbrella: true},
{:httpoison, "~> 1.4"},
{:device_cache, in_umbrella: true, only: [:test, :dev]}
]
end
end
https://github.com/syfgkjasdkn/distillery_601 seems to be able to reproduce it.
Two releases that shouldn't depend on each other
release :service1 do
set(version: "0.1.0")
set(
applications: [
:runtime_tools,
core: :permanent
]
)
end
release :service2 do
set(version: "0.1.0")
set(
applications: [
:runtime_tools,
non_prod_dep: :permanent
]
)
end
other than in [:dev, :test]
:
# in core's mix
defp deps do
[
{:non_prod_dep, in_umbrella: true, only: [:test, :dev]}
]
end
when running MIX_ENV=prod mix release --verbose --env=prod --name=service1
produce
...
> non_prod_dep-0.1.0
|
| from: _build/prod/lib/non_prod_dep
| applications:
| :kernel
| :stdlib
| :elixir
| :logger
| includes: none
|_____
...
@josevalim I think this may be an issue with Mix; using the sample project from @syfgkjasdkn, if you pop open a shell, you'll see that in Application.spec(:core)
the application list contains the :non_prod_dep
application, even though it shouldn't be available in the prod environment. Thoughts?
I believe it is caused by this issue: https://github.com/elixir-lang/elixir/issues/8225
You can try Elixir master or wait for Elixir v1.8-rc which should be out this week and you will be able to try it out to see if it solves your problem.
@josevalim Thanks!
@froy001 @syfgkjasdkn I'm going to close this issue since it appears that a resolution is pending release; there is not much I can do in the near term. As a possible workaround, you could use conditional compilation to define two different dependency lists, one without the umbrella deps you are trying to exclude, and a normal one; this should prevent that dependency from showing up in the applications list, though there may be some exceptions to the rule.
@bitwalker just tried https://github.com/syfgkjasdkn/distillery_601 again with elixir 1.8, and it seems the issue has indeed been resolved.
As for those on elixir < 1.8, the workaround https://github.com/syfgkjasdkn/distillery_601/commit/9c09f80c18e6202dea01d661b7212f5118b62508 worked as well, but it sometimes caused problems on CI such that running mix deps.get
didn't get deps for test env (obviously, since those were excluded completely from the deps list) and I had to run MIX_ENV=test mix deps.get
additionally.
Steps to reproduce
Just a brief list of the steps required to produce the issue.
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):Description of issue
I am releasing an Umbrella app with the following structure: apps/ ├── core ├── dealor_api_gateway ├── dealor_data_layer ├── device_cache ├── mqtt_manager ├── ota_manager └── _utils As you can see in the rel/config.exs I have 2 releases. When releasing
iot_system
distillery includes and deploysdevice_cache
which is not included in theapplication
list. The same rel/config works as expected with distillery 1.5.device_cache
rel/config.exs
, as it is often my first troubleshooting question, and you'll save us both time :)use Mix.Releases.Config,
This sets the default release built by
mix release
For a full list of config options for both releases
and environments, visit https://hexdocs.pm/distillery/configuration.html
You may define one or more environments in this file,
an environment's settings will override those of a release
when building in that environment, this combination of release
and environment configuration is called a profile
environment :dev do
If you are running Phoenix, you should make sure that
server: true is set and the code reloader is disabled,
even in dev mode.
It is recommended that you build with MIX_ENV=prod and pass
the --env flag to Distillery explicitly if you want to use
dev mode.
set dev_mode: true set include_erts: false set cookie: :"foo" end
environment :prod do set include_erts: false set include_src: false set cookie: :"bar" end
You may define one or more releases in this file.
If you have not set a default release, or selected one
when running
mix release
, the first release in the filewill be used by default
release :iot_system do set version: "0.61.4" set applications: [ :runtime_tools, dealor_api_gateway: :permanent, dealor_data_layer: :permanent, mqtt_manager: :permanent, ota_manager: :permanent, core: :permanent, _utils: :permanent, canada: :load ] set vm_args: "rel/vm.args" set pre_start_hooks: "rel/hooks/pre_start" set commands: [ "setup_db": "apps/dealor_data_layer/rel/commands/setup_db.sh", "seed": "apps/dealor_data_layer/rel/commands/seed.sh" ] end
release :device_cache do set version: "0.1.0"
set applications: [ :runtime_tools, device_cache: :permanent, mqtt_manager: :permanent ]
set vm_args: "rel/vm.args" end