Advanced phase workflows
The following options are useful when you need more control over image inputs or filesystem changes.
Install the client tools and sign in
Beams is a Teleport project and uses official Teleport client tools.
The client tools include tsh to sign in and run commands, and tctl to administer your cluster if you have permission.
Cluster: example.beams.run. Edit this example to use your cluster name.
Install version 18.11.10 of the client:
Download and open the macOS installer, then follow its instructions.
curl -O https://cdn.teleport.dev/teleport-tools-18.11.10.pkg
open teleport-tools-18.11.10.pkgFor Linux x86-64, download and install the client tools:
curl -O https://cdn.teleport.dev/teleport-v18.11.10-linux-amd64-bin.tar.gz
tar -xzf teleport-v18.11.10-linux-amd64-bin.tar.gz
sudo ./teleport/installFor Windows x86-64, run these commands in PowerShell. Add the extraction directory ($env:LOCALAPPDATA\Teleport) to your user PATH to use tsh in future terminals; the last command adds it to this terminal's PATH.
Invoke-WebRequest -Uri https://cdn.teleport.dev/teleport-v18.11.10-windows-amd64-bin.zip -OutFile teleport.zip
Expand-Archive -Path teleport.zip -DestinationPath "$env:LOCALAPPDATA\Teleport" -Force
$env:Path += ";$env:LOCALAPPDATA\Teleport"Follow the official client tools install guide for other versions and architectures.
Check that you’re running v18.11.10 of the client with tsh version.
tsh versionI sign in without a password (e.g. a passkey).
tsh login --proxy='example.beams.run' --auth=passwordlessI have a password & MFA set up for my account:
Replace you@example.com with your Teleport username.
tsh login --proxy='example.beams.run' --user=you@example.comI sign in with SSO (e.g. Okta, GitHub, SAML).
tsh login --proxy='example.beams.run'Rebuild dependencies under /home
Use metadata.rebuild_home_paths when generated files belong beside your application but should be recreated by commands, rather than saved from interactive work. It is available only on rebuild stages. Paths must be clean absolute paths with no patterns.
This example saves a Node.js project’s source in a snapshot phase and rebuilds node_modules in a child phase. Before you start, have a project with at least one npm dependency and a package-lock.json that matches package.json. If you need to generate the lockfile, run npm install --package-lock-only from your project directory before copying the source. For the basic build-beam workflow, see Snapshots.
From your workstation, create the source phase. The built-in default:v1 image already includes Node.js and npm, so you don’t need to create a separate tools phase.
tsh phase add app-source --from=default:v1In the build beam that opens, put the project in /home/beams/app, including both manifest files but not node_modules. Then save the source:
tsh phase snapshot --finalOn your workstation, save this as app-dependencies.yaml:
version: v1
metadata:
name: app-dependencies
from: app-source
rebuild_home_paths:
- /home/beams/app/node_modules
commands:
- comment: Reinstall dependencies from the saved application lockfile
command: npm
args: [ci]
workdir: /home/beams/appFrom the directory containing app-dependencies.yaml, apply it and start a beam to inspect the result:
tsh phase apply -f app-dependencies.yaml &&
tsh beams add --phase=app-dependenciesInside that beam, check that the saved manifests are present and the installed dependencies can be listed:
cd /home/beams/app &&
test -f package.json && test -f package-lock.json && test -d node_modules &&
npm ls --depth=0The check should exit successfully and list your project’s direct dependencies without missing-dependency errors. This inspection beam cannot save changes back. Continue editing with tsh phase edit app-source, as described below.
npm ci runs as root. It can write to the declared node_modules directory, but the build still fails if it changes other files under /home. Later interactive snapshot builds based on app-dependencies cannot save changes to node_modules. The exception works in both directions: commands can recreate the declared paths, and interactive snapshots must leave them to the command build.
To update the source, run tsh phase edit app-source, edit the application or lockfile under /home/beams/app, then save with tsh phase snapshot --final. Its rebuild child automatically reruns npm ci on the updated source. The declaration on the child does not change the original source phase’s snapshot rules.
Use a raw command configuration
Prefer tsh phase apply -f phase.yaml for repeatable setups. For a single rebuild phase, --commands-file accepts one YAML document in the raw command format. The file must contain at least one build command. Unknown fields, empty files, and multiple documents are rejected.
Save this example as raw-build.yaml:
commands:
- comment: Install system tools
command: /bin/sh
args:
- -c
- apt-get update && apt-get install -y git curl
workdir: /
env:
- name: DEBIAN_FRONTEND
value: noninteractive
services:
- name: prepare-workspace
comment: Create a workspace for the beam user
type: pre-start
context: user
command: mkdir
args: [-p, /home/beams/app]
workdir: /home/beamsCreate or replace the phase:
tsh phase add raw-tools --commands-file=raw-build.yaml
tsh phase edit raw-tools --commands-file=raw-build.yamlThe raw format accepts these top-level fields:
| Field | Meaning |
|---|---|
commands |
Required, nonempty list of commands executed in order as root. Each command requires command, and may set args, comment, env, and workdir. The default working directory is /. |
services |
Optional list of named startup programs. Each service requires name and command, and may set args, comment, env, workdir, type, and context. Defaults are /home/beams, background, and user. |
protected_paths |
Optional list of clean absolute home paths that commands may change. Other home files must remain unchanged. Descendant interactive snapshots cannot save changes to the declared paths. |
command names an executable. args is its argument list, without shell expansion. For a shell script, invoke /bin/sh with -c as shown above. env is a list of name and value pairs. Services run as beams, even though build commands run as root. Replacing a raw command configuration keeps the existing phase’s parent. It cannot be combined with --from, --copy, or forking.
Copy files without a YAML configuration
For a one-off copy, repeat --copy with an absolute destination followed by the local source:
tsh phase add app-files --copy=/opt/app/config:./config --copy=/etc/app.conf:./app.conf
tsh phase edit app-files --copy=/opt/app/config:./updated-configThe same destination and replacement rules as YAML copy stages apply. Use this flag only when creating or replacing copy phases. It cannot be combined with --commands-file, --fork, or --fork-from. When editing, it also cannot be combined with --from.
Edit from another phase’s snapshot
To replace a snapshot phase’s contents with a starting point from another snapshot phase, use:
tsh phase edit app-work --from=other-workBoth phases must exist and have the same parent. The source must have a successful snapshot and cannot be a copy or rebuild phase. This opens a build beam rather than immediately replacing the target image. Save with tsh phase snapshot --final when ready. The usual restrictions on active builds and dependent snapshot phases apply.
Inspect a specific snapshot
For a failed build, prefer the inspection command printed in the error. To select a particular saved or failed image yourself, supply its explicit reference:
tsh beams add --phase='app-work@sha256:<digest>'You must have access to the phase that produced the snapshot, and its recorded identity must still be valid. Failed snapshots must not have expired. Inspect /var/log/beam/build.log inside the resulting beam. The inspection beam cannot save changes back. To save a repair, update the phase’s configuration or open an eligible snapshot phase with tsh phase edit.
Reuse an explicit snapshot reference
These commands are for snapshots already captured in a build beam. For everyday work, use tsh phase snapshot and tsh phase add NAME --fork inside the beam instead.
tsh phase snapshot app-work --from='parent@sha256:<digest>'
tsh phase add app-experiment --fork-from='parent@sha256:<digest>'The prefix names the snapshot’s parent, not its originating phase. Saving requires a snapshot created for the existing target. It cannot save another phase’s snapshot to that target, replace build commands, or change the parent. It saves only the referenced contents, not later changes in the running beam. --final cannot be combined with --from.
Forking creates a new phase from the captured filesystem. Outside a beam, a reference whose parent is a built-in base image also requires --region to identify the snapshot’s original region. Copy and rebuild phases cannot be forked, including through explicit digests. Snapshot references never move images between regions.