Docker Infrastructure Config
Relevant source files
The following files were used as context for generating this wiki page:
Docker Infrastructure Config manages the containerized services required for local development and automated testing. This configuration provides a consistent environment for the PostgreSQL database and Redis caching layer, ensuring all developers and CI pipelines use identical versions of core infrastructure.
The infrastructure supports a modular monolith API, background workers, and a suite of frontend applications within a pnpm workspace. Docker specifically handles the stateful components that the Node.js applications require to function.
Sources: README.md:37-38, package.json:19-20
Core Services
The platform relies on two primary containerized services defined in the infrastructure configuration.
PostgreSQL 16
PostgreSQL serves as the primary relational database. It stores clinical data, organization details, and patient records. The configuration enables row-level security (RLS) to maintain tenant isolation across the monorepo.
- Version: 16
- Role: Persistent data storage and tenant isolation.
- Initialization: Requires manual creation of test and E2E databases after the initial container start.
Sources: README.md:38-40, package.json:19
Redis 7
Redis provides the messaging and caching layer for background tasks. It serves as the backing store for BullMQ, which manages asynchronous jobs like PDF generation and webhooks.
- Version: 7
- Role: Message broker for BullMQ background workers.
- Client Implementation: Accessed via the
ioredisdriver.
Sources: README.md:38, apps/workers/package.json:15, apps/api/package.json:28
Service Architecture
The following diagram illustrates how the Docker-managed infrastructure interacts with the application components.
The diagram shows the connectivity between application services and the infrastructure containers. The API connects to both Postgres and Redis, while background workers interact exclusively with Redis.
Sources: README.md:14-19, package.json:19-20
Environment Management
Infrastructure lifecycle is managed through root-level pnpm scripts that wrap standard Docker Compose commands.
| Command | Action | Description |
|---|---|---|
pnpm db:up | docker compose up -d postgres redis | Starts infrastructure services in detached mode. |
pnpm db:down | docker compose down | Stops and removes all infrastructure containers. |
docker compose exec postgres createdb -U dhc dhc_test | createdb | Initializes a separate database for integration testing. |
docker compose exec postgres createdb -U dhc dhc_e2e | createdb | Initializes a separate database for browser-based E2E tests. |
Sources: package.json:19-20, README.md:39-40, README.md:58-59
Testing Infrastructure
Docker infrastructure facilitates three distinct testing tiers by providing isolated database instances.
- Local Development: The default
dhcdatabase stores development data and synthetic personas seeded viapnpm db:seed. - Integration Tests: The
dhc_testdatabase runs the tenant-isolation suite to verify row-level security rules. - End-to-End (E2E) Tests: The
dhc_e2edatabase provides a clean slate for Playwright browser tests. Each test worker creates its own clinic and data directly in this instance to ensure parallel execution without interference.
This sequence shows the lifecycle of Docker infrastructure during an automated CI run.
Sources: README.md:53-62, apps/e2e/fixtures.ts:98-107, package.json:21-25
Dependency Configuration
The application components use specific drivers to communicate with the Docker infrastructure.
API and Database Connection
The core API uses Prisma with the standard PostgreSQL adapter to communicate with the container.
Sources: apps/api/package.json:24-27
{
"dependencies": {
"@prisma/adapter-pg": "7.10.0",
"@prisma/client": "7.10.0",
"pg": "^8.23.1"
}
}
Worker and Caching Connection
Background workers utilize BullMQ to process tasks, which requires a connection to the Redis container.
Sources: apps/workers/package.json:14-15
{
"dependencies": {
"bullmq": "^6.3.11",
"ioredis": "^6.0.0"
}
}
Summary
The Docker Infrastructure Config provides the backbone for the Digital Healthcare Platform's local and testing environments. By containerizing PostgreSQL 16 and Redis 7, the project ensures that critical data isolation, background processing, and clinical workflows remain consistent across all development stages. The integration with root-level scripts simplifies the management of these services, allowing developers to focus on application logic while maintaining high standards for security and data integrity through isolated testing databases.