# UnitForge Docker Compose Configuration # Provides easy development and production deployment options version: "3.8" services: # Development service with hot reload unitforge-dev: 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 - /app/backend/__pycache__ # Exclude cache - /app/.pytest_cache env_file: - .env environment: - DEBUG=true - LOG_LEVEL=debug - 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 timeout: 10s retries: 3 start_period: 40s # Production-like service unitforge-prod: build: context: . dockerfile: Dockerfile target: production container_name: unitforge-prod ports: - "8080:8000" env_file: - .env environment: - DEBUG=false - LOG_LEVEL=info - RELOAD=false networks: - unitforge-network healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 start_period: 30s restart: unless-stopped # CLI-only service for batch operations unitforge-cli: build: context: . dockerfile: Dockerfile target: cli-only container_name: unitforge-cli volumes: - ./output:/output # Mount for output files - ./input:/input # Mount for input files working_dir: /app env_file: - .env networks: - unitforge-network 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 # 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