-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
mix deps compiled in Docker image need to be re-compiled when starting container #5130
Comments
I need more information to understand what is really happening. For example, does the machine where you built the software contains the same Elixir version that is inside Docker? Another option is that the Elixir compiler works on timestamps and maybe when creating the instance it sets all file timestamps to be the same? |
Btw, it seems your docker instruction is using elixir v1.3.2 (the latest) and if |
Hi Jose, Obrigado for the quick response.
I'm using Elixir entirely inside the container. When you build the image Elixir is installed from apt-get. Think of the container as a virtual machine image that you can boot and starts the same machine as it was when you created the image. So yes, the Elixir when compiling in the Dockerfile is the same as used when working with it inside a running container.
I also suspected it could be something related to compile time but I don't know where to start looking. The farthest I got was noticing all packages with the dependency build is outdated, please run "mix deps.compile" actually have their _build . To be honest I started Elixir/Phoenix and letting go Ruby on Rails a couple of month ago. In Rails we have a base Docker image we use for our Rails projects with all the base gems we need already installed, built in the Dockerfile with: COPY Gemfile Gemfile.lock $APP_HOME/
ENV BUNDLE_PATH=/home/app/bundle \
BUNDLE_GEMFILE=$APP_HOME/Gemfile \
BUNDLE_JOBS=2
RUN bundle install When you start that Rails container you don't need to run Is not critical but I'd just like to improve the UX when starting the app the first time. I'll appreciate any suggestions or ideas. |
Ok, thank you for explaining. I have a very minimum Docker knowledge. :) Just to make sure I got it correctly: the project is compiled inside Docker but, when starting the container, it still asks for compiling. Is this correct? Can you try running |
Thanks again ... I'll try it right now |
Thank you very much @josevalim ! ... It works ... I'll add |
Glad to have helped @hisapy! I have one last question though: can you print the mtime of the |
Sorry for the delay @josevalim I just came back and played a little with Iex tried a nice one liner but ended-up with: IO.puts "--- list of deps ---"; {:ok, deps} = File.ls("deps"); Enum.each(deps, &(IO.puts &1)); IO.puts "--- deps stats ---"; Path.wildcard("deps/*/.fetch", match_dot: true) |> Enum.each(&(IO.puts List.first(Tuple.to_list System.cmd("stat", [&1]))))
# is there any shortcut to get the first element of a tuple ? As you can see in the long output below, Change timestamp are set to the time the container was created. Apparently Access and Modify timestamp are still set to the creation time of the Docker image layer for the instruction I don't know if that could be a problem and I'm not sure how to avoid the change in Change when starting the container. For the moment I think we'll live with The long output is: --- list of deps ---
absinthe_plug
phoenix_live_reload
fs
phoenix_ecto
phoenix_html
postgrex
db_connection
phoenix_pubsub
phoenix
ecto
absinthe
cowboy
absinthe_relay
ranch
poolboy
connection
gettext
cowlib
poison
decimal
plug
--- deps stats ---
File: 'deps/absinthe/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 927738 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.029109810 +0000
Birth: -
File: 'deps/absinthe_plug/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 927991 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.119004047 +0000
Birth: -
File: 'deps/absinthe_relay/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928002 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.128992296 +0000
Birth: -
File: 'deps/connection/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928025 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.138980545 +0000
Birth: -
File: 'deps/cowboy/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928033 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.138980545 +0000
Birth: -
File: 'deps/cowlib/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928086 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.218886534 +0000
Birth: -
File: 'deps/db_connection/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928121 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.248851279 +0000
Birth: -
File: 'deps/decimal/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928154 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.268827777 +0000
Birth: -
File: 'deps/ecto/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 928161 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.278816025 +0000
Birth: -
File: 'deps/fs/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179161 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.358722014 +0000
Birth: -
File: 'deps/gettext/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179213 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.378698512 +0000
Birth: -
File: 'deps/phoenix/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179246 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.398675009 +0000
Birth: -
File: 'deps/phoenix_ecto/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179370 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.448616252 +0000
Birth: -
File: 'deps/phoenix_html/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179384 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.458604500 +0000
Birth: -
File: 'deps/phoenix_live_reload/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179410 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.468592749 +0000
Birth: -
File: 'deps/phoenix_pubsub/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179424 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.468592749 +0000
Birth: -
File: 'deps/plug/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179452 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.478580998 +0000
Birth: -
File: 'deps/poison/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179517 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.508545744 +0000
Birth: -
File: 'deps/poolboy/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179531 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.508545744 +0000
Birth: -
File: 'deps/postgrex/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179551 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.518533992 +0000
Birth: -
File: 'deps/ranch/.fetch'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe01h/65025d Inode: 179603 Links: 1
Access: (2644/-rw-r-Sr--) Uid: ( 1000/ app) Gid: ( 50/ staff)
Access: 2016-07-29 20:53:30.000000000 +0000
Modify: 2016-07-29 20:53:30.000000000 +0000
Change: 2016-08-11 21:55:52.538510489 +0000
Birth: -
:ok My |
Alright, thank you! |
I am having a similar issue. I am using CircleCI to run my tests. I have a BDD and a unit test suite. To not build the image twice i build it and then save the docker image to the workspace. Then in the unit and BDD test flow i do |
My problem was the same as https://elixirforum.com/t/using-docker-to-container-phoenix-does-not-persist-the-dependencies/11652/2.
Adding the _build folder:
Solved the problem |
This might be a possible minor bug.
Environment
Current behavior
I have a Dockerfile with an instruction to compile Mix deps. Everything works fine when you build the Docker image. However the first time you start a container with the image and run
mix phoenix.server
oriex -S mix.phoenix.server
everything compiles again. This process can take approximately 3 minutes. After this first compilation on the container, whenever you restart the container everything is compiled and working as expected.Although the _build directory contains all the builds you would expect to be in there, the first time you start the container
mix deps
output is like the following:Expected behavior
Based on the Dockerfile instructions, I expect deps to be properly compiled from the first time the container is started, thus
mix deps
output from the first time I get in the container should be:The text was updated successfully, but these errors were encountered: