{"id":20451329,"url":"https://github.com/graillus/gcrgc","last_synced_at":"2025-04-13T02:33:44.041Z","repository":{"id":35002153,"uuid":"172286110","full_name":"graillus/gcrgc","owner":"graillus","description":"Command-line tool for easily cleaning Google Container Registry repositories","archived":false,"fork":false,"pushed_at":"2024-08-26T18:21:55.000Z","size":281,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T20:04:13.895Z","etag":null,"topics":["cleaner","container-registry","gcloud","gcr","gcr-cleaner","golang","google-container-registry"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graillus.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-24T02:13:13.000Z","updated_at":"2024-08-20T07:45:37.000Z","dependencies_parsed_at":"2024-06-19T05:31:38.506Z","dependency_job_id":"2e898ea7-f667-4a41-b900-d32ea9fd1acd","html_url":"https://github.com/graillus/gcrgc","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/graillus%2Fgcrgc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graillus%2Fgcrgc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graillus%2Fgcrgc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graillus%2Fgcrgc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graillus","download_url":"https://codeload.github.com/graillus/gcrgc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657840,"owners_count":21140842,"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":["cleaner","container-registry","gcloud","gcr","gcr-cleaner","golang","google-container-registry"],"created_at":"2024-11-15T10:57:17.611Z","updated_at":"2025-04-13T02:33:44.019Z","avatar_url":"https://github.com/graillus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"gcrgc\n=====\n\n[![Build Status](https://travis-ci.org/graillus/gcrgc.svg?branch=master)](https://travis-ci.org/graillus/gcrgc)\n[![codecov.io](http://codecov.io/github/graillus/gcrgc/coverage.svg?branch=master)](http://codecov.io/github/graillus/gcrgc?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/graillus/gcrgc)](https://goreportcard.com/report/github.com/graillus/gcrgc)\n[![GoDoc](https://godoc.org/github.com/graillus/gcrgc?status.svg)](https://pkg.go.dev/github.com/graillus/gcrgc)\n[![License MIT](https://img.shields.io/github/license/graillus/gcrgc.svg)](https://github.com/graillus/gcrgc/blob/master/LICENSE)\n\nThe GCR Garbage Collector\n\nTool for cleaning up images on the Google Container Registry.\nInitially based on the [gist](https://gist.github.com/ahmetb/7ce6d741bd5baa194a3fac6b1fec8bb7) by [Ahmet Alp Balkan](https://gist.github.com/ahmetb), and rewritten in Go.\n\n## Features\n\n- Remove images older than the date specified with option `--date`\n- Keep images within a given retention period `--retention-period`\n- Exclude some image repositories with option `--exclude-repositories`\n- Exclude images with certain tag(s) from deletion with option `--exclude-tags`\n- Exclude images with tags matching a regexp pattern with option `--exclude-tag-pattern`\n- Exclude images with tags matching a [SemVer](https://semver.org) pattern with option `--exclude-semver-tags`\n  \u003e Note: The SemVer standard does not include the `v` or `V` prefix (e.g. v1.0.0), but as it is widely used, our Regexp will also match tags beginning with either `v` or `V`, so they will be excluded from deletion as well.\n- Only remove untagged images with `--untagged-only` flag\n- Dry-run mode with option `--dry-run` (don't actually delete images but get same output)\n\n## Prerequisites\n\nYou need an authenticated local `gcloud` installation, and write access to a Google Container Registry.\n\nYou can use a service account as well by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Read the Google [documentation](https://cloud.google.com/docs/authentication/getting-started) for more details.\n\n## Installation\n\n### Binary releases\n\n1. Download your [desired version](https://github.com/graillus/gcrgc/releases)\n2. Extract it\n```bash\ntar xvf gcrgc_0.4.4_linux_amd64.tar.gz\n```\n3. Move binary to desired destination\n```bash\nmv gcrgc /usr/local/bin\n```\n\n### From sources\n\n```bash\ngo get github.com/graillus/gcrgc\ncd $GOPATH/src/github.com/graillus/gcrgc\ngo build -o bin/gcrgc cmd/gcrgc/gcrgc.go\n```\n\n### Using docker\n\nA public image repository is available on [DockerHub](https://hub.docker.com/r/graillus/gcrgc)\n\n```bash\ndocker pull graillus/gcrgc\n```\n\nRun with Google service account credentials:\n```bash\ndocker run -t --rm \\\n  -v /path/to/serviceaccount.json:/credentials \\\n  -e GOOGLE_APPLICATION_CREDENTIALS=/credentials/serviceaccount.json\n  graillus/gcrgc ...\n```\n\n## Usage\n\n```bash\ngcrgc [options] \u003cregistry\u003e\n```\n\n### Examples:\n\nTo cleanup the entire registry, run:\n```bash\ngcrgc gcr.io/project-id\n```\n\u003e Warning ! All the repositories for that particular GCP project will be autodiscovered and cleaned.\nRunning this command will empty the entire registry !\n\nYou can set a retention period to keep the recent images and only clean the old ones.\n\nKeep the images less than 30 days old:\n```bash\ngcrgc --retention-period=30d gcr.io/project-id\n```\n\nCan also be expressed with an absolute date:\n```bash\ngcrgc --date=2019-01-01 gcr.io/project-id\n```\n\nTo limit the repositories to cleanup, you can either whitelist or blacklist a subset of repositories in the registry:\n\nCleanup the `gcr.io/project-id/nginx` and `gcr.io/project-id/my-app` repositories:\n```bash\ngcrgc --repositories=nginx,my-app gcr.io/project-id\n```\n\nCleanup everything BUT the `gcr.io/project-id/nginx` and `gcr.io/project-id/my-app` repositories:\n```bash\ngcrgc --exclude-repositories=nginx,my-app gcr.io/project-id\n```\n\nYou probably want to ensure the images with a certain tag are excluded from deletion:\n```bash\ngcrgc --exclude-tags=latest,other-tag gcr.io/project-id\n```\n\nOr, only clean untagged images:\n```bash\ngcrgc --untagged-only gcr.io/project-id\n```\n\nFor more advanced control over tags exclution there are additional options:\n\nExclude tags matching a SemVer pattern (like `v1.0.0`):\n```bash\ngcrgc --exclude-semver-tags gcr.io/project-id\n```\n\nExclude tags matching custom regexp patterns:\n```bash\ngcrgc \\\n  --exclude-tag-pattern '^release-.*' \\\n  --exclude-tag-pattern '^dev-.*' \\\n  gcr.io/project-id\n```\n\n### Using a configuration file\n\nInstead of passing command-line flags, it is possible reference a configuration file instead:\n```bash\ngcrgc --config config.yaml\n```\n\nThe config file matches the same structure as the command line options. Any option can be configured both in the command line and the configuration file.\nThe command line flags have a higher priority than the configuration defined in the file, so it's possible to override the file configuration with command line flags.\n\nconfig.yaml:\n```yaml\nregistry: gcr.io/project-id\nretention-period: 30d\nexclude-repositories:\n  - nginx\n  - my-app\nexclude-semver-tags: true\nexclude-tags:\n  - latest\nexclude-tag-pattern:\n  - ^release-([0-9]+\\.)+[0-9]+$\n```\n\n## Helm chart\n\nA Helm chart is available if you wish to run it on a Kubernetes cluster (as a `CronJob`).\n\nCheck the [documentation](https://github.com/graillus/helm-charts/tree/master/charts/gcrgc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraillus%2Fgcrgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraillus%2Fgcrgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraillus%2Fgcrgc/lists"}