Skip to content

Why I have two Dockerfiles for the same project

Posted on:August 22, 2016

My phoenix-based project uses two Dockerfiles. There is one for local development and CI and another one for production. Ideally I would want one Dockerfile; use the same image for local and production. But ease of development is also important.

Phoenix supports live-reload during development. The feature is very convenient; change a file, see the change without restarting the server.

I need to give docker access to my filesystem so that I can use live-reload. When I start my application in a container, I mount my code as a volume that the docker container can access. Then, live-reload will be able to catch the code changes I make without needing to restart the server or the container.

My app deploys to Heroku. Heroku does not support volume mounting. My CI process uses a second Dockerfile that copies the codebase to the docker image. Now I have two Dockerfiles: local and production. I will trade-off this bit of duplication for the sake of development productivity.