rmbg/build/Makefile
2026-05-16 23:30:58 -06:00

54 lines
1.5 KiB
Makefile

# mindthemath/rmbg image — build the published-package container, test it, push it.
# Override inline, e.g.: make release TAG=0.0.2
COMPOSE ?= docker compose
PYTHON ?= python3
IMAGE ?= mindthemath/rmbg
TAG ?= latest
PORT ?= 8000
INPUT ?= ../test.jpg
OUTPUT ?= output.png
BG ?= alpha
# Exported so compose.yml's ${TAG} interpolation picks it up.
export TAG
.DEFAULT_GOAL := help
.PHONY: help build run up stop down logs log ps shell test push release clean
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
build: ## Build the mindthemath/rmbg image
$(COMPOSE) build
run up: ## Start the service (GPU) in the background
$(COMPOSE) up -d
stop down: ## Stop and remove the service container
$(COMPOSE) down
logs log: ## Follow service logs
$(COMPOSE) logs -f
ps: ## Show service status
$(COMPOSE) ps
shell: ## Open a shell inside a fresh container
$(COMPOSE) run --rm --entrypoint bash rmbg
test: ## Send INPUT to the running service, save OUTPUT
$(PYTHON) ../scripts/client.py --url http://localhost:$(PORT) \
--input $(INPUT) --output $(OUTPUT) --background $(BG)
push: build ## Push mindthemath/rmbg:$(TAG) to Docker Hub (needs docker login)
docker push $(IMAGE):$(TAG)
release: build push ## Build then push mindthemath/rmbg:$(TAG)
clean: ## Stop the service and remove the built image
-$(COMPOSE) down
-docker image rm $(IMAGE):$(TAG)