From 671250095d4a4b6b1cb9408463dd901a913b34ef Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Mon, 15 Apr 2019 12:08:17 -0700
Subject: [PATCH] Install a docker registry GC cron

This installs a daily cron job for garbage collecting the docker
registry. Note that we need to orphan blobs by deleting their tags for
this to result in any cleaned up blobs. This will be done in a separate
change.

Change-Id: I85c87ee3b3a375e0141ef9b15a0b9e56c0938bd8
---
 playbooks/roles/registry/tasks/main.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/playbooks/roles/registry/tasks/main.yaml b/playbooks/roles/registry/tasks/main.yaml
index 8d4871d341..2166755474 100644
--- a/playbooks/roles/registry/tasks/main.yaml
+++ b/playbooks/roles/registry/tasks/main.yaml
@@ -44,3 +44,10 @@
   shell:
     cmd: docker-compose up -d
     chdir: /etc/registry-docker/
+
+- name: Install cron to garbage collect the registry daily
+  cron:
+    name: "docker registry garbage-collect"
+    minute: "0"
+    hour: "0"
+    job: "/usr/bin/docker exec registrydocker_registry_1 registry garbage-collect /etc/docker/registry/config.yml > /dev/null"