cheerfulstoic
Sharing CircleCI configuration / Dockerfile to build, test, and push Elixir Docker images
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 ismain)
- A
Dockerfileis 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
I’ve made it available in a GitHub Gist:
Comments welcome here or there
First Post!
dimitarvp
Thank you for sharing this! I’ll be trying it in the future.
Have you considered making other images not based on Alpine btw? I might try your Dockerfile with Ubuntu 20.04 which is one of the smaller images.
Last Post!
cheerfulstoic
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
Popular in Guides/Tuts
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









