Skip to Content
PlatformBuilds

Builds

Builds turn source into a running StackMachine app version. Send files or a ZIP archive, define install/build/start commands, stream logs while the build runs, and receive the live app URL when the version is ready.

Features

Files and ZIP uploads

For small deploys, pass a files map directly to client.deployments.create. For larger bundles, upload a ZIP with client.files.upload and deploy from the returned uploadUrl.

Build commands

Set installCmd, buildCmd, and startCmd so StackMachine can install dependencies, compile assets, and boot the runtime process.

Streaming progress

The returned deployment is created immediately with a build ID. Call deployment.wait and attach onProgress to watch stdout, stderr, runtime messages, and build lifecycle events.

Repeatable releases

Use allowExistingApp when pushing a new version of an existing app. StackMachine creates a fresh app version while preserving the app identity and domains.

Common workflow

  1. Prepare source files and optional environment variables.
  2. Create a deployment with inline files or an uploaded ZIP URL.
  3. Wait for the build to finish and inspect progress logs.
  4. Use the returned app version to open the live URL or fetch runtime logs later.

SDK examples

Create and wait for a build

This example builds a JavaScript app from inline files, custom commands, and environment variables.

builds.js
1
const deployment = await client.deployments.create(
2
  {
3
    appName: "edge-storefront",
4
    owner: "stackmachine",
5
    files: {
6
      "package.json": JSON.stringify({
7
        type: "module",
8
        scripts: {
9
          build: "node build.js",
10
          start: "node server.js",
11
        },
12
        dependencies: {},
13
        devDependencies: {},
14
      }),
15
      "build.js": [
16
        'import { mkdirSync, writeFileSync } from "node:fs";',
17
        'mkdirSync("dist", { recursive: true });',
18
        'writeFileSync("dist/index.html", "<h1>Hello from StackMachine</h1>");',
19
      ].join("\n"),
20
      "server.js": [
21
        'import { createServer } from "node:http";',
22
        'import { readFileSync } from "node:fs";',
23
        "",
24
        "createServer((req, res) => {",
25
        ' res.setHeader("content-type", "text/html");',
26
        ' res.end(readFileSync("dist/index.html"));',
27
        "}).listen(Number(process.env.PORT || 3000));",
28
      ].join("\n"),
29
    },
30
    installCmd: "npm install",
31
    buildCmd: "npm run build",
32
    startCmd: "npm start",
33
    envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }],
34
  },
35
  {
36
    onUploadProgress: ({ percent }) => console.log("upload", percent),
37
  },
38
);
39
 
40
const appVersion = await deployment.wait({
41
  onProgress: ({ datetime, stream, message }) => {
42
    console.log(datetime, stream, message);
43
  },
44
});
45
 
46
console.log(appVersion.app.url);

Source: stackmachine/sdks  JavaScript examples.