Note that these dockerfiles depend on:
- Having Docker installed on your machine
- Rebuilding the image every time you want to try your latest code
- Passing necessary environment variables when you
docker run
- Your app includes distillery and coveralls
Make modifications as needed to meet those requirements.
Note that multi-stage builds can be used to combine the prod
and test
files described below, I haven't updated the gist yet to reflect that option.
Running without rebuilding
If you want to run without rebuilding, an easy approach would be to modify the test.Dockerfile to use the following CMD:
CMD ["mix", "phx.server"]
And to mount volumes into the container for rel, config, priv, test, lib, mix.{exs,lock} and anything else you need to run your app.
docker build -t my-app -f test.Dockerfile .
docker run --rm -v ./lib:/app/lib -v ./mix.exs:/app/mix.exs <repeat -v flags as needed> -e MIX_ENV=dev <repeat -e flags as needed> my-app