Mix dependency errors when releasing an app inside an Umbrella app

Say I have 3 apps inside an umbrella app where hello_app and world_app may be independently deployed:

umbrella_project
  /hello_app
  /world_app
  /shared

I want to release hello_app, but I have the following errors when the Dockerfile reaches this line:

RUN MIX_ENV=prod mix release hello_app_release

Unchecked dependencies for environment prod:

  • foo_dependency (Hex package)
    the dependency is not available, run “mix deps.get”
  • bar_dependency (Hex package)
    the dependency is not available, run “mix deps.get”
    ** (Mix) Can’t continue due to errors on dependencies

And indeed these 2 dependencies are not listed in the hello_app mix file. These are dependencies that only world_app is using.

These 2 dependencies will always be listed in the mix.lock file though because we have only a single mix.lock file in an umbrella app. Could that be the reason for this error?

Here is the Dockerfile:

# First stage: build the release
FROM elixir:1.15-alpine as releaser

ENV MIX_ENV=prod
ENV HEX_HTTP_TIMEOUT=120
ARG app_name
WORKDIR /app

RUN mix do local.hex --force, local.rebar --force

COPY config/ ./config/
COPY mix.exs mix.lock ./
COPY apps/shared/mix.exs apps/shared/
COPY apps/${app_name}/mix.exs apps/${app_name}/

RUN mix do deps.get --only prod, deps.compile

COPY . .

RUN MIX_ENV=prod mix release ${app_name}_release

# Second stage: create the final image
FROM erlang:26-alpine

ARG app_name
WORKDIR /app

COPY --from=releaser /app/_build/prod/rel/${app_name}_release .

CMD ["./bin/start"]

Where the variable app_name can take for instance the value hello_app.

Note that without Docker I can run set "MIX_ENV=prod" && mix release hello_app_release without errors.

Any help is appreciated!