I’ve been learning Elixir recently and enjoying it so far, coming from a Rails background it’s really similar to Ruby. As I’m a Docker fan I had to configure everything up to be able to develop with it.

Sharing my current configuration for local development with Elixir 1.9.1, and Postgres 11.4 all tied up with docker-compose.

I’ve adapted the configuration from previous posts on Medium, namely this one.

I’ll be creating a new Phoenix project in API only mode without any of the UI parts in order to reduce the complexity of the Dockerfile.

So the first step would be to create a new Phoenix project.

mix phx.new --no-html --no-webpack

This simplifies the process as I don’t need to install Node.

After that we can move on to the Dockerfile. I’ll be using the latest version from Elixir slim but I’m planning on moving to alpine to make it lighter.

And as for docker-compose:

Notice that we’re executing a shell script run.sh which is as follows:

A possible alteration that you’ll have to make is to change the database host on dev.exs and test.exs from localhost to db. I was facing some connectivity issues between the postgres container and the application one until I made this change.