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
- A Next.js application in a GitHub, GitLab or Bitbucket repository, with a
package-lock.json. - A Qovery account and a cluster: create one in your cloud account, connect your own cluster, or try it on your laptop.
- A migration tool if you use one (Prisma, Drizzle Kit, Knex or another), with a
migratescript inpackage.json, for example"migrate": "prisma migrate deploy". Without one, skip Run the migrations and the migration job step of the deployment.
Prepare the application
Turn on the standalone output innext.config.js (or next.config.ts). next build then writes a self-contained server.js with only the dependencies it needs:
next.config.js
app/api/healthz/route.ts
Add a production Dockerfile
Create aDockerfile at the root of the repository:
Dockerfile
node:24-slimis the official Node.js image on Debian, on a long-term support (LTS) release.- Three stages keep the final image small:
depsinstalls every package,buildrunsnext build, andrunnergets only the standalone server, the static files andpublic. ARG NEXT_PUBLIC_API_URLpasses a variable of the same name to the build. Next.js writesNEXT_PUBLIC_values into the JavaScript bundle at build time, so they must exist during the build, not only at runtime. Add oneARGline perNEXT_PUBLIC_variable..next/staticandpublicare copied next toserver.js, because the standalone output does not include them.- The standalone server reads
HOSTNAMEto choose the address it listens on. Kubernetes setsHOSTNAMEto the pod name, so the start command sets it to0.0.0.0. - The
nodeuser comes with the image, so the server runs without root.
public folder, remove that COPY line. Add a .dockerignore with at least node_modules, .next and .git.
Port and health check
The application listens on port3000 and answers GET /api/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 fromDATABASE_URL. Create PostgreSQL, then expose its connection string under that name at the environment scope, so every service of the environment gets it.
- Qovery database (development)
- Blueprint (production)
- In the environment, click New Service and pick PostgreSQL. Keep the visibility private, then create and deploy it. See Create a Database.
- Open the Variables section of the environment, find the built-in variable
QOVERY_POSTGRESQL_Z<ID>_DATABASE_URL_INTERNAL, select Create alias, and name itDATABASE_URL.
process.env.DATABASE_URL only in server code: route handlers, server components and server actions. A variable without the NEXT_PUBLIC_ prefix never reaches the browser.
Set the variables
See Passing a value as a build argument. Never put a secret in a
NEXT_PUBLIC_ variable: it ends up in the bundle that browsers download.
Run the migrations
Run themigrate script in a lifecycle job built from the same repository and Dockerfile, triggered on the Deploy event, with these CMD arguments:
build. The runner image holds only what server.js needs, while the build stage has every package, the migration files and package.json. 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.
Deploy
- Console
- With a coding agent
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
/api/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 withqovery context set. Run it first, or add --organization and --project to each command.
Deployment fails on the health check
Deployment fails on the health check
The server listens on the pod name instead of
0.0.0.0, or on another port. Keep HOSTNAME=0.0.0.0 in the start command and check that the port in Qovery is 3000. Read the error lines with qovery environment deployment logs --environment "<env>" --service "<app>" --errors-only.Build fails on COPY /app/.next/standalone
Build fails on COPY /app/.next/standalone
output: "standalone" is missing from the Next.js config, so next build did not write the folder.A NEXT_PUBLIC_ value is undefined in the browser
A NEXT_PUBLIC_ value is undefined in the browser
The value was not set when the image was built. Declare it with
ARG in the build stage, create the variable in Qovery, and redeploy so the image is rebuilt.CSS, JavaScript or images return 404
CSS, JavaScript or images return 404
.next/static or public was not copied into the runner stage. The standalone output leaves both out.relation does not exist
relation does not exist
The migrations did not run against this database. Check that the job and the application read the same
DATABASE_URL, and read the job output with qovery log --job "<job name>".Next steps
Preview environments
Get a full copy of the environment for each pull request
Custom domain
Serve the application on your own domain
Auto deploy
Deploy on every push to the branch
Other frameworks
All framework guides