# Makefile for Markdown Editor Docker operations

.PHONY: help build run stop clean logs shell health

# Default target
help:
	@echo "Available commands:"
	@echo "  build     - Build the Docker image"
	@echo "  run       - Run the application with docker-compose"
	@echo "  run-prod  - Run with nginx reverse proxy"
	@echo "  stop      - Stop all containers"
	@echo "  clean     - Remove containers and images"
	@echo "  logs      - Show application logs"
	@echo "  shell     - Open shell in the app container"
	@echo "  health    - Check application health"

# Build the Docker image
build:
	docker-compose build --no-cache

# Run the application (development)
run:
	docker-compose up -d markdown-editor
	@echo "Application is running at http://localhost:3000"

# Run with production setup (nginx + app)
run-prod:
	docker-compose --profile production up -d
	@echo "Application is running at http://localhost (port 80)"

# Stop all containers
stop:
	docker-compose down

# Clean up containers and images
clean:
	docker-compose down --rmi all --volumes --remove-orphans
	docker system prune -f

# Show logs
logs:
	docker-compose logs -f markdown-editor

# Open shell in the app container
shell:
	docker-compose exec markdown-editor sh

# Check application health
health:
	@echo "Checking application health..."
	@curl -f http://localhost:3000/api/health || echo "Health check failed"

# Quick development cycle
dev: stop build run logs
