I spent quite a bit of time trying to find a good configuration to build / test my Elixir app in CircleCI and then push an image to Docker Hub. It is probably a somewhat common thing, but I did a lot of research and trial and error moving around different steps until I got it to a good point. I wanted to share in case in ended up being useful to somebody else searching Google
Features:
Uses Circle CI caching for dependencies / compiled files
Runs tests + code checks (using ex_check)
Builds and pushes images to Docker Hub:
One tag with the Circle CI build number
One tag with the git sha
One tag with latest (if the current branch is main)
A Dockerfile is included which uses Docker’s multi-stage builds and Elixir releases so that the resulting images (for this simple app) ends up around 12.5 MB
Yeah, absolutely try it with something else. I just used alpine because that’s what the example that I started from used
One note: at first I had alpine for the first stage but didn’t use it for the second stage and there were problems that I didn’t understand until I had done some searching around. So whatever you choose, I think you need to make sure both steps are using the same base linux distro