Skip to main content
This guide deploys a Node.js application built with Express, with a PostgreSQL database and migrations that run before each release. Qovery builds the image from your Dockerfile and runs it on a Kubernetes cluster in your own cloud account.
No configuration file in your repository. Qovery does not read a qovery.yml, .qovery.yml or .qovery.toml, and there is no qovery init. Projects, environments and services are created in the Console, with qovery api, or with Terraform. For the full path from a repository to a running app with commands only, see Deploy with the CLI and API.

Prerequisites

Prepare the server

Listen on 0.0.0.0 and on the port from PORT, answer a health check, and read the database URL from the environment:
server.js
trust proxy set to 1 trusts one hop, the cluster’s ingress, so req.protocol and req.ip reflect what the ingress saw, and a client cannot spoof them with its own X-Forwarded-* headers. path.join(__dirname, "public") resolves the static folder from the file location, not from the working directory. Add a migrate script to package.json that runs your migration tool, for example "migrate": "knex migrate:latest", "migrate": "prisma migrate deploy" or "migrate": "node-pg-migrate up".

Add a production Dockerfile

Create a Dockerfile at the root of the repository:
Dockerfile
  • node:24-slim is the official Node.js image on Debian, on a long-term support (LTS) release. Match it to the version you develop with.
  • Copying package.json and package-lock.json before the code keeps the dependency layer cached when only the code changes. npm ci installs the exact versions from the lock file, and --omit=dev leaves out the development dependencies.
  • NODE_ENV=production turns on the production behavior of Express and many libraries.
  • The node user comes with the image, so the server runs without root.
  • CMD ["node", "server.js"] starts Node directly rather than through npm start, so Node receives the stop signal and shuts down cleanly.
If your project compiles TypeScript or bundles front-end assets, run the build in a first stage and copy only the output into this image. Add a .dockerignore with at least node_modules and .git.

Port and health check

The application listens on port 3000 and answers GET /healthz with 200. Use both values when you create the application in Qovery.

Connect PostgreSQL

The application and the migration job read the connection string from DATABASE_URL. Create PostgreSQL, then expose its connection string under that name at the environment scope, so every service of the environment gets it.
  1. In the environment, click New Service and pick PostgreSQL. Keep the visibility private, then create and deploy it. See Create a Database.
  2. Open the Variables section of the environment, find the built-in variable QOVERY_POSTGRESQL_Z<ID>_DATABASE_URL_INTERNAL, select Create alias, and name it DATABASE_URL.
From the CLI, once the application exists:
This database runs as a container on your cluster, with no automated backups. Use it for development and testing.
See Aliases and Variable Interpolation for the rules. Most PostgreSQL clients for Node.js, including pg, Knex, Prisma and node-pg-migrate, accept the postgresql:// URL as is.

Set the variables

Add the other variables your application reads, and mark keys and passwords as secrets.

Run the migrations

Run the migrate script in a lifecycle job built from the same repository and Dockerfile, triggered on the Deploy event, with these CMD arguments:
The job runs once per deployment. In the default deployment pipeline, jobs run after the databases and before the applications, so the schema is up to date when the new code starts. Running the migrations in the start command instead works for a single instance, but every instance then runs them at boot, and a failed migration leaves the application crashing in a loop.

Deploy

1

Create a project and an environment

Follow steps 1 and 2 of Deploy Your First Application. Pick the cluster the environment runs on.
2

Add PostgreSQL

Create the database and the DATABASE_URL variable as described in Connect PostgreSQL.
3

Create the application

In the environment, click New Service › Create application, select Git Repository, then your repository and branch. Leave Root Application Path empty unless the Dockerfile is in a subfolder.
4

Set the port

Add port 3000 with the protocol HTTP, and turn on Publicly Accessible. Qovery serves it over HTTPS on port 443.
5

Set the health checks

Set the readiness and liveness probes to type HTTP, path /healthz, port 3000. See Service Health Checks.
6

Add the variables

Click Create, without deploying yet. Then open the Variables section of the environment and add the other variables listed in Set the variables at the environment scope, so the migration job gets them too. DATABASE_URL already exists from the previous step. Mark keys and passwords as secrets.
7

Create the migration job

Click New Service › Create lifecycle job, select the same repository, branch and Dockerfile, and trigger it on the Deploy event (START) with the CMD arguments ["npm", "run", "migrate"]. Set the number of restarts to 0. See Run the migrations.
8

Deploy

Deploy the environment. Qovery deploys the database, then the job, then the application, builds the image from your Dockerfile and gives the application a URL on qovery.io. Follow the progress in the Deployment logs tab.

Troubleshooting

The CLI commands below use the organization and project selected with qovery context set. Run it first, or add --organization and --project to each command.
The server listens on another port than the one set in Qovery, or on localhost. Pass "0.0.0.0" to app.listen and check that the port in Qovery is 3000. Read the error lines with qovery environment deployment logs --environment "<env>" --service "<app>" --errors-only.
A package the server needs at runtime is in devDependencies, so npm ci --omit=dev left it out. Move it to dependencies. The same applies to the migration tool, which the job runs from the same image.
The migrations did not run against this database. Check that the job and the application read the same DATABASE_URL at the environment scope, and read the job output with qovery log --job "<job name>".
The folder is missing from the image, because .dockerignore excludes it or the front-end build did not run, or express.static points at a path relative to the working directory. Use path.join(__dirname, "public").
For other errors, see Diagnose a Failed Build or Deployment.

Next steps

Preview environments

Get a full copy of the environment for each pull request

Autoscaling

Set the number of instances and the resources

Auto deploy

Deploy on every push to the branch

Other frameworks

All framework guides