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 (
amd64orarm64) 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
Dockerfileor 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:
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.shThe installer prints a dashboard link with a one-time setup token. Open an SSH tunnel from your Mac:
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.
alias levelrail-cli=/Applications/Levelrail.app/Contents/MacOS/levelrail-cli
export APP_API_URL=http://127.0.0.1:18080
levelrail-cli login --deviceLeave 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:
cd ~/code/demo-app
levelrail-cli deploy --dry-runThis output is from a small sample folder, with the path shortened:
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 stdoutThen deploy:
levelrail-cli deployThe 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.
levelrail-cli apps env import demo-app --file .env.server --dry-run
levelrail-cli apps env import demo-app --file .env.server --applyThe 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:
pg_dump --no-owner --no-privileges "$LOCAL_DATABASE_URL" > main.sqlCreate 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:
levelrail-cli databases create --name main-db --engine postgres --version 17 --waitImport the dump and connect the app:
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-appThe 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:
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 --waitA 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#
| Check | Command |
|---|---|
| App is healthy | levelrail-cli apps status demo-app |
| Logs look right | levelrail-cli logs demo-app |
| Database is connected | levelrail-cli apps connections list demo-app |
| Way back after a bad release | levelrail-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.