feat: configure docker compose for self-hosting#270
Open
samyuktaap wants to merge 3 commits into
Open
Conversation
Collaborator
|
@samyuktaap Please give us some time to review PR. |
ShantKhatri
reviewed
May 23, 2026
Contributor
ShantKhatri
left a comment
There was a problem hiding this comment.
Why do we need to make changes in the dev files while configuring Docker Compose here?
Author
|
Hi @ShantKhatri, Great question! While these look like changes to development/source files, they were actually necessary to resolve TypeScript compile-time errors and production runtime crashes that occur when compiling and running the application inside a production Docker container. Here is a breakdown of why each change was needed: 1. Swapping to
|
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.
Description
This PR adds full Docker and Docker Compose configuration for the DevCard monorepo to enable simple self-hosting and local development setups. It also fixes an ES module resolution issue in the
@devcard/sharedpackage that was causing the backend to crash-loop under the Node.js production runtime.Closes #37
Proposed Changes
1. Dockerization
docker-compose.yml): Defines services for:db(postgres:15-alpine): Persistent data volume, configuration credentials, and health check validation.redis(redis:7-alpine): Cache layer with persistent storage and health checks.backend(built fromapps/backend/Dockerfile): Configured to depend on the healthy database and redis containers.web(built fromapps/web/Dockerfile): Serves the SvelteKit application and proxy-points to the backend container.docker-compose.override.yml): Configures hot-reloading for local development by mounting the monorepo workspace into/appand specifying development entry points (pnpm dev)..dockerignore): Excludes heavy or runtime-specific folders (node_modules,.git,.gemini,.svelte-kit, build logs) to make container building lightweight and fast.2. Multi-Stage Dockerfiles
apps/backend/Dockerfile): Implements a multi-stage Node.js build:@devcard/sharedlibrary and typescript backend source code.apps/web/Dockerfile): Configures SvelteKit build usingadapter-nodeto run under the runtime server environment.3. ESM Relative Import Fix (Blocker)
packages/shared/src/index.ts"type": "module"), relative path imports must explicitly specify file extensions (e.g..js) at runtime. Importing from./platformsand./typescompiled literally without extensions, throwing a fatalERR_MODULE_NOT_FOUNDerror inside the compiled backend build..jsextensions (./platforms.jsand./types.js) to index relative exports so Node.js resolves them correctly at runtime.4. Configuration & Documentation
.env.example: Created at the repository root, detailing all database, redis, security tokens (JWT_SECRET,ENCRYPTION_KEY), app URLs, and server parameters.README.md: Updated with a Self-Hosting section detailing the step-by-step Compose workflow.Verification & Testing
1. Service Startup
Running
docker compose up -dbrings up all 4 containers successfully:2. Backend Health Verification
Requesting
http://localhost:3001/healthconfirms the NestJS/Fastify backend API is active and connected to PostgreSQL and Redis:{ "status": "ok", "timestamp": "2026-05-23T05:36:18.445Z", "service": "devcard-api" }3. Frontend Web Verification
Requesting
http://localhost:5173/returns200 OKwith successfully compiled SvelteKit bundle scripts and stylesheet links.