diff --git a/README.md b/README.md index 2c84855..f249c3a 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,30 @@ [![codecov](https://codecov.io/gh/TrianaLab/remake/graph/badge.svg?token=DI2AL1DL9T)](https://codecov.io/gh/TrianaLab/remake) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) - # Remake CLI 🚀 Remake is a powerful CLI tool that packages, distributes, and runs Makefiles as OCI artifacts. It enables centralized management of build scripts, seamless integration into CI/CD pipelines, and consistent execution across environments. +## 🗂️ Catalog + +This repository includes a **Makefile catalog** under `catalog/`, providing reusable OCI-published Makefiles organized by category: + +* **Runtimes** (`catalog/runtimes/`): + + * `make-os.mk`: Detect host OS, distribution, version, and architecture. + * `make-podman.mk`: Install and start Podman runtime from upstream binaries. +* **Services** (`catalog/services/`): + + * `make-redis.mk`: Spin up a Redis container via Podman with configurable password, port, and data volume. + +Each Makefile declares its own `VERSION := x.y.z` and bootstraps any lower-level dependencies automatically (OS detection, Podman). Simply invoke the highest-level Makefile: + +```bash +remake run -f oci://ghcr.io/TrianaLab/make-redis:latest run +# Or if you feel lazy today, you can just run: +remake run -f trianalab/make-redis run +``` + ## 🌟 Benefits * **CI/CD Friendly**: Easily integrate Makefile-based workflows into modern CI/CD systems. Keep your build logic versioned and reproducible across pipelines. @@ -28,11 +47,11 @@ curl -fsSL https://raw.githubusercontent.com/TrianaLab/remake/main/scripts/get-r This command downloads and runs an installation script that: 1. Fetches the latest `remake` binary. -2. Places it in your first available folder within `PATH` otherwise at `~/.local/bin`. +2. Places it in under `/usr/local/bin`. ### Go Installation -Make sure your `GOPATH/bin` or Go `bin` directory is in your `PATH`. +Make sure your Go `bin` directory is in your `PATH`: ```bash go install github.com/TrianaLab/remake@latest @@ -118,20 +137,18 @@ remake version ## 🤝 Contributing -We love contributions! To contribute: - 1. Fork the repository. -2. Create a new branch: `git checkout -b feature/YourFeature`. -3. Make your changes and add tests. -4. Ensure all tests pass: `go test ./...`. -5. Submit a pull request describing your changes. - -Please follow the existing code style and include documentation for any new features. +2. Create a new branch: `git checkout -b feature/`. +3. Add or update Makefile artifacts under `catalog/`, setting `VERSION := x.y.z`. +4. Ensure new/updated `*.mk` includes `install`, `status`/`run` targets. +5. Commit and push—CI will publish artifacts automatically to GHCR. +6. Open a Pull Request describing your changes. ## 📜 License -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. +MIT © TrianaLab. See the [LICENSE](LICENSE) file for details. + ## 📝 NOTICE -Additional legal and licensing information is provided in the [NOTICE](NOTICE.md) file. +See [NOTICE.md](NOTICE.md) for additional legal and licensing details. diff --git a/catalog/runtimes/make-podman.mk b/catalog/runtimes/make-podman.mk new file mode 100644 index 0000000..c37e143 --- /dev/null +++ b/catalog/runtimes/make-podman.mk @@ -0,0 +1,68 @@ +# make-podman.mk — Idempotent Podman installer + service manager +# Requires: remake run -f oci://ghcr.io/TrianaLab/make-os:0.1.0 detect + +VERSION := 0.1.0 + +OCI_OS := oci://ghcr.io/TrianaLab/make-os:0.1.0 +HOST_INFO := $(shell remake run -f $(OCI_OS) detect) +HOST_OS := $(word 1,$(HOST_INFO)) +DISTRO := $(word 2,$(HOST_INFO)) +OS_VER := $(word 3,$(HOST_INFO)) +ARCH := $(word 4,$(HOST_INFO)) + +.PHONY: install ensure-podman ensure-service status + +install: ensure-podman ensure-service + @echo "✅ Podman ready on $(HOST_OS)/$(DISTRO) $(OS_VER) ($(ARCH))" + +ensure-podman: + @echo "🔍 Checking Podman..." + @if ! command -v podman >/dev/null 2>&1; then \ + echo "➕ Installing Podman on $(HOST_OS)/$(DISTRO)..."; \ + if [ "$(HOST_OS)" = "linux" ]; then \ + if command -v apt-get >/dev/null 2>&1; then \ + sudo apt-get update && sudo apt-get install -y podman; \ + elif command -v dnf >/dev/null 2>&1; then \ + sudo dnf install -y podman; \ + else \ + echo "Unsupported distro: $(DISTRO)" >&2 && exit 1; \ + fi; \ + elif [ "$(HOST_OS)" = "macos" ]; then \ + brew install podman; \ + elif [ "$(HOST_OS)" = "windows" ]; then \ + powershell -NoProfile -Command "choco install podman -y"; \ + else \ + echo "Unsupported OS: $(HOST_OS)" >&2 && exit 1; \ + fi; \ + else \ + echo "✔ Podman present: $$(podman --version)"; \ + fi + +ensure-service: + @echo "🔍 Checking Podman service..." + @if [ "$(HOST_OS)" = "linux" ]; then \ + if ! systemctl is-active --quiet podman.socket; then \ + echo "➕ Starting podman.socket"; \ + sudo systemctl start podman.socket; \ + else \ + echo "✔ podman.socket running"; \ + fi; \ + elif [ "$(HOST_OS)" = "macos" ]; then \ + if ! podman system service --time=0 &>/dev/null; then \ + echo "➕ Starting Podman machine"; \ + podman machine start; \ + else \ + echo "✔ Podman machine running"; \ + fi; \ + elif [ "$(HOST_OS)" = "windows" ]; then \ + if ! powershell -NoProfile -Command "(Get-Service podman).Status -eq 'Running'"; then \ + echo "➕ Starting Podman service"; \ + powershell -NoProfile -Command "Start-Service podman"; \ + else \ + echo "✔ Podman service running"; \ + fi; \ + fi + +status: + @podman --version + @podman info | grep "host" diff --git a/catalog/services/make-redis.mk b/catalog/services/make-redis.mk new file mode 100644 index 0000000..c58aade --- /dev/null +++ b/catalog/services/make-redis.mk @@ -0,0 +1,52 @@ +# make-redis.mk — Idempotent Redis via Podman +# Requires: remake run -f oci://ghcr.io/TrianaLab/make-os:0.1.0 detect +# remake run -f oci://ghcr.io/TrianaLab/make-podman:0.1.0 + +VERSION := 0.1.0 +OCI_PODMAN := oci://ghcr.io/TrianaLab/make-podman:0.1.0 +HOST_INFO := $(shell remake run -f $(OCI_PODMAN) detect) +HOST_OS := $(word 1,$(HOST_INFO)) +DISTRO := $(word 2,$(HOST_INFO)) +OS_VER := $(word 3,$(HOST_INFO)) +ARCH := $(word 4,$(HOST_INFO)) + +# Configurable defaults +REDIS_VERSION ?= 7.0.0 +REDIS_PASSWORD ?= redispass +REDIS_PORT ?= 6379 +DATA_DIR ?= ./data/redis +CONTAINER_NAME ?= redis-server + +.PHONY: install run stop status + +install: + @echo "🔍 Ensuring Podman runtime" + @remake run -f $(OCI_PODMAN) ensure-podman + +run: install + @echo "🚀 Starting Redis $(REDIS_VERSION)" + @mkdir -p $(DATA_DIR) + @if podman ps --format '{{.Names}}' | grep -q '^$(CONTAINER_NAME)$$'; then \ + echo "✔ Container $(CONTAINER_NAME) already running"; \ + else \ + podman run -d \ + --name $(CONTAINER_NAME) \ + -e REDIS_PASSWORD=$(REDIS_PASSWORD) \ + -p $(REDIS_PORT):6379 \ + -v $(realpath $(DATA_DIR)):/data \ + docker.io/library/redis:$(REDIS_VERSION) \ + redis-server --requirepass $(REDIS_PASSWORD); \ + echo "✔ Redis started at localhost:$(REDIS_PORT)"; \ + fi + +stop: + @echo "🛑 Stopping Redis" + @if podman ps --format '{{.Names}}' | grep -q '^$(CONTAINER_NAME)$$'; then \ + podman stop $(CONTAINER_NAME) && podman rm $(CONTAINER_NAME); \ + echo "✔ Container stopped and removed"; \ + else \ + echo "✔ No running container named $(CONTAINER_NAME)"; \ + fi + +status: + @podman ps --filter "name=$(CONTAINER_NAME)" --format "{{.Names}} {{.Status}}" || echo "Redis not running" \ No newline at end of file