rs-uv3a/Makefile
Ryan Malloy 162d485c31 Add Docker infrastructure with caddy-docker-proxy
Multi-stage Dockerfile (node build → caddy:2-alpine production, node dev).
Compose base + dev override for prod/dev switching via .env ENVIRONMENT flag.
Makefile targets: build, up, down, restart, logs, dev, prod, clean, rebuild.
Caddyfile serves static Astro output with caching and compression.
2026-01-28 14:07:02 -07:00

60 lines
1.3 KiB
Makefile

include .env
export
# Compose file selection based on ENVIRONMENT
ifeq ($(ENVIRONMENT),dev)
COMPOSE_FILES := -f docker-compose.yml -f docker-compose.dev.yml
else
COMPOSE_FILES := -f docker-compose.yml
endif
DC := docker compose $(COMPOSE_FILES)
.PHONY: help build up down restart logs status clean rebuild dev prod
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
build: ## Build container image
$(DC) build
up: ## Start services (detached)
$(DC) up -d --build
@sleep 2
$(DC) logs --tail=20
down: ## Stop services
$(DC) down
restart: ## Restart services
$(DC) down
$(DC) up -d --build
@sleep 2
$(DC) logs --tail=20
logs: ## Show service logs
$(DC) logs -f
status: ## Show running containers
$(DC) ps
clean: ## Remove containers, images, and volumes
$(DC) down --rmi local -v
rebuild: ## Full rebuild (no cache)
$(DC) build --no-cache
$(DC) up -d
@sleep 2
$(DC) logs --tail=20
dev: ## Switch to dev mode and start
@sed -i 's/^ENVIRONMENT=.*/ENVIRONMENT=dev/' .env
@echo "Switched to dev mode"
$(MAKE) restart
prod: ## Switch to prod mode and start
@sed -i 's/^ENVIRONMENT=.*/ENVIRONMENT=prod/' .env
@echo "Switched to prod mode"
$(MAKE) restart