Deploy a version
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:// or api in vite.config.ts.
Name a target
Section titled “Name a target”A target is a network and the servers a label selector picks there. Add one to 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.
Deploy
Section titled “Deploy”In your project:
mk deploy canaryWith only one target, mk deploy needs no argument. It prints the version it deployed:
Built my-game (paper 26.3, 652 KB) into distDeployed 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.
Upload now, deploy later
Section titled “Upload now, deploy later”mk versions uploadmk versions deploy 536a8f9a9253 --target prodmk 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.
Watch it arrive
Section titled “Watch it arrive”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>).
mk versions listmk deployments listmk 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.
What goes up
Section titled “What goes up”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.
Related
Section titled “Related”- Roll back and undeploy: go back to an earlier version.
- Vite plugin and configuration: every field of
minekube(). - How servers get their bundles: what happens between
mk deployand the swap. - CLI reference: every flag of
mk deploy.
Was this helpful?
Thanks for the feedback.