> ## Documentation Index
> Fetch the complete documentation index at: https://docs.springwinter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Node.js, Express or Rails with PostgreSQL

> Use reviewed Node.js and Rails templates with private PostgreSQL, separate liveness and readiness checks, secure runtime configuration and reproducible tests.

Node.js, Express and Rails applications can run as SpringWinter web servers when they have a reproducible container and supported dependencies. PostgreSQL is a separate private resource. The reviewed Node.js and Rails examples separate process health from database readiness and do not create application tables.

## Choose a starting point

The [Node.js template](https://github.com/SpringWinter-Research/templates/tree/v0.1.0/node-postgres) uses Node's HTTP server and `pg`; it does not include Express. An Express application can use the same deployment resource after you verify its own startup and health behavior. The [Rails API template](https://github.com/SpringWinter-Research/templates/tree/v0.1.0/rails-postgres) uses Rails, Puma and `pg`.

Choose another architecture if you require a persistent local SQLite database, shared writable filesystem or an unsupported service. Check [compatibility](https://docs.springwinter.dev/reference/compatibility.md). These samples have no authentication, business schema, migrations or seed data.

## Architecture and prerequisites

```mermaid theme={null}
flowchart LR
    Operator[Dashboard or coding agent] --> Control[SpringWinter control plane]
    Control -->|Approved deployment| AWS
    Browser[Browser] --> ALB
    subgraph AWS[Customer-owned AWS account]
        ALB[Application load balancer]
        App[Node.js, Express or Rails web tasks]
        SQL[Private PostgreSQL]
        ALB --> App
        App -->|Verified TLS| SQL
    end
```

Use Node 24 for the Node sample. Use Ruby 3.4 or newer, Bundler and PostgreSQL client headers for Rails. Both need GitHub source access, a SpringWinter account and a verified AWS connection. Docker is required for the optional local image builds.

## Reproduce local tests

```bash theme={null}
git clone --branch v0.1.0 --depth 1 \
  https://github.com/SpringWinter-Research/templates.git springwinter-templates
cd springwinter-templates/node-postgres
npm ci
npm test
docker build -t springwinter-node-postgres .
```

The Node test injects a fake pool. It checks safe database failure and recovery, health and a missing route. It does not connect to PostgreSQL.

For Rails, from the checkout root:

```bash theme={null}
cd rails-postgres
bundle install
bundle exec ruby test/health_test.rb
docker build -t springwinter-rails-postgres .
```

The Rails test explicitly uses an unreachable disposable test address and exercises only non-database routes. It does not verify real database readiness. If you run either application manually, create a new isolated PostgreSQL database and set its URL explicitly. Do not run database tasks against a shared target.

## Runtime and resource settings

| Setting | Node.js sample | Rails sample |
| - | - | - |
| Dockerfile/context after copying into its own repository | `Dockerfile`, `.` | `Dockerfile`, `.` |
| Listen port | `3000` | `3000` |
| Health path | `/health` | `/health` |
| Readiness path | `/ready` | `/ready` |
| Container start | `node server.mjs` | `bundle exec puma -b tcp://0.0.0.0:3000 config.ru` |
| Runtime variables | `DATABASE_URL` | `DATABASE_URL`, `SECRET_KEY_BASE`, `RAILS_ENV=production` |

The Dockerfiles bind to all interfaces and run as unprivileged users. Keep the lockfiles. For a monorepo, set the root directory to the chosen template folder and keep the Dockerfile path relative to the repository root.

Generate a Rails secret privately and configure it through the environment settings. Do not put its value in a deployment prompt. Configure the private PostgreSQL URL with URL-encoded credentials and verified TLS. Use the trusted AWS RDS CA through the driver's documented trust settings when needed. Do not disable certificate verification.

For an Express app, use its reviewed production command, not a development watcher. Add a health route that returns HTTP 200 without login or redirects. If the API relies on another service, implement a separate representative readiness check rather than forcing every dependency into load-balancer liveness.

## Deployment methods and migrations

In the dashboard, create or explicitly reuse PostgreSQL, wait for its provisioning and configure the app connection privately. Create the web server with the settings above. An existing database needs explicit reuse approval and a backup/data-change plan.

Codex, Claude Code and Cursor use the same [skill and approval flow](https://docs.springwinter.dev/guides/coding-agents.md). For REST automation, read [Web servers](https://docs.springwinter.dev/api-reference/web-servers.md) and [Databases](https://docs.springwinter.dev/api-reference/databases.md) in the current contract. Use returned IDs and workflow envelopes. Do not invent a remote migration endpoint.

When adding a real schema, design the migration execution path before deployment. Running migrations on every replica can race. A rollback of the container image does not undo a database migration. Review compatibility, backups and recovery separately.

## Verify and diagnose

Wait for the exact resource workflow. Then test `/`, `/health` and `/ready` on the returned HTTPS URL. Both samples return a safe 503 when readiness fails. A passing `/health` does not prove database access. Add a harmless write/read check only against authorized sample data once your app has a schema.

For readiness failures, distinguish timeout, authentication, TLS and connection exhaustion in bounded redacted diagnostics. Do not print connection URLs. Check total pools across all task copies against database capacity; increasing replicas can increase connections even if request traffic is unchanged. See [deployment troubleshooting](https://docs.springwinter.dev/troubleshooting/deployments.md).

## Production, cost and cleanup

Add application authentication and authorization, request validation, backup/restore checks and monitoring. Use external object storage for uploads. Task files do not survive replacement. Estimate continuous compute, shared load balancing, database/storage/backups, builds, logs and transfer through [cost estimation](https://docs.springwinter.dev/guides/cost-estimation.md), with platform fees separate.

For temporary deployments, approve cleanup and final-snapshot policy. Remove previews and compute before dependencies. Local tests and image builds are evidence about those checks only; no template AWS deployment is asserted.

## Questions

**Is the Node example an Express tutorial?** No. It proves a small HTTP/`pg` pattern. Validate Express-specific middleware, proxy handling and error paths in your own app.

**Can I keep SQLite in the task volume?** A task disk is temporary. Use a supported durable database or choose a platform with a suitable persistent storage model.

Related: [PostgreSQL resources](https://docs.springwinter.dev/deploy/databases.md), [full-stack architecture](https://docs.springwinter.dev/guides/full-stack-apps.md), [environment variables](https://docs.springwinter.dev/concepts/environment-variables.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.