Deploys a new version of Docker Compose service without downtime.
This project is an Elixir port of docker-rollout with minor improvements.
- Elixir 1.14 or later
- Docker with
docker compose
support.
First, write the compose.yaml
for your application.
Then, run:
$ docker-compizo -f compose.yaml <service>
Above command will:
- deploy all other services except
<service>
. - deploy
<service>
:- if the
<service>
is not running,<service>
will be deployed directly. - if the
<service>
is running, and when one of the following conditions is met,<service>
will be deployed carefully, without downtime:- if the compose config hash of
<service>
is changed. - if the replicas of
<service>
is changed.
- if the compose config hash of
- in other cases, nothing will be deployed.
- if the
See docker-compizo --help
and examples in examples directory for more usage.
- A proxy is required to route traffic. Traefik is recommended.
- Services scaled by
docker-compizo
cannot havecontainer_name
andports
defined incompose.yaml
, as it's not possible to run multiple containers with the same name or port mapping. - Each deployment will increase the index of container names. For example,
project-service-1
will beproject-service-2
.
- It's better to provide healthcheck to containers. In conjunction with healthchecks, it is easier to only route traffic to the new containers when they're ready.
docker-compizo
achieves zero downtime deployment by a simple blue/green strategy:
- scaling the service for more containers
- waiting for the new containers to be ready
- removing the old containers
Using container orchestration tools like Kubernetes, Nomad or vice versa is usually an overkill for most projects.
I prefer the simple solution - Docker Compose. But, using docker compose up
to deploy a new version of a service causes downtime because the containers are stopped before the new containers are created. Nowadays, this kind of downtime is unacceptable for end users.
docker-compizo
tries to maintain a balance between a simple solution and a good end-user experience.
Compizo (/kəmˈpaɪzoʊ/) is a compound word formed by combining compose and and zero deployment:
docker-compizo = docker-compose + zero deployment
- Rewrite this project with Docker engine API.
- Integrate with a default proxy, such as docker-easy-haproxy.
- Support connection draining.
MIT