Skip to content
Levelrail

Deploy a Next.js app to your own server with Levelrail

One Linux box, one installer and a git repository. By the end the app is live behind HTTPS on a server you own, with logs and a one step rollback.

  • Beginner
  • 3 min read
On this page

Before you start

  • A Linux server (amd64 or arm64) with systemd and root access. The installer adds Docker if it is missing.
  • A Next.js app in a git repository the server can reach.
  • A terminal on the server, or on your own machine with the CLI installed.

Prepare the app

Set output: "standalone" in next.config for the smallest runtime image. Levelrail's Next.js preset fills in the port and health path, and keeps .next/cache on a volume so optimised images and ISR pages survive a redeploy.

next.config.ts
import type { NextConfig } from "next";

const config: NextConfig = {
  output: "standalone",
};

export default config;

Install and deploy

  1. Step 1Install the control plane

    Run the installer on the server. Its last lines print the dashboard address and a one time setup link.

    bash
    curl -fsSL https://levelrail.com/install.sh | sudo sh
  2. Step 2Create the admin account

    Open the setup link and choose a password. The first sign in offers a free certificate on an automatic hostname with one click, so you can have HTTPS before you touch DNS.

  3. Step 3Sign the CLI in

    On the dashboard home, the Connect your CLI card shows a ready made command with a single use pairing code. Paste it into your terminal. The installer already put levelrail-cli on the server's path.

    bash
    levelrail-cli login --api-url http://<server-ip>:8080 --code ABCD-EF23
  4. Step 4Preview the plan

    Import the repository without deploying first. Without --deploy, the CLI only prints the deployment plan and changes nothing, so you can read it before anything is created.

    bash
    levelrail-cli import https://github.com/your-org/your-app
  5. Step 5Create and deploy the app

    Run the same command with --deploy to create the app and start its first build.

    bash
    levelrail-cli import https://github.com/your-org/your-app --deploy
  6. Step 6Find the address

    open prints the app's public addresses, custom domain first and then the automatic URL.

    bash
    levelrail-cli open your-app

Logs and rollback

  1. Step 7Read the logs

    Read an app's recent logs from the terminal. The dashboard has the same logs with search.

    bash
    levelrail-cli logs your-app
  2. Step 8Roll back a bad deploy

    Deploys are gated on readiness and every release keeps its image, so going back to the previous successful deploy is one command.

    bash
    levelrail-cli rollback your-app

To deploy on every push, connect the repository through your git host's webhook from the app's source settings. The Levelrail docs cover webhooks, preview environments and custom domains.

If something fails

  • The installer says the control plane did not become healthy: check systemctl status levelrail and journalctl -u levelrail -n 100 --no-pager. A port already in use is a common cause.
  • The installer reports a checksum mismatch: stop and run it again. Never skip the checksum check to get past it.
  • The CLI says connection refused when signing in: it points at the wrong address. Check the --api-url value against the dashboard address.
  • An import says connection refused: the control plane is not running. Start it with systemctl start levelrail.
Keep going
Next

Take it further with Levelrail

The product page covers what it does, how to install it and where the docs live.