Skip to content

Dockerization & Self-Hosting Stack #108

Description

@devarshishimpi

Context

For self-hosters and dedicated private environments, configuring Node, Postgres, and Redis manually on a server is tedious and error-prone. We need a zero-friction, standard deployment configuration that spins up the entire Codra architecture locally or on a VPS with a single command.

Task

  1. Dockerfile (apps/node/Dockerfile):
    • Write a production-ready, multi-stage Dockerfile.
    • Builder Stage: Use node:20-alpine (or the current LTS version). Utilize npm workspaces (or turborepo if configured) to install all dependencies and run the build command specifically for the node app (npm run build --workspace=@codraoss/node-server).
    • Runner Stage: Use a fresh node:20-alpine image. Copy only the compiled dist files and production node_modules from the builder stage to keep the final image size minimal.
    • Expose port 3000. Set the container CMD to ["node", "dist/index.js"].
  2. Docker Compose (docker-compose.yml):
    • Create a docker-compose.yml file in the root of the repository.
    • Service 1: postgres: Use the official postgres:15-alpine image. Configure standard environment variables (POSTGRES_USER=postgres, POSTGRES_PASSWORD=password, POSTGRES_DB=codra). Map port 5432:5432.
    • Service 2: redis: Use the official redis:7-alpine image. Map port 6379:6379.
    • Service 3: codra-app: Build this service from the apps/node/Dockerfile. Map port 3000:3000. Set the DATABASE_URL environment variable to postgres://postgres:password@postgres:5432/codra and the REDIS_URL environment variable to redis://redis:6379.
    • Add depends_on rules to the codra-app service to ensure Redis and Postgres are booted before the Node app starts.
  3. Documentation:
    • Add a short README.md in apps/node (or update the main repository README) instructing users how to run docker compose up -d.
    • Document how users should provide necessary GitHub App credentials and LLM API keys via an .env file that Docker Compose will read.

Acceptance Criteria

  • Running docker compose up --build successfully compiles the Node application and starts Postgres, Redis, and the Codra Node app.
  • The application container successfully resolves and connects to the adjacent Postgres and Redis containers using the internal Docker network.
  • The API is accessible on http://localhost:3000 from the host machine.
  • The Docker image builds cleanly without including unnecessary source files or dev dependencies in the final runner stage.

Relevant Files/Paths

  • apps/node/Dockerfile (New)
  • docker-compose.yml (New)
  • README.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions