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
Executable File

#!/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}"
install="pip3 install gitlab-registry-cleanup"
cleanup="gitlab-registry-cleanup -g https://gitlab.wojciechkozlowski.eu -r https://registry.wojciechkozlowski.eu -c /gitlab.cred"
docker run --rm --volumes-from gitlab \
-v ${DIRNAME}/gitlab.cred:/gitlab.cred \
python bash -c "${install} && ${cleanup}"
# -----------------------------------------------------------------------------
# Garbage collect and hard delete untagged images.
# -----------------------------------------------------------------------------
echo -e "${CYAN}[${SCRIPT}] Garbage collect untagged images ${NC}"
docker exec gitlab bash -c "gitlab-ctl registry-garbage-collect"