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.
This commit is contained in:
parent
364b6602c4
commit
162d485c31
6 changed files with 160 additions and 0 deletions
59
Makefile
Normal file
59
Makefile
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue