feat: add Docker Compose developer environment with Makefile shortcuts (M4)
- Root docker-compose.yml: backend (python:3.11-slim) + frontend (multi-stage node build -> nginx:alpine) on the newzy-network bridge network, frontend waits for the backend health check - Persistent SQLite via bind mount ./data/db -> /app/data/db - .env / .env.example documenting DATABASE_URL, DEBUG, BACKEND_CORS_ORIGINS and FRONTEND_API_URL - Makefile: dev, stop, restart, build, logs, status, backend-start, frontend-start, test, e2e, shell-backend, shell-frontend, clean - data/.gitignore keeps the data/ structure in git while excluding the database; root .gitignore drops the overly broad data/ rule and adds docker-compose.override.yml - backend: .gitignore covers .env.*, Dockerfile sets unbuffered python and pre-creates the db volume dir; frontend: new .dockerignore - README: full Docker setup docs (prerequisites, quick start, services, ports, network/storage, env vars, Makefile reference, troubleshooting)
This commit is contained in:
1 parent
9144411e0f
commit
ed7b30438e
11 files changed
+653
-15
No files matched your search
@@ -0,0 +1,60 @@
|
||||
# newzy — development shortcuts (docker compose under the hood).
|
||||
# Run `make help` (or just `make`) for the list of targets.
|
||||
|
||||
COMPOSE ?= docker compose
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help dev stop restart build logs status backend-start frontend-start \
|
||||
test test-frontend test-backend e2e shell-backend shell-frontend clean
|
||||
|
||||
help: ## Show this help
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
dev: ## Build (if needed) and start both services in the background
|
||||
$(COMPOSE) up -d --build
|
||||
|
||||
stop: ## Stop and remove containers (local data in ./data is kept)
|
||||
$(COMPOSE) down
|
||||
|
||||
restart: ## Recreate and start both services
|
||||
$(COMPOSE) down
|
||||
$(COMPOSE) up -d --build
|
||||
|
||||
build: ## Rebuild all images from scratch (no cache)
|
||||
$(COMPOSE) build --no-cache
|
||||
|
||||
logs: ## Follow the logs of both services
|
||||
$(COMPOSE) logs -f backend frontend
|
||||
|
||||
status: ## Show the status of both services
|
||||
$(COMPOSE) ps
|
||||
|
||||
backend-start: ## Build (if needed) and start the backend only
|
||||
$(COMPOSE) up -d backend
|
||||
|
||||
frontend-start: ## Build (if needed) and start the frontend only
|
||||
$(COMPOSE) up -d frontend
|
||||
|
||||
test: test-frontend test-backend ## Run all unit tests (frontend + backend)
|
||||
|
||||
test-frontend: ## Run frontend unit tests (requires Node.js 18+)
|
||||
cd frontend && npm run test
|
||||
|
||||
test-backend: ## Run backend tests (uses backend/.venv if present, else system pytest)
|
||||
cd backend && if [ -x .venv/bin/pytest ]; then .venv/bin/pytest; else pytest; fi
|
||||
|
||||
e2e: ## Run Playwright E2E tests (frontend/playwright; API calls are mocked)
|
||||
cd frontend && npm run e2e
|
||||
|
||||
shell-backend: ## Open a shell inside the running backend container
|
||||
$(COMPOSE) exec backend bash
|
||||
|
||||
shell-frontend: ## Open a shell inside the running frontend container
|
||||
$(COMPOSE) exec frontend sh
|
||||
|
||||
clean: ## Stop everything; remove containers, volumes and local data
|
||||
$(COMPOSE) down -v --remove-orphans
|
||||
rm -rf data/
|
||||
git checkout -- data/ 2>/dev/null || true
|
||||
docker image prune -f
|
||||
Reference in new issue
Block a user