Skip to content

Continuous Deployment for docker-compose

License

Notifications You must be signed in to change notification settings

vaniland-mc/compose-cd

 
 

Repository files navigation

compose-cd

shellcheck latest release release date license stars downloads code size Continuous Deployment for docker-compose

Install

$ 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/*****"

Dependencies

  • bash
  • find
  • getopt
  • git
  • curl
  • jq
  • sudo
  • docker
  • docker-compose
  • systemd

How to use

$ 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.

How it Works

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).

FAQ

compose-cd manages a Git repository?

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).

How to limit the files that cause a restart?

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

How to use private repository?

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.

How to use private container image?

compose-cd just executes docker-compose pull. Please run docker login beforehand.

How to pin container image from configuration files?

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:

Blog

Slide

  • VRC-LT #9 slide page 0

  • さくらのマイクロコミュニティ マイクラサーバ管理者の会 #2 slide_page_0

License

MIT. See LICENSE for more details.

About

Continuous Deployment for docker-compose

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%