feat: Phase 2 - Docker Compose Setup for Microservices#119
Merged
JacobCoffee merged 9 commits intomainfrom Nov 23, 2025
Merged
Conversation
Add comprehensive Docker Compose commands for local development: - docker-up: Start all services (PostgreSQL, API, Bot) - docker-down: Stop all services - docker-logs: Follow logs from services - docker-shell-*: Shell access to containers - docker-restart: Restart services - docker-rebuild: Rebuild and restart - infra-up/down: Start/stop PostgreSQL only These commands enable developers to easily work with Docker Compose for local development and testing. Part of Phase 2: Docker Compose infrastructure setup.
Add detailed documentation for Docker Compose development setup: - Architecture overview and service diagrams - Quick start guide - Complete Makefile command reference - Development workflows and debugging tips - Infrastructure-only mode for local development - Hot-reload configuration and troubleshooting - Best practices and production warnings The documentation is written in Sphinx RST format and integrated into the existing documentation structure. Part of Phase 2: Docker Compose infrastructure setup.
Add docker-compose.yml for local development with all services: Services: - PostgreSQL 15 Alpine with health checks and persistent volume - API service built from services/api/Dockerfile - Hot-reload enabled via volume mounts - Auto-runs migrations on startup - Exposed on port 8000 - Bot service built from services/bot/Dockerfile - Hot-reload enabled via volume mounts - Connects to API service Features: - Health checks for all services with proper dependencies - Volume mounts for hot-reload (delegated mode for performance) - Shared byte-network bridge network - Logging configuration (JSON driver, 10MB max, 3 files) - Environment variable injection from .env file This enables developers to run the entire stack with 'make docker-up' and have a fully functional development environment with hot-reload. Part of Phase 2: Docker Compose infrastructure setup.
Add dedicated health check controller with three endpoints designed for container orchestration: - `/health/` - General health check with database verification - `/health/ready` - Readiness probe for traffic routing - `/health/live` - Liveness probe for deadlock detection This complements the existing `/system/health` endpoint which provides more comprehensive system status including bot connectivity. Used by Docker Compose healthchecks and suitable for Kubernetes deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Create .env.docker.example with Docker-specific configuration: - Uses service names (postgres, api) instead of localhost - Optimized defaults for containerized environments - Clear documentation for required credentials - Production override examples Users can copy this to .env for local Docker development. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Create docker-compose.prod.yml with production-optimized settings: Configuration changes: - Disable debug mode and reduce logging verbosity - Remove volume mounts for hot-reload - Configure resource limits and reservations - Add restart policies with backoff - Remove exposed ports for internal-only services - Use production-grade logging (50MB max, 5 files) Worker configuration: - API: 4 workers (configurable via SERVER_HTTP_WORKERS) - Database: Resource limits for stability - Bot: Automatic restart on failure Usage: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d Suitable for Railway, staging, and production deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Create detailed documentation covering: Development workflow: - Quick start instructions - Hot reload configuration - Database migrations - Service shell access - Debugging and troubleshooting Production deployment: - Production compose file usage - Railway deployment guide - Environment configuration - Resource management Testing procedures: - 10-point testing checklist - Health check verification - Inter-service communication tests - Automated test script example Common troubleshooting: - Build failures - Connection issues - Port conflicts - Migration problems Completes Phase 2.2 documentation requirements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add Docker as the primary development method: Changes: - Add Quick Start with Docker section - Include docker-up commands and service URLs - Link to comprehensive Docker documentation - Reorganize development section for clarity - Keep uv local development as alternative Makes Docker Compose the recommended approach for new contributors while maintaining flexibility for local development preferences. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
🚅 Deployed to the byte-pr-119 environment in byte
|
Contributor
Reviewer's GuideAdds a full Docker Compose-based local and production environment for the microservices stack, introduces Kubernetes-style health endpoints in the API, extends the Makefile with Docker management commands, and updates env templates and documentation to make Docker the recommended development workflow. Sequence diagram for API health check endpoint with database verification and Docker healthchecksequenceDiagram
actor Dev as "Developer or Orchestrator"
participant Docker as "Docker Healthcheck"
participant API as "API Container (Uvicorn + Litestar)"
participant HC as "HealthController"
participant DB as "Postgres"
Dev->>Docker: "Configure healthcheck 'GET http://localhost:8000/health'"
loop "Periodic health probe"
Docker->>API: "HTTP GET /health/"
API->>HC: "Dispatch to 'health_check' handler"
HC->>DB: "Execute 'SELECT 1' via AsyncSession"
alt "Database reachable"
DB-->>HC: "Result OK"
HC-->>API: "Response {status: 'ok', database: 'healthy'} (200)"
API-->>Docker: "HTTP 200 OK"
Docker-->>Dev: "Service marked 'healthy'"
else "Database unreachable or error"
DB-->>HC: "Raises exception"
HC-->>API: "Response {status: 'degraded', database: 'unhealthy'} (503)"
API-->>Docker: "HTTP 503 Service Unavailable"
Docker-->>Dev: "Service marked 'unhealthy' after retries"
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
Blocking issues:
- Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications. (link)
- Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications. (link)
General comments:
- In docker-compose.prod.yml, the api service command is split across lines inside the YAML string, which is likely to be parsed incorrectly by Compose; consider making the entire shell command a single line or using a properly quoted multi-line literal.
- There are now two different health URL conventions (/system/health via SYSTEM_HEALTH and the new /health*/ endpoints on HealthController); it may be worth consolidating these paths or clearly separating their responsibilities to avoid confusion in clients and future routing changes.
- The tooling and docs mix both
docker composeanddocker-composeinvocations (e.g., Makefile vs docs/docker-setup.md), so standardizing on one form would make the developer experience more consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In docker-compose.prod.yml, the api service command is split across lines inside the YAML string, which is likely to be parsed incorrectly by Compose; consider making the entire shell command a single line or using a properly quoted multi-line literal.
- There are now two different health URL conventions (/system/health via SYSTEM_HEALTH and the new /health*/ endpoints on HealthController); it may be worth consolidating these paths or clearly separating their responsibilities to avoid confusion in clients and future routing changes.
- The tooling and docs mix both `docker compose` and `docker-compose` invocations (e.g., Makefile vs docs/docker-setup.md), so standardizing on one form would make the developer experience more consistent.
## Individual Comments
### Comment 1
<location> `services/api/src/byte_api/domain/system/controllers/health.py:128-129` </location>
<code_context>
+ Returns:
+ Response with alive status (always 200 unless service is completely dead).
+ """
+ logger.debug("Liveness check passed")
+ return Response(
+ content={"status": "alive"},
</code_context>
<issue_to_address>
**suggestion (performance):** Debug logging on every liveness probe may cause unnecessary log noise.
Since liveness probes can run every few seconds, this log will be emitted very frequently and may clutter logs in production. Consider removing it, making it even more conditional (e.g., behind a config flag), or otherwise ensuring it doesn’t produce unnecessary noise under normal operation.
```suggestion
return Response(
```
</issue_to_address>
### Comment 2
<location> `docs/docker-compose.rst:514` </location>
<code_context>
+Environment Variables
+~~~~~~~~~~~~~~~~~~~~~
+
+The Docker Compose setup uses environment variables from ``.env`` file:
+
+**Required for API**:
</code_context>
<issue_to_address>
**nitpick (typo):** Minor grammar improvement: add "the" before ``.env``.
Consider phrasing this as "from the `.env` file:" for smoother reading.
```suggestion
The Docker Compose setup uses environment variables from the ``.env`` file:
```
</issue_to_address>
### Comment 3
<location> `docs/docker-compose.rst:535` </location>
<code_context>
123456789012345678
</code_context>
<issue_to_address>
**security (discord-client-id):** Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.
*Source: gitleaks*
</issue_to_address>
### Comment 4
<location> `docs/docker-compose.rst:536` </location>
<code_context>
123456789012345678
</code_context>
<issue_to_address>
**security (discord-client-id):** Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.
*Source: gitleaks*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 2 of the microservices migration plan: Docker Compose setup for local development and production deployment.
Changes
Docker Compose Configuration
docker-compose.yml: Full stack development environment
byte-networkdocker-compose.prod.yml: Production overrides
Health Check Endpoints
New controller:
services/api/src/byte_api/domain/system/controllers/health.pyGET /health/- General health check with database verificationGET /health/ready- Readiness probe for traffic routing (Kubernetes-compatible)GET /health/live- Liveness probe for deadlock detection (Kubernetes-compatible)Features:
Makefile Commands
Added 88 lines of Docker management commands:
Service Management:
make docker-up- Start all servicesmake docker-down- Stop all servicesmake docker-down-volumes- Stop and remove volumesmake docker-rebuild- Rebuild and restartmake docker-restart- Restart all servicesmake docker-restart-{service}- Restart specific serviceMonitoring:
make docker-logs- Follow all logsmake docker-logs-{service}- Service-specific logsmake docker-ps- Show service statusShell Access:
make docker-shell-api- API container bashmake docker-shell-bot- Bot container bashmake docker-shell-postgres- PostgreSQL shellInfrastructure:
make infra-up- Start PostgreSQL onlymake infra-down- Stop PostgreSQLConfiguration
Documentation
docs/docker-setup.md: Comprehensive Docker guide (630 lines)
README.md: Updated with Docker workflow
Technical Highlights
Architecture
Developer Experience
Production Readiness
Testing
CI Checks ✅
Local Testing Checklist
Migration Impact
Breaking Changes
None. This PR only adds Docker Compose support. Existing uv-based local development continues to work.
New Dependencies
None. All dependencies were added in Phase 1.
Deployment
Railway deployment configuration remains compatible. Services can be deployed individually using existing Dockerfiles.
Related
.claude/PLAN.mdChecklist
make ci)Commits
51c7c5b- feat: add Kubernetes-style health check endpointsf5e315a- docs: add Docker Compose environment template42a40d6- feat: add production Docker Compose configurationf387664- docs: add comprehensive Docker Compose setup guideb497abe- docs: update README with Docker Compose workflowReview Notes
This PR is designed to be reviewed in <30 minutes:
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Summary by Sourcery
Add Docker Compose-based local and production environments, with health check endpoints and supporting tooling for the Byte microservices stack.
New Features:
Enhancements:
Build:
Documentation: