https://github.com/dokuqui/job_detection
Script to detect if any container, service, network, volume or date was left after job
https://github.com/dokuqui/job_detection
docker docker-compose github-actions gitlab-ci golang
Last synced: 3 months ago
JSON representation
Script to detect if any container, service, network, volume or date was left after job
- Host: GitHub
- URL: https://github.com/dokuqui/job_detection
- Owner: Dokuqui
- License: apache-2.0
- Created: 2024-07-25T14:06:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-21T15:51:17.000Z (over 1 year ago)
- Last Synced: 2025-02-21T16:42:59.607Z (over 1 year ago)
- Topics: docker, docker-compose, github-actions, gitlab-ci, golang
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Job_Detection
## Overview
`Job_detection` is a Go-based tool designed to manage and clean up GitLab CI and GitHub Workflows after job is finished. It monitors Docker events to detect when relevant containers start or stop and performs thorough cleanup operations to ensure no residual resources remain.
## Features
- Monitors Docker events for container lifecycle changes.
- Identifies and matches containers based on configurable job patterns.
- Stops and removes containers, networks, and volumes associated with completed GitLab CI jobs.
- Supports Docker Compose setups by running `docker-compose down` for multi-container applications.
- Handles graceful shutdowns to ensure cleanup is performed even when the script terminates unexpectedly.
## How to Run
### Prerequisites
- Go 1.21 or later
- Docker installed and running
- GitLab Runner installed and configured
### Steps
1. **Clone the Repository:**
```sh
git clone git@github.com:Dokuqui/Job_Detection.git
cd Job_Detection
```
2. **Configure Job Patterns:**
Create or modify the `jobPattern.json` file to specify patterns for identifying relevant containers.
```json
{
"jobPatterns": [
"^/runner-.*-project-.*-concurrent-.*-.*-build$",
"^/runner-.*-project-.*-concurrent-.*-.*-test$",
"^/runner-.*-project-.*-concurrent-.*-.*-deploy$"
]
}
```
3. **Run the Script:**
```sh
go run github-detection.go `or` go run gitlab-detection.go
```
## Gitlab Configuration to run
For detailed documentation for gitlab, please visit our [Readme page](../Job_Detection/docs/gitlab-conf.md).
## Tests
Also in each package exists dedicated test for several functions. To run them you can run in your terminal command.
**Run all test:**
```sh
go test -v ./...
```