Next.js
Deploy a Next.js app: the source is shipped, the box installs, builds and runs it as a service on port 3000.
cd my-app
kvbox deploy
# ✓ my-app is live at https://my-app.kvbox.appWhat happens
Nothing is built on your machine:
- The source is shipped, without
node_modules,.nextand.git..envfiles go along. - The box installs it with your package manager, told by the lockfile: npm, pnpm or yarn (a bun project installs with npm).
- It runs your
buildscript, then starts the app withstarton port 3000 (or the port you gave on the first run, or--port 5400), where the address points. Both are required:"build": "next build"and"start": "next start", ascreate-next-appmakes them.
The app lives in /srv/app/current and runs as the systemd service kvbox-app: restarted if it dies, back after a reboot. The deploy waits up to 30 seconds for the app to answer on its port; if it never does, the deploy fails and prints the last lines of the app's log.
A redeploy installs and builds in a staging directory while the old app keeps serving, then swaps and restarts: a failed build changes nothing. It takes a minute or two, the time of an install and a build.
Environment variables
Set them with kvbox env and the app gets them; it is restarted when the list changes at the box's next start. A .env file in the project works too, since it is shipped. Its port stays the deploy's (3000 unless you gave another) whatever a PORT variable says.
In the box
kvbox connect my-app lands in a box with the whole project. The app's log:
kvbox exec my-app -- journalctl -u kvbox-app -n 100Defaults
The box is s (2 vCPU, 4 GB of RAM), since next build wants memory. It hibernates after an hour without visitors and wakes on the next one.