From 488398124667514081d9c3c040d3db141ef7532c Mon Sep 17 00:00:00 2001 From: William Valentin Date: Sun, 14 Sep 2025 16:59:30 -0700 Subject: [PATCH] refactor(docker): simplify docker-compose.yml configuration - Remove deprecated version field - Keep only essential services: dev, prod, cli - Remove complex services: test, docs, nginx, monitoring - Remove custom networks for simplicity - Focus on core application containers - Update service configurations for simplified Dockerfile --- docker-compose.yml | 114 ++++----------------------------------------- 1 file changed, 9 insertions(+), 105 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 80bab0a..b509e03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,5 @@ # UnitForge Docker Compose Configuration -# Provides easy development and production deployment options - -version: "3.8" +# Simple configuration for building and running the application services: # Development service with hot reload @@ -9,11 +7,9 @@ services: build: context: . dockerfile: Dockerfile - target: development container_name: unitforge-dev ports: - "8000:8000" - - "8001:8001" # Alternative port for testing volumes: - .:/app - /app/.venv # Exclude venv from bind mount @@ -27,8 +23,6 @@ services: - RELOAD=true - PYTHONPATH=/app/backend command: ["./start-server.sh", "--host", "0.0.0.0", "--log-level", "debug"] - networks: - - unitforge-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s @@ -36,12 +30,11 @@ services: retries: 3 start_period: 40s - # Production-like service + # Production service unitforge-prod: build: context: . dockerfile: Dockerfile - target: production container_name: unitforge-prod ports: - "8080:8000" @@ -51,8 +44,9 @@ services: - DEBUG=false - LOG_LEVEL=info - RELOAD=false - networks: - - unitforge-network + - PYTHONPATH=/app/backend + command: + ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s @@ -66,7 +60,6 @@ services: build: context: . dockerfile: Dockerfile - target: cli-only container_name: unitforge-cli volumes: - ./output:/output # Mount for output files @@ -74,101 +67,12 @@ services: working_dir: /app env_file: - .env - networks: - - unitforge-network + environment: + - PYTHONPATH=/app/backend + entrypoint: ["./unitforge-cli"] profiles: - cli - - # Test runner service - unitforge-test: - build: - context: . - dockerfile: Dockerfile - target: development - container_name: unitforge-test - volumes: - - .:/app - - /app/.venv - - test-results:/app/test-results - env_file: - - .env - environment: - - PYTHONPATH=/app/backend - command: - [ - "python", - "-m", - "pytest", - "tests/", - "-v", - "--junitxml=/app/test-results/junit.xml", - "--cov=backend", - "--cov-report=html:/app/test-results/htmlcov", - ] - networks: - - unitforge-network - profiles: - - test - - # Documentation service (for future use) - unitforge-docs: - build: - context: . - dockerfile: Dockerfile - target: development - container_name: unitforge-docs - ports: - - "8002:8000" - volumes: - - .:/app - - /app/.venv - env_file: - - .env - environment: - - PYTHONPATH=/app/backend - command: - [ - "python", - "-c", - "from backend.app.main import app; import uvicorn; uvicorn.run(app, host='0.0.0.0', port=8000, reload=True)", - ] - networks: - - unitforge-network - profiles: - - docs - - # Load balancer for production (nginx) - nginx: - image: nginx:alpine - container_name: unitforge-nginx - ports: - - "80:80" - - "443:443" - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf:ro - - ./ssl:/etc/nginx/ssl:ro - depends_on: - - unitforge-prod - networks: - - unitforge-network - profiles: - - production - restart: unless-stopped - -networks: - unitforge-network: - driver: bridge - name: unitforge-network - -volumes: - test-results: - driver: local - node_modules: - driver: local -# Override configurations for different environments # Usage examples: # Development: docker-compose up unitforge-dev -# Production: docker-compose --profile production up +# Production: docker-compose up unitforge-prod # CLI only: docker-compose --profile cli run --rm unitforge-cli --help -# Run tests: docker-compose --profile test up unitforge-test -# With nginx: docker-compose --profile production up nginx unitforge-prod