Install
Markdown
Ask AI
Share

Move a Local App to Your Own Linux Server with Levelrail

Take an app from your Mac to a Linux server you own: install Levelrail, upload the folder, set variables, copy the Postgres data and add a domain.

Markdown
Ask AI
Share

Your app works on your Mac. To keep it online when the lid is closed, move four things to a Linux server: the code, the variables, the data and the domain.

What you need#

  • A Linux server (amd64 or arm64) with systemd and root access. 1 vCPU, 1 GB of RAM and 10 GB of disk boots the platform, and 2 vCPU with 2 GB is more comfortable once builds and apps run.
  • Ports 80 and 443 free and reachable. Keep port 8080 closed to the internet.
  • A project with a Dockerfile or a detected stack such as Node, Go, Python or Java.
  • A domain, if you want your own address.

Step 1: install Levelrail on the server#

Run this on the server. It checks the installer against the published checksum before running it:

bash
curl -fsSLO https://github.com/glincker/levelrail/releases/latest/download/install.sh
curl -fsSLO https://github.com/glincker/levelrail/releases/latest/download/checksums.txt
grep ' install.sh$' checksums.txt | sha256sum -c - && sudo sh install.sh

The installer prints a dashboard link with a one-time setup token. Open an SSH tunnel from your Mac:

bash
ssh -L 18080:127.0.0.1:8080 <user>@<server-ip>

Open the printed link with http://127.0.0.1:18080 as its address, keeping the /login#setup=<token> part, and choose the admin password. Local port 18080 avoids a clash with anything on your Mac’s 8080. If the installer picked a different server port, use it in place of 8080.

Back up /var/lib/levelrail-data/master.key, which encrypts your stored secrets. More detail is on the install page.

Step 2: sign in from your Mac#

With Levelrail for Mac installed, the CLI is inside the app. Otherwise see the CLI install options.

bash
alias levelrail-cli=/Applications/Levelrail.app/Contents/MacOS/levelrail-cli
export APP_API_URL=http://127.0.0.1:18080
levelrail-cli login --device

Leave the tunnel open and approve the printed code in the dashboard.

Step 3: preview, then deploy the folder#

Look at what would be sent first:

bash
cd ~/code/demo-app
levelrail-cli deploy --dry-run

This output is from a small sample folder, with the path shortened:

output
deploy: ~/code/demo-app as app "demo-app" (Dockerfile)
  4 files, 124 B to upload (.gitignore, node_modules, .git and .env files are skipped)
  largest files:
          76 B  Dockerfile
          20 B  package.json
          15 B  src/server.js
          13 B  .gitignore
  dry run: nothing is sent, the full list follows on stdout

Then deploy:

bash
levelrail-cli deploy

The CLI asks for confirmation, uploads the folder, streams the build log and prints the app URL once the deploy is healthy. The app is named after the folder. If your project is a Compose file, follow deploying a Compose app instead.

Step 4: bring your variables#

Copy .env to .env.server, edit the values for the server and delete the local DATABASE_URL line, since step 5 sets that one. Keep the new file out of git.

bash
levelrail-cli apps env import demo-app --file .env.server --dry-run
levelrail-cli apps env import demo-app --file .env.server --apply

The dry run reports key names, not values. Keys that look sensitive go to the secret store.

Step 5: move the Postgres data#

Stop writes to the local app, then dump the database. Set LOCAL_DATABASE_URL to your local connection string:

bash
pg_dump --no-owner --no-privileges "$LOCAL_DATABASE_URL" > main.sql

Create a database on the server with the same or a newer major version, and wait for it to be ready. Change 17 to suit yours:

bash
levelrail-cli databases create --name main-db --engine postgres --version 17 --wait

Import the dump and connect the app:

bash
levelrail-cli databases import main-db --in main.sql
levelrail-cli apps connect demo-app main-db --env-var DATABASE_URL
levelrail-cli apps apply demo-app

The connection string lands in DATABASE_URL and the restart picks it up. The default size limit for an import is 1 GiB. Delete main.sql once you have checked the data, since it holds a copy of your database.

Redis used as a cache can start empty: create it with --engine redis and a version, then connect it under its own variable name.

Step 6: add your domain#

Create an A record that points at the server’s public IP. Then:

bash
levelrail-cli apps domains add demo-app app.example.com --wait
levelrail-cli domains check demo-app app.example.com
levelrail-cli domains cert app.example.com --wait

A routed domain starts on a self-signed certificate. The last command runs preflight checks and requests a public Let’s Encrypt certificate. Public certificates are a server setting, so it applies to every domain on that server.

Check before you switch over#

CheckCommand
App is healthylevelrail-cli apps status demo-app
Logs look rightlevelrail-cli logs demo-app
Database is connectedlevelrail-cli apps connections list demo-app
Way back after a bad releaselevelrail-cli rollback demo-app

Then set up a backup target and try one restore.

How this was checked#

The commands follow the Levelrail docs and the CLI help for v1.5.20. The --dry-run output above is real. The server steps were not run end to end for this post, so no server output is shown.

Next steps#

Start with the server install, or try your app locally first with Levelrail for Mac. If your project lives in git, levelrail-cli up builds from the remote instead.

Frequently asked questions #

Do I need a git repository or a registry?

No. levelrail-cli deploy uploads the folder and the server builds it. You can connect a git source later.

Is my .env file uploaded?

No. Secret-looking files, including .env files, are skipped. Import the variables with levelrail-cli apps env import.

How does my local database get to the server?

Dump it with pg_dump, create a database on the server and import the dump with levelrail-cli databases import.

Next steps

Keep reading