From a44047d779c572fdd34dd5d95c8e08c344412ac2 Mon Sep 17 00:00:00 2001 From: Simon C Date: Mon, 1 Jun 2020 09:42:46 +0200 Subject: [PATCH] feat: Ajout du service watchtower --- watchtower/.env | 5 +++++ watchtower/README.md | 20 ++++++++++++++++++++ watchtower/docker-compose.yml | 17 +++++++++++++++++ watchtower/run | 30 ++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 watchtower/.env create mode 100644 watchtower/README.md create mode 100644 watchtower/docker-compose.yml create mode 100755 watchtower/run diff --git a/watchtower/.env b/watchtower/.env new file mode 100644 index 0000000..c28c531 --- /dev/null +++ b/watchtower/.env @@ -0,0 +1,5 @@ +WATCHTOWER_CONTAINER_NAME=watchtower +WATCHTOWER_IMAGE=containrrr/watchtower:1.0.1 +REGISTRY_DOMAIN=registry.cool.life +REGISTRY_USER=kosssi +REGISTRY_PASSWORD=z91PjNYpswd4ai5YoMCw58VoygJSZev7qNJ0cAlPmPBD5pVz9O diff --git a/watchtower/README.md b/watchtower/README.md new file mode 100644 index 0000000..2ef3555 --- /dev/null +++ b/watchtower/README.md @@ -0,0 +1,20 @@ +# Watchtower + +> A process for automating Docker container base image updates. +> +> Watchtower is an application that will monitor your running Docker containers and watch for changes to the images that those containers were originally started from. If watchtower detects that an image has changed, it will automatically restart the container using the new image. +> +> -- [Github][github] + +## Principe + +Le but est de tenir les images à jour. + +## Authentification + +Pour utiliser le service avec un _registry_ privé il faut générer un fichier +d'authentification. + + + +[github]: https://github.com/containrrr/watchtower diff --git a/watchtower/docker-compose.yml b/watchtower/docker-compose.yml new file mode 100644 index 0000000..52ee210 --- /dev/null +++ b/watchtower/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.8' + +services: + watchtower: + container_name: ${WATCHTOWER_CONTAINER_NAME} + image: ${WATCHTOWER_IMAGE} + restart: always + command: -i 60 --label-enable --cleanup --debug + # --debug + environment: + REPO_USER: ${REGISTRY_USER} + REPO_PASS: ${REGISTRY_PASSWORD} + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ${PWD}/config.json:/config.json + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro diff --git a/watchtower/run b/watchtower/run new file mode 100755 index 0000000..cf9ebb6 --- /dev/null +++ b/watchtower/run @@ -0,0 +1,30 @@ +#!/bin/bash + +set -eu + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +. $DIR/../help.sh + +watchtower_help() { + echo "./run config : 🔑 Génération du fichier config.json" +} + +watchtower_config() { + script_env + echo "🔑 Génération du fichier config.json" + CONFIG_PATH_DEFAULT="./config.json" + CONFIG_PATH=${CONFIG_PATH:-$CONFIG_PATH_DEFAULT} + echo "{\"auths\":{\"$REGISTRY_DOMAIN\":{\"auth\":\"$(echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64)\"}}}" > $CONFIG_PATH +} + +if [ $# -ge 1 ]; then + if [ "${1}" == "config" ]; then + script_start + watchtower_config + script_end + elif [ "${1}" != "--only-source" ]; then + watchtower_help + fi +else + watchtower_help +fi