Deploy a Next.js app from GitHub

This guide takes a Next.js repository on GitHub to a running app on your server. You need a connected server first.

1. Connect GitHub

  1. Open Settings → GitHub and click Connect GitHub. You need permission to manage GitHub (owners and admins have it).
  2. GitHub asks which account and repositories to give access to. Pick them and confirm.
  3. You come back to the dashboard with the message GitHub connected. Your repositories now appear under Repositories and stay in sync automatically.

2. Add a Dockerfile to your repository

Builds run from a Dockerfile in your repository. Buildpacks are not supported yet, so add one before you create the project. For Next.js, turn on standalone output in next.config.js (or next.config.ts):

module.exports = { output: 'standalone' };

Then add a Dockerfile at the root of the app. This one works for npm projects:

FROM node:24-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:24-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static
COPY --from=build /app/public ./public
USER node
EXPOSE 3000
CMD ["node", "server.js"]

If your app has no public folder, drop that COPY line.

3. Create the project

  1. Open Projects and click New project.
  2. Fill in the form (the fields are explained below).
  3. Leave Deploy on every push to the branch on if you want automatic deploys.
  4. Click Create project.
FieldWhat to enter
Name, SlugThe slug is used for the container name.
Repository, BranchThe branch defaults to the repository's default branch.
ServerWhere the app is built and run.
Container portThe port your app listens on inside the container. When we find next in your package.json we show Detected: nextjs and suggest 3000. An EXPOSE line in your Dockerfile wins.
Root directoryFor monorepos, the folder of the app. Leave it empty for the repository root.
DockerfilePath to the Dockerfile, default Dockerfile.
Health check pathA path that returns 2xx when the app is ready, default /.

4. Deploy

Click Deploy on the project page. You can follow the build log live; select any deployment to see its log.

What happens on a deploy:

  1. The agent on your server clones the exact commit and runs docker build with your Dockerfile.
  2. It starts the new container on a private port on 127.0.0.1 with your environment variables.
  3. It waits for the health check path to answer successfully twice in a row (up to 90 seconds).
  4. Only then does it switch traffic to the new container and remove the old one. If the health check fails, the old version keeps running.

Environment variables are available when the app runs, not while the image builds. If your build needs a value, set it in the Dockerfile.

5. Make it reachable

A new project has no public address yet: the app listens on a private port on the server. Add a custom domain to put it on the internet with HTTPS.

Automatic deploys

With Deploy on push on, every push to the project's branch starts a deployment. To run tests or require an approval first, turn on a pipeline.

Roll back

Every earlier successful deployment shows Roll back to this. A rollback re-releases the old image right away, without rebuilding.

Require approval for production

Turn on Production deploys need approval by another member on the project page. Deploys then wait until a different member clicks Approve (or Reject). The person who started a deploy cannot approve it.

Change settings later

The project settings card lets you change the name, branch, root directory, Dockerfile, health check path, container port, a memory limit, and Deploy on push. Changes apply to the next deployment. The server and repository can't be changed after creation.

Other targets

By default a project runs on one server. The Deploy Target card on the project page can also deploy to several servers behind a load balancer, or to a k3s cluster.