Hello,
Until now I was using docker container to build and deploy my phoenix apps.
Something as following:
- I have a
dev.Dockerfile
and adocker-compose.dev.yml
dedicated for development - I have a
prod.Dockerfile
and adocker-compose.yml
dedicated to production - The reason I have 2 Dockerfiles (despite I heard that it’s not very good) is because the dev one has some development dedicated tools and the prod one is a multistage Dockerfile with a build stage (where I use Releases) and a very lightweight actual image (with only the Releases copied over).
The compose files are barely different, mainly ports and envs. - To deploy, I SSH into the prod server, pull the repo and run
docker-compose up -d
.
So, nothing too fancy.
And in the meantime I even started to bring into play some CI/CD with Gitlab CI, and it seems even easier and cleaner to deploy, but the workflow is the same.
Now I wanted to tackle the downtime issue.
At first I thought about solving this “manually”. I mean like the green/blue strategy by having a load balancer and managing the replacement of the old image manually (here is a good blog post I find about the subject https://coderbook.com/@marcus/how-to-do-zero-downtime-deployments-of-docker-containers/)
Another solution seems to be using docker swarm
abilities (with docker services
) to update containers. I just heard of it and it seems to be a pretty interesting solution. This could also allow me to gradually get rid of docker-compose
.
The other solution I want to discuss here, is using Elixir/Erlang own abilities to perform code reloading.
But first I want to say that I’m completely lost about the current tools and the “best way” to do it. I heard of distillery, edeliver, and also elixir releases. I don’t get what’s doing what.
Elixir Releases seems to be a recent tool and it seems that it’s not so spread.
In fact I’m already using releases but only because I had some hard try to figure out in my docker containers approach how to handle my env variable. Following some recipes I found, I’m mostly using it because I put all my env variables within the config/releases.exs
file and it just works.
Edeliver seems to be a tool that automates what we could do manually otherwise like SSH’ing into the prod server and copying the files.
Distillery, I don’t get its usage.
So, I wanted to know more about this topic.
Where Elixir/Erlang intrinsic hot code reloading abilities come into play?
Also, is it possible to have docker containers and those Elixir/Erlang code reloading at the same time?
Thank you for all your insights about this topic.
I’ll be happy to hear more about your workflows.
Have a good day…