mix_docker icon indicating copy to clipboard operation
mix_docker copied to clipboard

Umbrella App mix docker.build and mix docker.release each sub-app using separate Dockerfile.build.sub_app<N> and Dockerfile.release.sub_app<N>

Open yeongsheng-tan opened this issue 7 years ago • 2 comments

I have a top level umbrella_app with 2 sub-apps: sub_app1 and sub_app2. I would like to carry out mix docker.build and mix docker.release for each sub-app separately, each using a different Dockerfile.build.sub_app1, Dockerfile.build.sub_app2 and Dockerfile.release.sub_app1 and Dockerfile.release.sub_app2.

In each of the Dockerfile.build.sub_app1 and Dockerfile.build.sub_app2, I would like to invoke a different mix release --profile=<sub_app>:prod

How could this be achieved? Is this a correct practice?

I managed to do so by creating custom Dockerfile.build for each sub-app within which I invoke mix release --profile=<sub_app>:prod by editing my umbrella project config/config.exs config section as such:

# config :mix_docker,
#   image: "app/sub_app1",
#   dockerfile_build: "./Dockerfile.build.sub_app1",
#   dockerfile_release: "./Dockerfile.release.sub_app1"

config :mix_docker,
  image: "app/sub_app2",
  dockerfile_build: "./Dockerfile.build.sub_app2",
  dockerfile_release: "./Dockerfile.release.sub_app2"

I then manually edit and toggle on/off each section as I trigger mix docker.build for each case.

==> Writing tarball to _build/prod/rel/sub_app1/releases/<version>/sub_app1.tar.gz
==> Updating tarball
==> Tarball updated!
==> Release successfully built!
    You can run it in one of the following ways:
      Interactive: _build/prod/rel/sub_app1/bin/sub_app1 console
      Foreground: _build/prod/rel/sub_app1/bin/sub_app1 foreground
      Daemon: _build/prod/rel/sub_app1/bin/sub_app1 start
 ---> a2da9353baed
Removing intermediate container 35a7361860a6
Successfully built a2da9353baed
Docker image app/sub_app1:build has been successfully created

However, mix docker.release always fails as it expects my tarball to be created at /opt/app/_build/prod/rel/umbrella_app/releases//umbrella_app.tar.gz

16:17:45.630 [debug] $ docker create --name mix_docker-980782 app/sub_app1:build
b9f43d3a25a19f0ea43e0bd06de4a66f07171aadf8a2c551eef7c3841b6fe77d

16:17:45.719 [debug] $ docker cp mix_docker-980782:/opt/app/_build/prod/rel/umbrella_app/releases/<version>/umbrella_app.tar.gz umbrella_app.tar.gz
Error response from daemon: lstat /var/lib/docker/overlay/e129f7d73db871107dbd7b69832632150768a05098bc60bc5f479a18fec97307/merged/opt/app/_build/prod/rel/umbrella_app/releases/<version>/umbrella_app.tar.gz: no such file or directory
** (MatchError) no match of right hand side value: {%IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false}, 1}
    (mix_docker) lib/mix_docker.ex:179: MixDocker.system!/2
    (mix_docker) lib/mix_docker.ex:36: anonymous fn/4 in MixDocker.release/1
    (mix_docker) lib/mix_docker.ex:33: MixDocker.release/1
    (mix) lib/mix/task.ex:294: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

Where it should be doing instead in order to work correctly:

docker cp mix_docker-980782:/opt/app/_build/prod/rel/sub_app1/releases/<version>/sub_app1.tar.gz sub_app1.tar.gz

However, the current implementation defaults app bundle create using the umbrella_app being the app_name(). Where it should inspect and detect from the release profile info for the app name to use.

Is my understanding correct? Am I using the package correctly?

yeongsheng-tan avatar Apr 05 '17 08:04 yeongsheng-tan

I get the same issue.

samsondav avatar Jul 04 '17 15:07 samsondav

Me too

gfrare avatar Aug 01 '17 17:08 gfrare