Skip to content

Deploy from files

Upload source files inline and wait for the build to finish.

Pass your source files in a files map to deployments.create. StackMachine automatically detects the project, installs dependencies, and builds it for you. Include dependency manifests and lockfiles alongside the source; you can omit install/build/start commands. The SDK uploads your bundle; then call wait() to stream build logs until the app is live. For an existing project folder, follow Deploy from ZIP.

Start a deployment

Pass appName / app_name, owner, and a files object whose keys are paths in the bundle. The call returns right away with a buildId and QUEUED status — the build has not finished yet.

Optional: envVars / env_vars, region, and upload progress (onUploadProgress / on_upload_progress).

deploy-from-files.jsdeploy_from_files.py
// Request: appName, owner, files (required); optional envVars, region
const deployment = await client.deployments.create(
  {
    appName: "hello-stackmachine",
    owner: "stackmachine",
    files: {
      "index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
    },
    envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }], // sensitive: hide value in the dashboard
    region: "iad", // region slug where the app is deployed
  },
  {
    onUploadProgress: ({ percent }) => {
      console.log("Upload progress %:", percent * 100);
    },
  },
);
// Should return: {
console.log(deployment.buildId, deployment.status);
# Request: app_name, owner, files; optional env_vars, region
deployment = client.deployments.create(
    app_name="hello-stackmachine",
    owner="stackmachine",
    files={
        "index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
    },
    env_vars=[{"name": "NODE_ENV", "value": "production", "sensitive": False}],  # sensitive: hide value in the dashboard
    region="iad",  # region slug where the app is deployed
    on_upload_progress=lambda p: print("Upload progress %:", p.percent * 100),
)
# Should return: {
print(deployment.build_id, deployment.status)

Wait for the build

Call wait() on the deployment object from the previous step. Use onProgress / on_progress to print build logs as they arrive. When the promise resolves, you get an app version with the live url and adminUrl / admin_url.

deploy-from-files.jsdeploy_from_files.py
const appVersion = await deployment.wait({
  onProgress: ({ datetime, stream, kind, message }) => {
    // Should log: {
    //   "kind": "LOG",
    //   "message": "Building...",
    //   "datetime": "2024-01-15T12:00:00.000Z",
    //   "stream": "STDOUT"
    // }
    console.log(datetime, stream, kind, message);
  },
});
// Should return: {
console.log(appVersion.id, appVersion.app.url, appVersion.app.adminUrl);
app_version = deployment.wait(
    on_progress=lambda e: print(e.datetime, e.stream, e.kind, e.message),
)
# Should return: {
print(app_version.id, app_version.app.url, app_version.app.admin_url)

Source: stackmachine/sdks examples.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close