Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
Added support for watchtower
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Mar 23, 2019
1 parent 99a7d42 commit 2bcc8e5
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env-default
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ BACKUPS_CONTAINER=backup

# backups collections, collection per container/backup point
BACKUPS_PORTAINER_COLLECTION_ID=11111-2222-3333-4444

# watchtower
WATCHTOWER_INTERVAL=10
WATCHTOWER_SLACK_HOOK=https://mattermost.anarchista.net/hooks/hxs9ebij57r15k1i6hz1dp6s6e
WATCHTOWER_IDENTIFIER="CIA-ZSP Watchtower"
2 changes: 2 additions & 0 deletions apps/conf/docker-compose.health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ services:
- VIRTUAL_PORT=8000
- LETSENCRYPT_HOST=health.${MAIN_DOMAIN}${DOMAIN_SUFFIX}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
labels:
com.centurylinklabs.watchtower.enable: true
3 changes: 3 additions & 0 deletions apps/conf/docker-compose.service-discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
restart: unless-stopped
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true
- com.centurylinklabs.watchtower.enable=true
ports:
- "80:80"
- "443:443"
Expand All @@ -32,6 +33,7 @@ services:
restart: always
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen=true
- com.centurylinklabs.watchtower.enable=true
command: "-notify-sighup ${COMPOSE_PROJECT_NAME}_gateway_1 -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf"
volumes_from:
- gateway
Expand All @@ -46,3 +48,4 @@ services:

# @debugging: It may be useful to disable HSTS when the SSL setup is not ready yet
- HSTS=on

2 changes: 2 additions & 0 deletions apps/conf/docker-compose.smtp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ services:
- "25"
env_file:
- .env
labels:
com.centurylinklabs.watchtower.enable: true

2 changes: 2 additions & 0 deletions apps/conf/docker-compose.ssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ services:

# @debugging: Enable to test if the Letsencrypt is properly configured
#- ACME_CA_URI=https://acme-staging.api.letsencrypt.org/directory
labels:
com.centurylinklabs.watchtower.enable: true
2 changes: 2 additions & 0 deletions apps/conf/docker-compose.technical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ services:
- VIRTUAL_PORT=9000
- LETSENCRYPT_HOST=a2.${MAIN_DOMAIN}${DOMAIN_SUFFIX}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
labels:
com.centurylinklabs.watchtower.enable: true
2 changes: 2 additions & 0 deletions apps/conf/templates/docker-compose.backup.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ services:

restart: on-failure
mem_limit: 80000000 # 80M
labels:
com.centurylinklabs.watchtower.enable: true
1 change: 1 addition & 0 deletions apps/conf/templates/docker-compose.dashboard.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ services:
org.docker.services.dashboard.description: 'Dashboard - a list of all hosted websites running on this network'
org.docker.services.dashboard.icon: 'pe-7s-browser'
org.docker.services.dashboard.only_for_admin: false
com.centurylinklabs.watchtower.enable: true
4 changes: 4 additions & 0 deletions apps/conf/templates/docker-compose.db.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ services:
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
labels:
com.centurylinklabs.watchtower.enable: true


#
Expand All @@ -39,3 +41,5 @@ services:
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
expose:
- "80"
labels:
com.centurylinklabs.watchtower.enable: true
2 changes: 2 additions & 0 deletions apps/conf/templates/docker-compose.deployer.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ services:
- VIRTUAL_PORT=8012
- LETSENCRYPT_HOST=deploy.${MAIN_DOMAIN}${DOMAIN_SUFFIX}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
labels:
com.centurylinklabs.watchtower.enable: true
17 changes: 17 additions & 0 deletions apps/conf/templates/docker-compose.updates.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"
services:
#
# Automatically does a docker pull for tagged services with "com.centurylinklabs.watchtower.enable" tag
#
autoupdater:
image: v2tec/watchtower
command: "--label-enable --interval ${WATCHTOWER_INTERVAL} --cleanup"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /root/.docker/config.json:/config.json
environment:
- WATCHTOWER_NOTIFICATIONS=slack
- WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL=${WATCHTOWER_SLACK_HOOK}
- WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=${WATCHTOWER_IDENTIFIER}
labels:
com.centurylinklabs.watchtower.enable: true
1 change: 1 addition & 0 deletions apps/conf/templates/docker-compose.uptimeboard.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ services:
org.docker.services.dashboard.description: 'Applications health monitoring'
org.docker.services.dashboard.icon: 'pe-7s-angle-down-circle'
org.docker.services.dashboard.only_for_admin: false
com.centurylinklabs.watchtower.enable: true
28 changes: 28 additions & 0 deletions docs/source/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,31 @@ Example cases:

.. _file-repository: https://github.com/riotkit-org/file-repository
.. _file-repository.docs.riotkit.org: https://file-repository.docs.riotkit.org/en/latest/client/configuration-reference.html

Automatic containers update
---------------------------

Watchtower_ keeps an eye on containers marked with *com.centurylinklabs.watchtower.enable* label.
Each container's image is checked for update availability, if an update is available then it's pulled from registry
and the container is re-created on a new version of image.

Downtime is minimized by pulling newer versions of images at first, then re-creating containers in proper order.
Linked containers dependency chain is respected, so the containers are re-created in proper order.

To enable Watchtower, just use a template "docker-compose.updates.yml.example", copy it to the conf directory with removing ".example" suffix.

**Configuration**

By default there are a few example variables extracted into the environment. You may adjust it to your needs, turn off notifications,
or switch notifications from slack/mattermost to e-mail.

Check Watchtower_ documentation for detail.

.. code:: bash
# watchtower
WATCHTOWER_INTERVAL=1800
WATCHTOWER_SLACK_HOOK=...
WATCHTOWER_IDENTIFIER="Watchtower"
.. _Watchtower: https://github.com/v2tec/watchtower

0 comments on commit 2bcc8e5

Please sign in to comment.