I need to deploy an application stack to ECS. To do this, I use the new Docker Compose ECS integration (see e.g. here).
In few words, everything boils up to using the correct docker context
and launching the command docker compose up
. This is of great help and very quick.
I would like to automate the deploy process in a GitLab pipeline.
What (Docker) image should I use in my pipeline to be able to run the new docker compose
command?
Thanks in advance.
So to elaborate on the idea from the comments:
The docker compose
binary is direcly woven together with the docker
command itself, essentially being an extension to it.
As I see it there are now two main options:
You setup a dedicated gitlab runner, that works with the normal shell executor. You then install docker on that machine and also setup the compose-cli according to this manual. Then you can start deploying with the compose command.
You create a docker image that gives you the docker compose
command. An example dockerfile could look like this:
FROM docker
RUN apk add curl
RUN apk add tar
RUN curl -L https://github.com/docker/compose-cli/releases/download/v1.0.6/docker-linux-amd64.tar.gz -O
RUN tar xzf docker-linux-amd64.tar.gz
RUN chmod +x docker/docker
RUN ln -s /usr/local/bin/docker /usr/bin/com.docker.cli
Now, the difficulty there is to manage to have the docker daemon available. However it should be possible with gitlabs dind workflow.
After starting the container with docker run --rm --privileged -it <containername> sh
the docker compose
command in my example would be available as ./docker compose
as I did not add the new docker binary to any path. However the docker daemon is not started.
Note: the resulting image from this Dockerfile is essentially only a modified Docker-in-Docker image. So it should work, but I was not able to test it.
Docker itself provides an image on their docker hub that offers docker-compose functionality. The Gitlab CI image tag would be "docker/compose"