Skip to content
Get started

Deploy a version

View as Markdown

mk deploy takes your game from your machine to the servers of a network. It builds the project as vite build does, uploads what the build wrote to dist/ as a version, and deploys the version to a target: every server the target’s selector picks runs it.

Before you start: you need a network with at least one server in it. See Create a network and Let servers in in Connect. mk talks to the Minekube API on your machine (mk api) unless you name another; for staging during the preview, set MINEKUBE_API=https://api.staging.minekube.com or api in vite.config.ts.

A target is a network and the servers a label selector picks there. Add one to vite.config.ts:

vite.config.ts
import { minekube } from "@minekube/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
minekube({
bundles: { "my-game": { platform: "paper", entry: "src/game.ts" } },
targets: {
prod: { network: "my-network", selector: "*" },
canary: { network: "my-network", selector: "channel=canary" },
},
}),
],
});

"*" is every server of the network, written out, so a forgotten selector never rolls out to all of them.

In your project:

Terminal window
mk deploy canary

With only one target, mk deploy needs no argument. It prints the version it deployed:

Built my-game (paper 26.3, 652 KB) into dist
Deployed version 536a8f9a9253 to canary (the servers channel=canary picks in my-network): my-game (paper 26.3, 652 KB)

The version is named by the hash of its bundles, so deploying the same code twice makes no new version. Every server whose labels match runs it. A label comes from the server itself, in its connector.json, or from the invite or trust rule that let it in. A canary is a set of servers labelled channel=canary: try a version there first, then deploy it to prod.

--message and --tag describe the version, up to 100 and 25 characters. Without them, mk deploy takes the subject of the project’s last git commit and its hash, 12 characters with -dirty for uncommitted changes.

Terminal window
mk versions upload
mk versions deploy 536a8f9a9253 --target prod

mk versions upload builds and uploads a version without deploying it. mk versions deploy deploys a version uploaded before to a target. The id as mk versions list prints it is enough, or more of it (mk versions list --full) should two versions share those 12 characters.

Each server’s connector gets the new deployment, downloads the bundles it does not have, and the Minekube plugin swaps the game in. Players stay connected. On the server, the log says Reloaded <id> (<revision>).

Terminal window
mk versions list
mk deployments list

mk versions list shows the network’s 50 newest versions with the selectors that run each. mk deployments list shows what runs where, since when and by whom, and which of your targets each deployment belongs to.

mk deploy uploads exactly what dist/ holds after the build. dist/minekube.json names each bundle with its platform, the platform version it is built for and its SHA-256, and mk checks every file against it first. Before it deploys, mk deploy lists the servers of the target that run another version of the platform, by the registry’s minekube.com/version label; --strict-versions refuses then. Client bundles stay on your machine: networks run server bundles only.

Was this helpful?