{"id":23719619,"url":"https://github.com/maksim-paskal/gitlab-registry-cleaner","last_synced_at":"2026-02-12T04:30:18.077Z","repository":{"id":37829496,"uuid":"471946418","full_name":"maksim-paskal/gitlab-registry-cleaner","owner":"maksim-paskal","description":"Tool to clean docker registry in Gitlab","archived":false,"fork":false,"pushed_at":"2023-12-06T10:02:42.000Z","size":189,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-30T21:52:55.171Z","etag":null,"topics":["containers","devops","docker-registry","gitlab"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maksim-paskal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-20T10:30:46.000Z","updated_at":"2023-02-10T20:06:59.000Z","dependencies_parsed_at":"2023-02-08T11:30:34.027Z","dependency_job_id":null,"html_url":"https://github.com/maksim-paskal/gitlab-registry-cleaner","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksim-paskal%2Fgitlab-registry-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksim-paskal%2Fgitlab-registry-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksim-paskal%2Fgitlab-registry-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksim-paskal%2Fgitlab-registry-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maksim-paskal","download_url":"https://codeload.github.com/maksim-paskal/gitlab-registry-cleaner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808789,"owners_count":19700513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["containers","devops","docker-registry","gitlab"],"created_at":"2024-12-30T21:52:58.096Z","updated_at":"2026-02-12T04:30:18.021Z","avatar_url":"https://github.com/maksim-paskal.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gitlab Docker Registry Cleaner\n\n## Motivation\n\nWith DevOps practices, docker registry growing fast with developing new features. Need some tool to purge stale docker registry tags in docker repository.\n\n## Installation\n\ncreate custom [values.yaml](charts/gitlab-registry-cleaner/values.yaml) for example\n\n```yaml\nenv:\n- name: GITLAB_TOKEN\n  value: sometoken\n- name: GITLAB_URL\n  value: https://git.lab/api/v4\n- name: REGISTRY_URL\n  value: \"https://someregistry.azurecr.io\"\n- name: REGISTRY_USERNAME\n  value: \"someuser\"\n- name: REGISTRY_PASSWORD\n  value: \"sometoken\"\n# optional\n- name: SENTRY_DSN\n  value: \"https://id@sentry/0\"\n\nargs:\n- -metrics.pushgateway=http://prometheus-pushgateway.prometheus.svc.cluster.local:9091\n\ntolerations:\n- key: \"kubernetes.azure.com/scalesetpriority\"\n  operator: \"Equal\"\n  value: \"spot\"\n  effect: \"NoSchedule\"\n```\n\n```bash\nhelm repo add maksim-paskal-gitlab-registry-cleaner https://maksim-paskal.github.io/gitlab-registry-cleaner\nhelm repo update\n\nhelm upgrade gitlab-registry-cleaner \\\n--install \\\n--create-namespace \\\n--namespace gitlab-registry-cleaner \\\nmaksim-paskal-gitlab-registry-cleaner/gitlab-registry-cleaner \\\n--values values.yaml\n```\n\n## Requirements\n\nAll docker registry artifacts must contains the path of Gitlab project and sluglify tag of git branch or git tag\n\nIn Gitlab CI/CD is very simple to make it with\n\n```yaml\nbuild:\n  image: docker:dind\n  script: |\n    docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY\n\n    export BUILD_STAGE_NAME=someimagename\n    export BUILD_IMAGE_NAME=$CI_REGISTRY/$CI_PROJECT_PATH/$BUILD_STAGE_NAME:$CI_COMMIT_REF_SLUG\n\n    docker build --pull -t $BUILD_IMAGE_NAME .\n    docker push $BUILD_IMAGE_NAME\n```\n\nAll git tags that use in stage/prod envieroment must be named with `release-YYYMMDD` where `YYYYMMDD` is release date\n\n## Clearing docker registry tags\n\nClearing docker tags will be peformed with this logic\n\n### 1. If docker registry have this release tags\n\n```bash\nrelease-20220320\nrelease-20220319\nrelease-20220319-patch1\nrelease-20220319-patch2\nrelease-20220318-test\nrelease-20220311\nrelease-20220310 # will be removed\nrelease-20220301 # will be removed\nrelease-20220221 # will be removed\n```\n\n`gitlab-registry-cleaner` will leave only last 10 day of release tags\n\n### 2. If docker registry tag exists and there if no git tag (branch was merged to main branch) - docker tag will be removed\n\n## Clearing docker snapshots tags\n\nin registry can be stored database snapshots, so we need to remove old snapshots also\n\ndefault path in registry `devops/docker/mysql-.+` for snapshots\n\n```bash\n20210316-snap # will be removed\n20210421-snap # will be removed\n20210504-snap # will be removed\n20211117-snap # will be removed\n20220331-snap # will be removed\n20220415-snap # will be removed\n20220606-snap\n20220615-snap\n20220809-snap\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaksim-paskal%2Fgitlab-registry-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaksim-paskal%2Fgitlab-registry-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaksim-paskal%2Fgitlab-registry-cleaner/lists"}