# Makefile for kami-spider Docker image management .PHONY: help build-base build clean test push-base push-app # Default variables VERSION ?= latest REGISTRY ?= localhost:5000 USE_PROXY ?= 0 help: ## Show this help message @echo "Available commands:" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' build-base: ## Build base image with all dependencies @echo "๐Ÿ—๏ธ Building base image..." ./build-base-image.sh build-base-with-proxy: ## Build base image using proxy @echo "๐Ÿ—๏ธ Building base image with proxy..." USE_PROXY=1 ./build-base-image.sh build: ## Build application image using pre-built base image @echo "๐Ÿš€ Building application image..." docker build \ -t kami-spider:$(VERSION) \ --build-arg DOCKER_REGISTRY=$(REGISTRY) \ --build-arg USE_PROXY=$(USE_PROXY) \ . build-all: build-base build ## Build everything (base image + application) clean: ## Clean up Docker images @echo "๐Ÿงน Cleaning up Docker images..." docker rmi kami-spider-base:latest 2>/dev/null || true docker rmi kami-spider-base:$(VERSION) 2>/dev/null || true docker rmi kami-spider:$(VERSION) 2>/dev/null || true docker image prune -f test-base: ## Test base image @echo "๐Ÿงช Testing base image..." docker run --rm kami-spider-base:latest python --version docker run --rm kami-spider-base:latest python -c "import fastapi; print('โœ… FastAPI available')" docker run --rm kami-spider-base:latest python -c "import playwright; print('โœ… Playwright available')" test: ## Test application image @echo "๐Ÿงช Testing application image..." docker run --rm -p 8001:8000 -d --name test-app kami-spider:$(VERSION) sleep 5 curl -f http://localhost:8001/health || (echo "โŒ Health check failed" && docker stop test-app && exit 1) docker stop test-app @echo "โœ… Application test passed" test-all: test-base test ## Run all tests push-base: ## Push base image to registry @echo "๐Ÿ“ค Pushing base image to registry..." docker tag kami-spider-base:latest $(REGISTRY)/kami-spider-base:$(VERSION) docker push $(REGISTRY)/kami-spider-base:$(VERSION) @echo "โœ… Base image pushed successfully" push-app: ## Push application image to registry @echo "๐Ÿ“ค Pushing application image to registry..." docker tag kami-spider:$(VERSION) $(REGISTRY)/kami-spider:$(VERSION) docker push $(REGISTRY)/kami-spider:$(VERSION) @echo "โœ… Application image pushed successfully" push-all: push-base push-app ## Push all images to registry dev: ## Build image for development @echo "๐Ÿ”ง Building development image..." make build @echo "๐Ÿ”ง Development image built: kami-spider:$(VERSION)" prod: VERSION=$(shell date +%Y%m%d-%H%M%S) prod: ## Build production image with timestamp @echo "๐Ÿญ Building production image..." make build @echo "๐Ÿญ Production image built: kami-spider:$(VERSION)" # Quick start commands quick-start: ## Quick start for local development @echo "๐Ÿš€ Quick starting kami-spider..." make build docker run -d --name kami-spider -p 8000:8000 kami-spider:latest @echo "โœ… Application started on http://localhost:8000" stop: ## Stop and remove running container docker stop kami-spider 2>/dev/null || true docker rm kami-spider 2>/dev/null || true @echo "๐Ÿ›‘ Application stopped" logs: ## Show application logs docker logs -f kami-spider 2>/dev/null || echo "โŒ No running container found" # Performance comparison compare-builds: ## Compare build times between original and optimized @echo "โฑ๏ธ Comparing build times..." @echo "Building original Dockerfile..." time make build-original @echo "Building optimized Dockerfile..." time make build-optimized @echo "โœ… Build comparison completed"