infra(docker): add Docker Compose with PostgreSQL and Keycloak

- Add docker-compose.yml (v3.9) with postgres:16-alpine and keycloak:26.1 services
- Configure PostgreSQL with separate workclub and keycloak databases
- Setup Keycloak with database backend, admin user, and realm import capability
- Create PostgreSQL init script to provision development databases and users
- Add placeholder realm-export.json for Keycloak realm configuration
- Configure healthchecks and app-network bridge for service discovery
- Document configuration and patterns in learnings.md
This commit is contained in:
OpenCode Assistant
2026-03-03 14:07:29 +01:00
parent c7dd3299d7
commit cf7b47cb69
6 changed files with 712 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
=== TASK 1: Monorepo Scaffolding Verification ===
Date: 2026-03-03
Task: Initialize git repository, create monorepo directory structure, .NET 10 solution with 6 projects
=== GIT INITIALIZATION ===
✓ Git repository initialized at /Users/mastermito/Dev/opencode/.git/
=== DIRECTORY STRUCTURE ===
✓ backend/
✓ frontend/
✓ infra/
=== CONFIGURATION FILES ===
✓ .gitignore (with dotnet, node, IDE patterns)
✓ .editorconfig (C# conventions)
✓ backend/global.json (pinned to .NET 10.0.100)
=== .NET SOLUTION ===
Solution File: backend/WorkClub.slnx (new .NET 10 format)
SDK Version: 10.0.100
=== PROJECTS CREATED ===
1. ✓ WorkClub.Api (ASP.NET Core Web API)
2. ✓ WorkClub.Application (Class Library)
3. ✓ WorkClub.Domain (Class Library)
4. ✓ WorkClub.Infrastructure (Class Library)
5. ✓ WorkClub.Tests.Unit (xUnit)
6. ✓ WorkClub.Tests.Integration (xUnit)
=== PROJECT REFERENCES (CLEAN ARCHITECTURE) ===
✓ Api → Application + Infrastructure
✓ Application → Domain
✓ Infrastructure → Domain
✓ Tests.Unit → Api, Application, Domain, Infrastructure
✓ Tests.Integration → Api, Application, Domain, Infrastructure
=== NUGET PACKAGES ADDED ===
Application:
✓ Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0
✓ Finbuckle.MultiTenant 8.2.0 (resolved to 9.0.0)
Infrastructure:
✓ Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0
Api:
✓ Microsoft.AspNetCore.Authentication.JwtBearer 10.0.0
Tests.Integration:
✓ Testcontainers.PostgreSql 3.7.0
✓ Microsoft.AspNetCore.Mvc.Testing 10.0.0
=== GIT COMMIT ===
✓ Commit created: c7dd329
✓ Message: "chore(scaffold): initialize git repo and monorepo with .NET solution"
✓ Files committed: 26 files, 3063 insertions
=== BUILD VERIFICATION ===
Command: dotnet build backend/WorkClub.slnx --configuration Release
Output Summary:
✓ 6 projects built successfully
✓ Ellapsed: 4.64 seconds
✓ Errors: 0
✓ Warnings: 14 (expected - NuGet version mismatches, Testcontainers security advisories)
Build Results:
WorkClub.Domain → /Users/mastermito/Dev/opencode/backend/WorkClub.Domain/bin/Release/net10.0/WorkClub.Domain.dll
WorkClub.Infrastructure → /Users/mastermito/Dev/opencode/backend/WorkClub.Infrastructure/bin/Release/net10.0/WorkClub.Infrastructure.dll
WorkClub.Application → /Users/mastermito/Dev/opencode/backend/WorkClub.Application/bin/Release/net10.0/WorkClub.Application.dll
WorkClub.Api → /Users/mastermito/Dev/opencode/backend/WorkClub.Api/bin/Release/net10.0/WorkClub.Api.dll
WorkClub.Tests.Unit → /Users/mastermito/Dev/opencode/backend/WorkClub.Tests.Unit/bin/Release/net10.0/WorkClub.Tests.Unit.dll
WorkClub.Tests.Integration → /Users/mastermito/Dev/opencode/backend/WorkClub.Tests.Integration/bin/Release/net10.0/WorkClub.Tests.Integration.dll
=== COMPLETION CHECKLIST ===
[x] Git repository initialized at /Users/mastermito/Dev/opencode
[x] Initial commit created with "chore(scaffold): initialize git repo and monorepo with .NET solution"
[x] Directory structure: backend/, frontend/, infra/
[x] .NET solution at backend/WorkClub.slnx with 6 projects
[x] Project references follow Clean Architecture pattern
[x] Files: .gitignore (comprehensive), .editorconfig, global.json
[x] NuGet packages added to appropriate projects
[x] Verification: dotnet build backend/WorkClub.slnx → exit 0, 6 succeeded, 0 failed
[x] Evidence saved to .sisyphus/evidence/task-1-setup-verification.txt
=== STATUS ===
✓ TASK COMPLETE: All requirements met, solution compiles with zero errors.

View File

@@ -0,0 +1,83 @@
TASK 2: Docker Compose Configuration Verification
================================================
Generated: 2026-03-03
## Configuration Files Created
✓ /docker-compose.yml - Main Docker Compose configuration
✓ /infra/keycloak/realm-export.json - Placeholder realm export
✓ /infra/postgres/init.sql - PostgreSQL initialization script
## YAML Syntax Validation
✓ docker-compose.yml structure verified:
- services: postgres, keycloak
- volumes: postgres-data
- networks: app-network
## Configuration Details
### PostgreSQL Service (postgres)
- Image: postgres:16-alpine
- Port: 5432
- Databases:
* postgres (system)
* workclub (application, user: app, password: devpass)
* keycloak (Keycloak metadata, user: keycloak, password: keycloakpass)
- Volume: postgres-data (/var/lib/postgresql/data)
- Healthcheck: pg_isready -U postgres
- Network: app-network
### Keycloak Service (keycloak)
- Image: quay.io/keycloak/keycloak:26.1
- Port: 8080
- Admin: admin/admin
- Database: keycloak (PostgreSQL)
- Command: start-dev --import-realm
- Realm Import: /opt/keycloak/data/import mounted to ./infra/keycloak
- Healthcheck: /health/ready endpoint
- Network: app-network
- Depends on: postgres (healthy)
## Environment Notes
Docker Engine: 29.2.1
Docker Compose: Not available (would require docker compose CLI plugin)
NOTE: Full integration test (docker compose up -d) cannot run in this environment.
However, configuration is syntactically valid and follows Docker Compose v3.9 specification.
## Service Dependencies
keycloak → depends_on postgres (service_healthy condition)
Both services connected via app-network bridge network
## Verification Summary
✓ YAML Syntax: Valid
✓ Service Definition: Both postgres and keycloak properly configured
✓ Environment Variables: All required vars present
✓ Volumes: postgres-data volume declared, keycloak realm import mount configured
✓ Networks: app-network bridge network declared
✓ Healthchecks: Configured for both services
✓ Database Setup: init.sql script creates workclub and keycloak databases with proper users
## Known Limitations
- docker compose CLI plugin not available in this environment
- Cannot perform runtime health verification (docker compose up)
- Cannot test OIDC discovery endpoint connectivity
- Manual Docker deployment would require: docker run commands or alternative orchestration
## File Structure
/Users/mastermito/Dev/opencode/
├── docker-compose.yml
├── infra/
│ ├── postgres/
│ │ └── init.sql
│ └── keycloak/
│ └── realm-export.json
All files are in place and ready for Docker deployment.