https://github.com/quving/gitlab-registry-pruner
A script that prunes the gitlab-registries.
https://github.com/quving/gitlab-registry-pruner
Last synced: about 1 year ago
JSON representation
A script that prunes the gitlab-registries.
- Host: GitHub
- URL: https://github.com/quving/gitlab-registry-pruner
- Owner: Quving
- Created: 2019-11-11T16:12:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T06:52:22.000Z (over 3 years ago)
- Last Synced: 2025-01-30T23:48:58.701Z (over 1 year ago)
- Language: Python
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gitlab Registry Pruner
[](https://drone.quving.com/Quving/gitlab-registry-pruner)
## Description
Contains scripts to keep your Gitlab-Registry clean.
## Configuration
| Env | Description | Example | Required |
|----------------------|----------------------------------------------|---------|-----------------------|
| GITLAB_GROUP_ID | The ID of the group of your gitlab-instance. | 12 | :heavy_check_mark:
| GITLAB_SERVER | Your Gitlab host including protocol. | 'https://gitlab.com' | :heavy_check_mark: |
| GITLAB_PRIVATE_TOKEN | Your Gitlab private access token. | 'jbArsqXnXqhd28DMfCh3' | :heavy_check_mark: |
|TAGS_TO_KEEP|A comma seperated string of tags what want to be kept.|'latest,stable,develop'|:heavy_check_mark:|
|DELETE_TAGS_WITH_PREFIX|A comma seperated string of string prefixes that should be removed. For example setting 'v' would have the effect that tags such as v0.1.4, v0.2.4 and version will be deleted. In general v*.|'v,test_'|:heavy_check_mark:|
|KEEP_N_LATEST_TAGS|A number of latest tags (specified by 'DELETE_TAGS_WITH_PREFIX') that should be kept.| 5 |:heavy_check_mark:
|DRY_RUN| Execute script with dry-run option. Set '1' for dry-run. Else '0'. For safety it's set on '1' as default.| 1 |:heavy_check_mark:
|LOG_DIR| The directory where the logs will be put. If the directory does not exist, it will be created.| 'logs' |:heavy_check_mark:
## Usage
### Using Docker
```sh
docker run --rm -it \
-e GITLAB_GROUP_ID='...' \
-e GITLAB_SERVER={} \
-e GITLAB_PRIVATE_TOKEN='...' \
-e TAGS_TO_KEEP='...' \
-e DELETE_TAGS_WITH_PREFIX='...' \
-e KEEP_N_LATEST_TAGS='...' \
-e DRY_RUN='...' \
pingu/gitlab-registry-pruner
```
### Using python
1. (Export the environment variables.)
2. ```pip install -r requirements.txt```
3. ```python main.py```