| |
|
|
| .PHONY: help build build-gpu build-cpu build-all run stop clean logs shell test push pull |
|
|
| |
| PROJECT_NAME = backgroundfx-pro |
| VERSION ?= latest |
| REGISTRY ?= |
| DOCKER_COMPOSE = docker-compose |
| DOCKER = docker |
|
|
| |
| GREEN = \033[0 |
| YELLOW = \033[1 |
| RED = \033[0 |
| NC = \033[0m |
|
|
| help: |
| @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: build-gpu |
|
|
| build-gpu: |
| @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: |
| @echo "$(GREEN)Building CPU image...$(NC)" |
| $(DOCKER) build -f docker/Dockerfile.cpu -t $(PROJECT_NAME):cpu .. |
|
|
| build-prod: |
| @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-nocache: |
| $(DOCKER) build --no-cache -f docker/Dockerfile -t $(PROJECT_NAME):gpu .. |
|
|
| |
| |
| |
|
|
| run: |
| $(DOCKER_COMPOSE) up -d backgroundfx-gpu |
| @echo "$(GREEN)BackgroundFX Pro is running at http://localhost:7860$(NC)" |
|
|
| run-cpu: |
| $(DOCKER_COMPOSE) --profile cpu up -d backgroundfx-cpu |
| @echo "$(GREEN)BackgroundFX Pro (CPU) is running at http://localhost:7861$(NC)" |
|
|
| run-dev: |
| $(DOCKER_COMPOSE) -f docker-compose.yml -f docker-compose.dev.yml up |
|
|
| run-prod: |
| $(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" |
|
|
| |
| |
| |
|
|
| stop: |
| $(DOCKER_COMPOSE) down |
|
|
| restart: |
| $(DOCKER_COMPOSE) restart |
|
|
| clean: |
| $(DOCKER_COMPOSE) down -v |
| $(DOCKER) image prune -f |
| @echo "$(GREEN)Cleanup complete$(NC)" |
|
|
| clean-all: |
| $(DOCKER_COMPOSE) down -v --rmi all |
| $(DOCKER) system prune -af --volumes |
| @echo "$(YELLOW)All Docker resources cleaned$(NC)" |
|
|
| |
| |
| |
|
|
| logs: |
| $(DOCKER_COMPOSE) logs -f |
|
|
| logs-app: |
| $(DOCKER_COMPOSE) logs -f backgroundfx-gpu |
|
|
| logs-tail: |
| $(DOCKER_COMPOSE) logs --tail=100 |
|
|
| status: |
| $(DOCKER_COMPOSE) ps |
|
|
| stats: |
| $(DOCKER) stats --no-stream $$($(DOCKER_COMPOSE) ps -q) |
|
|
| health: |
| @echo "$(GREEN)Health Status:$(NC)" |
| @$(DOCKER) inspect --format='{{.Name}}: {{.State.Health.Status}}' $$($(DOCKER_COMPOSE) ps -q) 2>/dev/null || echo "No health checks configured" |
|
|
| |
| |
| |
|
|
| shell: |
| $(DOCKER_COMPOSE) exec backgroundfx-gpu /bin/bash |
|
|
| shell-root: |
| $(DOCKER_COMPOSE) exec -u root backgroundfx-gpu /bin/bash |
|
|
| test: |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m pytest tests/ |
|
|
| lint: |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m flake8 . |
|
|
| format: |
| $(DOCKER_COMPOSE) run --rm backgroundfx-gpu python -m black . |
|
|
| |
| |
| |
|
|
| download-models: |
| $(DOCKER_COMPOSE) --profile setup run --rm model-downloader |
|
|
| list-models: |
| $(DOCKER_COMPOSE) exec backgroundfx-gpu python -c "from models import ModelRegistry; r=ModelRegistry(); print(r.get_statistics())" |
|
|
| |
| |
| |
|
|
| push: |
| @if [ -z "$(REGISTRY)" ] |
| 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: |
| @if [ -z "$(REGISTRY)" ] |
| echo "$(RED)Error: REGISTRY not set$(NC)" |
| exit 1 |
| fi |
| $(DOCKER) pull $(REGISTRY)/$(PROJECT_NAME):gpu-$(VERSION) |
|
|
| deploy: |
| ./deploy.sh production |
|
|
| |
| |
| |
|
|
| backup: |
| @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: |
| @if [ -z "$(BACKUP_FILE)" ] |
| 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 |
|
|
| |
| |
| |
|
|
| gpu-check: |
| $(DOCKER) run --rm --gpus all nvidia/cuda:12.1.0-base-ubuntu20.04 nvidia-smi |
|
|
| env-example: |
| cp docker/.env.example docker/.env |
| @echo "$(GREEN)Created docker/.env - please edit with your settings$(NC)" |
|
|
| version: |
| @echo "Project: $(PROJECT_NAME)" |
| @echo "Version: $(VERSION)" |
| @echo "Docker: $$(docker --version)" |
| @echo "Docker Compose: $$(docker-compose --version)" |
|
|
| .DEFAULT_GOAL := help |