feat: Ajout du service watchtower

This commit is contained in:
Simon 2020-06-01 09:42:46 +02:00
parent afe28be81e
commit a44047d779
4 changed files with 72 additions and 0 deletions

5
watchtower/.env Normal file
View File

@ -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

20
watchtower/README.md Normal file
View File

@ -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.
>
> -- <cite>[Github][github]</cite>
## 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

View File

@ -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

30
watchtower/run Executable file
View File

@ -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