diff --git a/MIRRORS b/MIRRORS new file mode 100644 index 0000000..f944ff7 --- /dev/null +++ b/MIRRORS @@ -0,0 +1,4 @@ +git@github.com:kevinveenbirkenbach/dockreap.git +ssh://git@code.infinito.nexus:2201/kevinveenbirkenbach/dockreap.git +git@github.com:kevinveenbirkenbach/dockreap.git +https://pypi.org/project/dockreap/ diff --git a/README.md b/README.md index cdf661d..1bd8473 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ -# 🧹 Docker Volume Cleaner -[![GitHub Sponsors](https://img.shields.io/badge/Sponsor-GitHub%20Sponsors-blue?logo=github)](https://github.com/sponsors/kevinveenbirkenbach) [![Patreon](https://img.shields.io/badge/Support-Patreon-orange?logo=patreon)](https://www.patreon.com/c/kevinveenbirkenbach) [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20me%20a%20Coffee-Funding-yellow?logo=buymeacoffee)](https://buymeacoffee.com/kevinveenbirkenbach) [![PayPal](https://img.shields.io/badge/Donate-PayPal-blue?logo=paypal)](https://s.veen.world/paypaldonate) +# 🧹 Docker Volume Cleaner (dockreap) +[![GitHub Sponsors](https://img.shields.io/badge/Sponsor-GitHub%20Sponsors-blue?logo=github)](https://github.com/sponsors/kevinveenbirkenbach) +[![Patreon](https://img.shields.io/badge/Support-Patreon-orange?logo=patreon)](https://www.patreon.com/c/kevinveenbirkenbach) +[![Buy Me a Coffee](https://img.shields.io/badge/Buy%20me%20a%20Coffee-Funding-yellow?logo=buymeacoffee)](https://buymeacoffee.com/kevinveenbirkenbach) +[![PayPal](https://img.shields.io/badge/Donate-PayPal-blue?logo=paypal)](https://s.veen.world/paypaldonate) -**Docker Volume Cleaner** is a lightweight Python tool that helps you identify and remove unused anonymous Docker volumes β€” including symlinks and their targets πŸ—‘οΈ +**dockreap** is a lightweight Python CLI tool that helps you identify and remove unused **anonymous Docker volumes** β€” including symlinks and their targets πŸ—‘οΈ Keep your Docker environment tidy, automated, and efficient πŸš€ @@ -10,32 +13,43 @@ Keep your Docker environment tidy, automated, and efficient πŸš€ ## βš™οΈ Features -- Detects all anonymous Docker volumes (64-character hashes) +- Detects anonymous Docker volumes (64-character hash names) - Skips whitelisted volumes - Skips bootstrap mounts (`/var/www/bootstrap`) - Cleans up symlinks **and** their target directories - Optional confirmation prompt via `--no-confirmation` -- Pure Python β€” **no dependencies** +- Pure Python β€” **no external dependencies** --- ## πŸ“¦ Installation -Install it using [Kevin’s Package Manager](https://github.com/kevinveenbirkenbach/package-manager) with the alias: +### Install from PyPI (recommended) ```bash -pkgmgr install dockreap +pip install dockreap ``` -> `dockreap` is the alias for this tool within `pkgmgr`. -> Repository: [github.com/kevinveenbirkenbach/docker-volume-cleaner](https://github.com/kevinveenbirkenbach/docker-volume-cleaner) +or with an isolated environment: + +```bash +pipx install dockreap +``` + +### Install from source (development) + +```bash +git clone https://github.com/kevinveenbirkenbach/dockreap.git +cd dockreap +pip install . +``` --- -## πŸ§ͺ How to Use +## πŸ§ͺ Usage ```bash -# Basic usage with confirmation prompt +# Basic usage (with confirmation prompt) dockreap # Skip confirmation @@ -49,9 +63,20 @@ dockreap "volumeid1 volumeid2" --no-confirmation ``` πŸ“ Notes: -- Only volumes with 64-character hash names (anonymous volumes) are considered. -- Volumes mounted at `/var/www/bootstrap` are automatically excluded. -- If a volume directory is a **symlink**, both the symlink and its target are removed. + +* Only volumes with **64-character hash names** (anonymous volumes) are considered. +* Volumes mounted at `/var/www/bootstrap` are automatically excluded. +* If a volume’s `_data` directory is a **symlink**, both the symlink **and its target directory** are removed. +* Volumes referenced by **any container (running or stopped)** are not deleted. + +--- + +## πŸ” Requirements + +* Python β‰₯ 3.9 +* Docker CLI available and configured +* Sufficient permissions to remove Docker volumes + (usually requires `root` or membership in the `docker` group) --- @@ -61,13 +86,9 @@ This project is licensed under the **MIT License**. --- -## πŸ€– Built with ChatGPT - -Developed with the help of [ChatGPT]([https://chat.openai.com/share/7b177eef-b97f-4e63-b2ef-cfdc69c2337e](https://chatgpt.com/share/67f3c910-2ea0-800f-85db-71ec39a713f2)) 🀝 - ---- - ## πŸ‘€ Author -**Kevin Veen-Birkenbach** +**Kevin Veen-Birkenbach** 🌍 [https://www.veen.world/](https://www.veen.world/) + +``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..35e2e4d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=69", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "dockreap" +version = "0.0.0" +description = "Remove unused anonymous Docker volumes (with symlink cleanup)." +readme = "README.md" +requires-python = ">=3.9" +license = { text = "MIT" } +authors = [{ name = "Kevin Veen-Birkenbach" }] +keywords = ["docker", "volumes", "cleanup", "devops"] +classifiers = [ + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Environment :: Console", + "Operating System :: POSIX :: Linux", + "Topic :: System :: Systems Administration", +] + +dependencies = [] + +[project.urls] +Homepage = "https://www.veen.world/" +Repository = "https://github.com/kevinveenbirkenbach/dockreap" + +[project.scripts] +dockreap = "dockreap.__main__:main" + +[tool.setuptools] +package-dir = { "" = "src" } + +[tool.setuptools.packages.find] +where = ["src"] diff --git a/src/dockreap/__init__.py b/src/dockreap/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/src/dockreap/__main__.py similarity index 99% rename from main.py rename to src/dockreap/__main__.py index be2b7ff..4c8c205 100755 --- a/main.py +++ b/src/dockreap/__main__.py @@ -4,7 +4,6 @@ import argparse import subprocess import re import sys -import os from pathlib import Path import shutil