Download docker/Makefile from MogensR/VideoBackgroundReplacer: direct link, hf CLI and curl.
- Browser
- Download file 7.29 kB
-
https://huggingface.co/spaces/MogensR/VideoBackgroundReplacer/resolve/main/docker/Makefile
- Command line
-
hf download hf://spaces/MogensR/VideoBackgroundReplacer/docker/Makefile
-
curl -L -o Makefile https://huggingface.co/spaces/MogensR/VideoBackgroundReplacer/resolve/main/docker/Makefile
7.29 kB
| # Makefile for BackgroundFX Pro Docker operations | |
| .PHONY: help build build-gpu build-cpu build-all run stop clean logs shell test push pull | |
| # Variables | |
| PROJECT_NAME = backgroundfx-pro | |
| VERSION ?= latest | |
| REGISTRY ?= | |
| DOCKER_COMPOSE = docker-compose | |
| DOCKER = docker | |
| # Colors for output | |
| GREEN = \033[0;32m | |
| YELLOW = \033[1;33m | |
| RED = \033[0;31m | |
| NC = \033[0m # No Color | |
| help: ## Show this help message | |
| @echo "BackgroundFX Pro Docker Management" | |
| @echo "==================================" | |
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(GREEN)%-20s$(NC) %s\n", $$1, $$2}' | |
| # ============================================================================ | |
| # Build Commands | |
| # ============================================================================ | |
| build: build-gpu ## Build default GPU image | |
| build-gpu: ## Build GPU-enabled image | |
| @echo "$(GREEN)Building GPU image...$(NC)" | |
| $(DOCKER) build -f docker/Dockerfile -t $(PROJECT_NAME):gpu .. | |
| $(DOCKER) tag $(PROJECT_NAME):gpu $(PROJECT_NAME):latest | |
| build-cpu: ## Build CPU-only image | |
| @echo "$(GREEN)Building CPU image...$(NC)" | |
| $(DOCKER) build -f docker/Dockerfile.cpu -t $(PROJECT_NAME):cpu .. | |
| build-prod: ## Build production-optimized image | |
| @echo "$(GREEN)Building production image...$(NC)" | |
| $(DOCKER) build -f docker/Dockerfile.prod -t $(PROJECT_NAME):prod .. | |
| build-all: build-gpu build-cpu build-prod ## Build all images | |
| build-nocache: ## Build with no cache | |
| $(DOCKER) build --no-cache -f docker/Dockerfile -t $(PROJECT_NAME):gpu .. | |
| # ============================================================================ | |
| # Run Commands | |
| # ============================================================================ | |
| run: ## Run with docker-compose (GPU) | |
| $(DOCKER_COMPOSE) up -d backgroundfx-gpu | |
| @echo "$(GREEN)BackgroundFX Pro is running at http://localhost:7860$(NC)" | |
| run-cpu: ## Run CPU version | |
| $(DOCKER_COMPOSE) --profile cpu up -d backgroundfx-cpu | |
| @echo "$(GREEN)BackgroundFX Pro (CPU) is running at http://localhost:7861$(NC)" | |
| run-dev: ## Run in development mode with live reload | |
| $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.dev.yml up | |
| run-prod: ## Run in production mode with monitoring | |
| $(DOCKER_COMPOSE) --profile production --profile monitoring up -d | |
| @echo "$(GREEN)Production stack running:$(NC)" | |
| @echo " - App: http://localhost:7860" | |
| @echo " - API: http://localhost:8000" | |
| @echo " - Grafana: http://localhost:3000" | |
| @echo " - Prometheus: http://localhost:9090" | |
| # ============================================================================ | |
| # Management Commands | |
| # ============================================================================ | |
| stop: ## Stop all containers | |
| $(DOCKER_COMPOSE) down | |
| restart: ## Restart all containers | |
| $(DOCKER_COMPOSE) restart | |
| clean: ## Clean up containers, volumes, and images | |
| $(DOCKER_COMPOSE) down -v | |
| $(DOCKER) image prune -f | |
| @echo "$(GREEN)Cleanup complete$(NC)" | |
| clean-all: ## Deep clean including all images and volumes | |
| $(DOCKER_COMPOSE) down -v --rmi all | |
| $(DOCKER) system prune -af --volumes | |
| @echo "$(YELLOW)All Docker resources cleaned$(NC)" | |
| # ============================================================================ | |
| # Monitoring Commands | |
| # ============================================================================ | |
| logs: ## Show logs from all containers | |
| $(DOCKER_COMPOSE) logs -f | |
| logs-app: ## Show only application logs | |
| $(DOCKER_COMPOSE) logs -f backgroundfx-gpu | |
| logs-tail: ## Show last 100 lines of logs | |
| $(DOCKER_COMPOSE) logs --tail=100 | |
| status: ## Show container status | |
| $(DOCKER_COMPOSE) ps | |
| stats: ## Show resource usage statistics | |
| $(DOCKER) stats --no-stream $$($(DOCKER_COMPOSE) ps -q) | |
| health: ## Check health status | |
| @echo "$(GREEN)Health Status:$(NC)" | |
| @$(DOCKER) inspect --format='{{.Name}}: {{.State.Health.Status}}' $$($(DOCKER_COMPOSE) ps -q) 2>/dev/null || echo "No health checks configured" | |
| # ============================================================================ | |
| # Development Commands | |
| # ============================================================================ | |
| shell: ## Open shell in running container | |
| $(DOCKER_COMPOSE) exec backgroundfx-gpu /bin/bash | |
| shell-root: ## Open root shell in running container | |
| $(DOCKER_COMPOSE) exec -u root backgroundfx-gpu /bin/bash | |
| test: ## Run tests in container | |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m pytest tests/ | |
| lint: ## Run linting in container | |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m flake8 . | |
| format: ## Format code in container | |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m black . | |
| # ============================================================================ | |
| # Model Management | |
| # ============================================================================ | |
| download-models: ## Download all models | |
| $(DOCKER_COMPOSE) --profile setup run --rm model-downloader | |
| list-models: ## List available models | |
| $(DOCKER_COMPOSE) exec backgroundfx-gpu python -c "from models import ModelRegistry; r=ModelRegistry(); print(r.get_statistics())" | |
| # ============================================================================ | |
| # Deployment Commands | |
| # ============================================================================ | |
| push: ## Push images to registry | |
| @if [ -z "$(REGISTRY)" ]; then \ | |
| echo "$(RED)Error: REGISTRY not set$(NC)"; \ | |
| exit 1; \ | |
| fi | |
| $(DOCKER) tag $(PROJECT_NAME):gpu $(REGISTRY)/$(PROJECT_NAME):gpu-$(VERSION) | |
| $(DOCKER) push $(REGISTRY)/$(PROJECT_NAME):gpu-$(VERSION) | |
| pull: ## Pull images from registry | |
| @if [ -z "$(REGISTRY)" ]; then \ | |
| echo "$(RED)Error: REGISTRY not set$(NC)"; \ | |
| exit 1; \ | |
| fi | |
| $(DOCKER) pull $(REGISTRY)/$(PROJECT_NAME):gpu-$(VERSION) | |
| deploy: ## Deploy to production | |
| ./deploy.sh production | |
| # ============================================================================ | |
| # Backup Commands | |
| # ============================================================================ | |
| backup: ## Backup volumes | |
| @echo "$(GREEN)Creating backup...$(NC)" | |
| $(DOCKER) run --rm -v $(PROJECT_NAME)_model-cache:/data -v $$(pwd)/backups:/backup alpine tar czf /backup/models-$$(date +%Y%m%d-%H%M%S).tar.gz -C /data . | |
| $(DOCKER) run --rm -v $(PROJECT_NAME)_outputs:/data -v $$(pwd)/backups:/backup alpine tar czf /backup/outputs-$$(date +%Y%m%d-%H%M%S).tar.gz -C /data . | |
| @echo "$(GREEN)Backup complete$(NC)" | |
| restore: ## Restore from backup (set BACKUP_FILE) | |
| @if [ -z "$(BACKUP_FILE)" ]; then \ | |
| echo "$(RED)Error: BACKUP_FILE not set$(NC)"; \ | |
| exit 1; \ | |
| fi | |
| $(DOCKER) run --rm -v $(PROJECT_NAME)_model-cache:/data -v $$(pwd)/backups:/backup alpine tar xzf /backup/$(BACKUP_FILE) -C /data | |
| # ============================================================================ | |
| # Utility Commands | |
| # ============================================================================ | |
| gpu-check: ## Check GPU availability | |
| $(DOCKER) run --rm --gpus all nvidia/cuda:12.1.0-base-ubuntu20.04 nvidia-smi | |
| env-example: ## Copy example environment file | |
| cp docker/.env.example docker/.env | |
| @echo "$(GREEN)Created docker/.env - please edit with your settings$(NC)" | |
| version: ## Show version information | |
| @echo "Project: $(PROJECT_NAME)" | |
| @echo "Version: $(VERSION)" | |
| @echo "Docker: $$(docker --version)" | |
| @echo "Docker Compose: $$(docker-compose --version)" | |
| .DEFAULT_GOAL := help |