feat: implement docker infrastructure (US-001)
- Add docker-compose.yml with postgres, redis, api, and web services - Add multi-stage Dockerfile for API (Python 3.11) - Add multi-stage Dockerfile for web (Node.js 20 + nginx) - Add Makefile with common development commands - Add .env.example with all required environment variables - Add placeholder pyproject.toml and package.json for builds - Configure health checks for all services - Setup persistent volumes for postgres, redis, and repos - Run services as non-root users
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
.PHONY: help up down logs migrate test lint clean build
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@echo "Headquarter Development Commands"
|
||||
@echo "================================"
|
||||
@echo "make up - Start all services"
|
||||
@echo "make down - Stop all services"
|
||||
@echo "make logs - View service logs"
|
||||
@echo "make migrate - Run database migrations"
|
||||
@echo "make test - Run test suites"
|
||||
@echo "make lint - Run linting"
|
||||
@echo "make build - Build all Docker images"
|
||||
@echo "make clean - Remove containers and volumes"
|
||||
@echo "make shell - Open shell in API container"
|
||||
|
||||
# Start services
|
||||
up:
|
||||
docker compose up -d
|
||||
@echo "Services starting..."
|
||||
@echo "API: http://localhost:8000"
|
||||
@echo "Web: http://localhost:3000"
|
||||
@echo "Postgres: localhost:5432"
|
||||
@echo "Redis: localhost:6379"
|
||||
|
||||
# Stop services
|
||||
down:
|
||||
docker compose down
|
||||
|
||||
# View logs
|
||||
logs:
|
||||
docker compose logs -f
|
||||
|
||||
# View specific service logs
|
||||
logs-api:
|
||||
docker compose logs -f api
|
||||
|
||||
logs-web:
|
||||
docker compose logs -f web
|
||||
|
||||
logs-db:
|
||||
docker compose logs -f postgres
|
||||
|
||||
# Run database migrations
|
||||
migrate:
|
||||
docker compose exec api alembic upgrade head
|
||||
|
||||
# Create new migration
|
||||
migration:
|
||||
docker compose exec api alembic revision --autogenerate -m "$(message)"
|
||||
|
||||
# Run tests
|
||||
test:
|
||||
docker compose exec api pytest -v
|
||||
|
||||
# Run linting
|
||||
lint:
|
||||
docker compose exec api ruff check .
|
||||
docker compose exec api mypy .
|
||||
cd apps/web && npm run lint
|
||||
|
||||
# Type checking
|
||||
typecheck:
|
||||
docker compose exec api mypy .
|
||||
cd apps/web && npm run typecheck
|
||||
|
||||
# Build all images
|
||||
build:
|
||||
docker compose build
|
||||
|
||||
# Build specific service
|
||||
build-api:
|
||||
docker compose build api
|
||||
|
||||
build-web:
|
||||
docker compose build web
|
||||
|
||||
# Clean up
|
||||
clean:
|
||||
docker compose down -v --remove-orphans
|
||||
docker system prune -f
|
||||
|
||||
# Open shell in API container
|
||||
shell:
|
||||
docker compose exec api /bin/sh
|
||||
|
||||
# Database shell
|
||||
db-shell:
|
||||
docker compose exec postgres psql -U $(POSTGRES_USER) -d $(POSTGRES_DB)
|
||||
|
||||
# Health check
|
||||
health:
|
||||
@echo "Checking service health..."
|
||||
@docker compose ps
|
||||
Reference in New Issue
Block a user