Continuous Deployment for docker-compose
$ wget https://github.com/sksat/compose-cd/releases/latest/download/compose-cd.tar.zst
$ tar xvf compose-cd.tar.zst
$ ./compose-cd install
--search-root "/srv"
--git-pull-user <user for `git pull`>
--discord-webhook "https://discord.com/api/webhooks/*****"
bash
find
getopt
git
curl
jq
sudo
docker
docker-compose
systemd
$ mkdir /srv && cd /srv
$ git clone <compose-cd managed repository> # example: https://github.com/sksat/mc.yohane.su
Please add .compose-cd
file to the same directory of docker-compose.yml
.
compose-cd
finds docker-compose
services including .compose-cd
in the same directory as docker-compose
configuration(docker-compose.yml
).
The main feature of compose-cd
is compose-cd update
command.
It loads common configuration from /etc/compose-cd/config
and update services under SEARCH_ROOT
.
This "update" includes following
git pull
docker-compose pull
compose-cd update
runs every minute by systemd timer(compose-cd.timer).
No. compose-cd
manages docker-compose
services including .compose-cd
.
So, we can create monorepo that includes compose-cd
managed docker-compose
services.
In this use case, it is highly recommended to use compose-cd
version 0.4+ because .compose-apply
behavior changed(ref: #30).
Please add .compose-apply
file to the same directory of the .compose-cd
.
Write the list of files you want to trigger restart in this file.
It supports wildcard.
example: mc.yohane.su
compose-cd
just executes git pull
on GIT_PULL_USER
.
Please use SSH type remote-url.
GitHub's deploy keys would be useful. Other Git hosting services probably have similar features.
compose-cd
just executes docker-compose pull
.
Please run docker login
beforehand.
Please use following option to prevent pull container image without changes on Git repository.
UPDATE_REPO_ONLY=true
UPDATE_IMAGE_BY_REPO=true
It is also recommended to digest pinning in docker-compose.yml
like following.
services:
paper:
image: ghcr.io/sksat/papermc-docker:1.18.1@sha256:6b100740af773991eb8f7d15d3f249b54a17c5be679c2a70d0c5b733e63e50a0
At first glance, updating this configuration may seem to be very tedious, but it is possible to automate this update using Renovate Bot.
Example:
MIT. See LICENSE for more details.