This repository has been archived on 2023-02-05. You can view files and clone it, but cannot push or open issues or pull requests.
loki/registry-cleaner.sh

31 lines
1.0 KiB
Bash
Raw Normal View History

2019-07-29 01:17:02 +02:00
#!/bin/bash
set -e
CYAN='\033[01;36m'
NC='\033[00m'
SCRIPT=$(readlink -f $0)
DIRNAME=$(dirname $SCRIPT)
# -----------------------------------------------------------------------------
# Soft delete untagged images.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Soft delete untagged images ${NC}"
2019-07-29 01:17:02 +02:00
install="pip3 install gitlab-registry-cleanup"
2019-12-14 13:02:50 +01:00
cleanup="gitlab-registry-cleanup -g https://gitlab.wojciechkozlowski.eu -r https://registry.wojciechkozlowski.eu -c /gitlab.cred"
2019-07-29 01:17:02 +02:00
docker run --rm --volumes-from gitlab \
2019-12-14 13:02:50 +01:00
-v ${DIRNAME}/gitlab.cred:/gitlab.cred \
python bash -c "${install} && ${cleanup}"
2019-07-29 01:17:02 +02:00
# -----------------------------------------------------------------------------
# Garbage collect and hard delete untagged images.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Garbage collect untagged images ${NC}"
2019-07-29 01:17:02 +02:00
docker exec gitlab bash -c "gitlab-ctl registry-garbage-collect"