+Zerops allows you to build custom runtime images (CRI) when the default base runtime images don't meet your application's requirements. This is an optional phase in the [build and deploy pipeline](/features/pipeline#runtime-prepare-phase-optional).
-
+Alpine is a versatile base for running anything not explicitly offered as a dedicated Zerops runtime. You can install any packages and tools you need, treating it as a clean OS to customize however you want.
-GET STARTED
+It is also a great option when you need a specific version of a technology (like Go, Node.js, or PHP) that Zerops doesn't support by default—whether it's an older version for legacy projects or a newer release not yet available.
-
Quickstart and concept
+## Configuration
-[Quickstart](/zcp/quickstart) for hands-on; [How it works](/zcp/concept/how-it-works) for the work loop.
+### Default Runtime Environment
-
+The default runtime environment contains:
-
+- {data.alpine.default}
+- [zCLI](/references/cli)
+-
-SETUP
+### When You Need a Custom Runtime Image
-
Remote or local workspace
+Since Alpine serves as a general-purpose base, you'll likely want to customize it for your specific use case. Common scenarios include:
-[Remote or local setup](/zcp/setup/choose-workspace), [Trust model](/zcp/security/trust-model), and [Production boundary](/zcp/security/production-policy).
+:::important
+You should not include your application code in the custom runtime image, as your built/packaged code is deployed automatically into fresh containers.
+:::
-
+Here are examples of configuring custom runtime images in your `zerops.yml`:
-
+### Basic Setup
-WORKFLOWS
+### Using Build Files in Runtime Preparation
-
Build, package, promote
+For complete configuration details, see the [runtime prepare phase configuration guide](/features/pipeline#configuration).
-[Build and ship](/zcp/workflows/build-with-zcp), [Package a running service](/zcp/workflows/package-running-service), [Promote to production](/zcp/workflows/promote-to-production).
+## Process and Caching
-
+### How Runtime Prepare Works
+The runtime prepare process follows the same steps for all runtimes. See [how runtime prepare works](/features/pipeline#how-it-works) for the complete process details.
-
+### Caching Behavior
+Zerops caches custom runtime images to optimize deployment times. Learn about [custom runtime image caching](/features/pipeline#custom-runtime-image-caching) including when images are cached and reused.
-REFERENCE
+### Build Management
+For information about managing builds and deployments, see [managing builds and deployments](/features/pipeline#manage-builds-and-deployments).
-
Troubleshooting and lookup
+:::warning
+Local Storage volumes are not available during the runtime prepare phase, and start commands (such as a SeaweedFS mount) do not run there.
+:::
-[Workflows in depth](/zcp/reference/agent-workflow), [ZCP MCP tools](/zcp/reference/mcp-operations), [Troubleshooting](/zcp/reference/troubleshooting), [Glossary](/zcp/glossary).
+## Troubleshooting
-
+If your `prepareCommands` fail, check the for specific error messages.
-
+----------------------------------------
-For the broader feature concept — why coding agents need real project infrastructure rather than a sandbox or generated artifact — start with [Infrastructure for Coding Agents](/features/coding-agents).
+# Alpine > How To > Deploy Process
-With the generated workflow instructions enabled, an app task ends in proof or a blocker. **Proof** is a deployed runtime plus the URL, endpoint response, UI state, worker result, or stored data that shows the requested behavior works. A **blocker** is the agent reading the relevant Zerops evidence and naming the missing credential, decision, unsupported fit, or repeated failure.
-Your prompt can stay about the product. Name the stack, runtime layout, acceptance criteria, delivery path, external credentials, or risky approval only when those decisions matter.
-## What the agent gets
+----------------------------------------
-
+# Alpine > How To > Env Variables
-
-STATE
-### Current state
+----------------------------------------
-Services, runtime layout, managed dependencies, env-var keys and references, logs, events, deploy history, verification state, and saved work state.
+# Alpine > How To > Filebrowser
-
-
-CONTROLS
+----------------------------------------
-### Zerops operations
+# Alpine > How To > Logs
-Project-scoped tools for discovering services, changing env vars, managing runtimes, deploying, verifying, scaling, public access, and delivery setup.
-
-
+----------------------------------------
-INSTRUCTIONS
+# Alpine > How To > Scaling
-### Workflow
-The generated instructions combine service setup and app development: inspect state, choose the runtime target, use or create services, wire code and `zerops.yaml`, deploy, verify, and choose delivery. The Zerops work stays behind the product task instead of becoming another checklist.
-
+----------------------------------------
-
+# Alpine > How To > Trigger Pipeline
-EVIDENCE
-### Evidence-based completion
-A build or deploy is not the finish line. A completed app task should end with a working URL, endpoint result, UI proof, or a blocker backed by logs, events, and verification evidence.
+----------------------------------------
-
+# Alpine > How To > Upgrade
-
-## What you no longer have to script
-Without this layer, an app prompt often turns into an operations runbook. With MCP tools and workflow instructions enabled, you should not need to paste:
+----------------------------------------
-- the service map, runtime target, dev/stage state, or managed-service inventory,
-- database credentials, private hostnames, env-var references, or generated connection strings,
-- build logs, runtime logs, event timelines, or a guess about why the last deploy failed,
-- a deploy/verify/recovery script for every task,
-- a recap after the chat loses context; the agent can read current workflow status.
+# Alpine > Overview
-**You still own the decisions that need human judgment:** product intent, technology constraints, acceptance criteria, external credentials, repository policy, and approval for destructive actions.
-## Where it runs
+[Alpine Linux ↗](https://alpinelinux.org/) is a lightweight, security-oriented Linux distribution based on musl libc and busybox, known for its small footprint and efficiency.
-The **same `zcp` binary** runs in both setups. In [remote setup](/zcp/setup/hosted-workspace), Zerops packages it as a `zcp@1` service with Browser VS Code and bundled agent wiring. In [local setup](/zcp/setup/local-agent-bridge), you install it on your machine and connect your own editor or CLI agent. The project surface is the same; the workspace, network access, deploy source, and safety profile differ.
+Alpine services in Zerops provide a minimal base environment for running applications built with technologies that aren't officially supported by Zerops, or for custom setups requiring full control over the runtime environment while keeping resource usage low.
-To start, add remote setup in Zerops or initialize local setup beside your editor or CLI agent. The [Quickstart](/zcp/quickstart) uses remote setup because it needs no local install.
+:::tip
+Do you have any questions? Check the step-by-step tutorial, browse the documentation and join our **[Discord](https://discord.com/invite/WDvCZ54)** community to get help from our team and other members.
+:::
-## Your agent, credentials, and workspace
+## Feature Highlights
-**Agent account.** ZCP supports multiple coding agents including Claude Code (Anthropic), Codex (OpenAI), Antigravity, and Grok Build. Remote setup can bundle one of these, already configured for MCP. Zerops wires the agent to the tools; you still authenticate with your own subscription login or API credentials.
+- [Create Alpine service](/alpine/how-to/create) — Start with creating an Alpine service using GUI or zCLI.
+- [zerops.yaml](/alpine/how-to/build-pipeline#add-zeropsyaml-to-your-repository) — See a full example of zerops.yaml file to configure your own app.
+- [Scaling configuration](/alpine/how-to/scaling) — Set up scaling of your Alpine service so that it runs smoothly while using only necessary resources.
-**Zerops token.** The MCP server connects through `ZCP_API_KEY`, a Zerops token limited to one project. Remote setup gets it from the platform; local setup reads it from `.mcp.json`. Token details live in [Tokens and credentials](/zcp/security/tokens-and-project-access).
+{" "}
-**Workspace freedom.** The `zcp@1` service is still a normal Zerops service. You can install another agent CLI, add private MCP servers or helper tools, edit `CLAUDE.md`, add team dotfiles, and adapt the workspace. Details live in [What remote workspace gives you](/zcp/setup/hosted-workspace).
+- [Customize build environment](/alpine/how-to/build-process#customize-build-environment)
+- [Customize runtime environment](/alpine/how-to/customize-runtime)
-:::caution Production boundary
-Use this setup for development or staging work. Production should stay in a separate Zerops project and receive released work through your CI or release process; see [Promote to production](/zcp/workflows/promote-to-production) for the practical flow and [Production boundary](/zcp/security/production-policy) for the policy.
-:::
+## When in doubt, reach out
-## What stays outside
+Don't know how to start or got stuck during the process? You might not be the first one, visit the FAQ section to find out.
-This section is not a replacement for Zerops platform references. The Zerops [build and deploy pipeline](/features/pipeline), [permissions](/features/rbac), networking, scaling, and service references remain canonical for platform behavior.
+In case you haven't found an answer (and also if you have), we and our community are looking forward to hearing from you on Discord.
+Have you built something that others might find useful? Don't hesitate to share your knowledge!
-----------------------------------------
+- [FAQ](/alpine/faq) — Most common questions in one place.
+- [Discord](https://discord.com/invite/WDvCZ54) — Join our core team and Zerops community on Discord. Ask questions and share your tips with other members.
-# Zcp > Glossary
+## Popular Guides
+- [zCLI](/references/cli) — Get even more out of Zerops with the zCLI command line tool.
+- [Zerops VPN](/references/networking/vpn) — Connect to your services easily with Zerops VPN.
-Use these definitions when a page, workflow status, agent handoff, or policy needs exact wording. In normal prompts, describe the outcome you want.
-## Core names
+----------------------------------------
-**ZCP MCP** - Zerops Control Plane MCP: the MCP tool surface that exposes project-scoped Zerops operations to coding agents.
+# Bun > How To > Build Pipeline
-**MCP server** - the Model Context Protocol server exposed by the `zcp` binary.
-**ZCP MCP tools** - the project-scoped Zerops operations exposed to an agent or MCP-capable client. In MCP clients, this usually appears as the `zerops` server.
+Zerops provides a customizable build and runtime environment for your Bun application.
-**`zcp` binary** - the executable that can run inside remote setup or on your machine in local setup.
+## Add zerops.yaml to your repository
-**`zcp` service** - the service instance in a Zerops project that hosts remote setup.
+Start by adding `zerops.yaml` file to the **root of your repository** and modify it to fit your application:
-**`zcp@1` service** - the Zerops service type used for remote setup.
+```yaml
+zerops:
+ # define hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build:
+ # REQUIRED. Set the base technology for the build environment:
+ base: bun@latest
-**zCLI** - the Zerops command-line client for humans, scripts, VPN, and CI. It is separate from ZCP MCP.
+ # OPTIONAL. Set the operating system for the build environment.
+ # os: ubuntu
-**zsc** - the in-container Zerops Setup Control utility used from `zerops.yaml`.
+ # OPTIONAL. Customise the build environment by installing additional packages
+ # or tools to the base build environment.
+ # prepareCommands:
+ # - sudo apt-get something
+ # - curl something else
-## Setup and workspace
+ # OPTIONAL. Build your application
+ buildCommands:
+ - bun i
+ - bun run build
-**Remote setup** - the `zcp` binary running inside a Zerops `zcp@1` service.
+ # REQUIRED. Select which files / folders to deploy after
+ # the build has successfully finished
+ deployFiles:
+ - dist
+ - package.json
+ - node_modules
-**Include Coding Agent** - remote setup option that adds a bundled agent CLI (Claude Code, Codex, Antigravity, or Grok Build) and preconfigures it to use ZCP MCP tools.
+ # OPTIONAL. Which files / folders you want to cache for the next build.
+ # Next builds will be faster when the cache is used.
+ cache: node_modules
-**Cloud IDE** - browser-based VS Code served by remote setup.
-
-**Browser VS Code** - dashboard entry point into the Cloud IDE.
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Sets the base technology for the runtime environment:
+ base: bun@latest
-**AI Agent environment** - recipe environment preset that creates app services plus remote setup with **Include Coding Agent** enabled.
+ # OPTIONAL. Sets the internal port(s) your app listens on:
+ ports:
+ # port number
+ - port: 3000
-**Local setup** - the `zcp` binary running on your machine after `zcp init`, while your local editor or CLI agent talks to it.
+ # OPTIONAL. Customise the runtime Bun environment by installing additional
+ # dependencies to the base Bun runtime environment.
+ # prepareCommands:
+ # - sudo apt-get something
+ # - curl something else
-**Env bridge** - local setup behavior that writes a local `.env` snapshot from Zerops env vars and references so local app code can reach managed services over VPN.
+ # OPTIONAL. Run one or more commands each time a new runtime container
+ # is started or restarted. These commands are triggered before
+ # your Bun application is started.
+ # initCommands:
+ # - rm -rf ./cache
-**Agent client** - the editor, CLI, hosted agent runtime, or custom MCP client that connects to ZCP MCP.
+ # REQUIRED. Your Bun application start command
+ start: bun start
+```
-## Generated files and state
+The top-level element is always `zerops`.
-**Generated workflow block** - the managed section in `CLAUDE.md` between `` and ``. Durable project instructions belong outside it.
+### Setup
-**`.mcp.json`** - local MCP server config. It points the local agent client at `zcp serve` and stores `ZCP_API_KEY`; keep it out of git.
+The first element `setup` contains the **hostname** of your service. A runtime service with the same hostname must exist in Zerops.
+Zerops supports the definition of multiple runtime services in a single `zerops.yaml`. This is useful when you use a monorepo. Just add multiple setup elements in your `zerops.yaml`:
-**`.zcp/state/`** - local workflow metadata for a project directory: known runtimes, pairing, delivery choice, sessions, deploy attempts, verify attempts, and coordination locks. It is not source code.
+```yaml
+zerops:
+ # definition for app service
+ - setup: app
+ # optional
+ build: ...
+ # optional
+ deploy: ...
+ # required
+ run: ...
-**Workflow state** - saved metadata that lets the agent resume, audit, or close a guided run after interruption.
+ # definition for api service
+ - setup: api
+ # optional
+ build: ...
+ # optional
+ deploy: ...
+ # required
+ run: ...
+```
-## Workflow
+Each service configuration contains at least the `run` section. Optional `build` and `deploy` sections can be added to further customize your process.
-**Bootstrap** - workflow phase that reads the current project and settles which runtime services and managed services the app should use before app code work starts.
+## Build pipeline configuration
-**Service setup** - the phase that decides which runtime services and managed services the app should use before app code work starts.
+### base
-**Develop** - workflow phase that changes app code/config, deploys, verifies reachability and behavior, and fixes failures from evidence.
+_REQUIRED._ Sets the base technology for the build environment.
-**Runtime target** - the app runtime selected for the current change, such as `appdev`, `appstage`, `app`, or a linked local target.
+Following options are available for Bun builds:
-
+ The base build environment contains {data.alpine.default}, the selected
+ major version of Bun,
+ [Zerops command line tool](/references/cli), `npm`,
+ `yarn`, `git` and `npx` tools.
+
-**Direct deploy** - deploy from the current source to the scoped runtime through ZCP MCP. The first verified running result uses direct deploy before delivery setup is applied.
+:::info
+You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository.
+:::
-**Reachability verification** - checks that the runtime exists, is running, has no recent blocking errors, and can answer an HTTP probe when it is an HTTP service.
+If you need to install more technologies to the build environment, set multiple values as a yaml array. For example:
-**Behavior verification** - checks that the requested app behavior works on the real URL, endpoint, worker result, or stored state.
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build:
+ # REQUIRED. Sets the base technology for the build environment:
+ base:
+ - bun@latest
+ prepareCommands:
+ - zsc add go@latest
+ ...
+```
-**Proof** - user-inspectable completion evidence, such as a URL, endpoint result, UI state, processed job, or stored result.
+See the full list of supported [build base environments](/zerops-yaml/base-list#runtime-services).
-**Blocker** - a clear stop state with evidence: failure category, runtime in scope, what was tried, and what decision or credential is needed.
+To customise your build environment use the [prepareCommands](build-pipeline#preparecommands) attribute.
-## Delivery and production
+:::note
+Modifying the base technology will invalidate your build cache. See our [Build Cache Documentation](/features/build-cache) for more details about cache invalidation.
+:::
-**Delivery choice** - what happens after a verified deploy: keep direct deploy, push to git, or hand off to CI/release/human process.
+### os
-**Delivery mode** - exact reference label for delivery choice:
+_OPTIONAL._ Sets the operating system for the build environment.
-- `auto` - keep direct deploy for future changes.
-- `git-push` - commit and push to a configured remote, then observe/verify any tracked build.
-- `manual` - external CI, release process, or a human owns future delivery.
+Following options are available:
-**Git-push capability** - whether remote setup has enough remote URL and credential setup to push from remote setup. It can exist even when the current delivery mode is `auto`.
+- `alpine`
+- `ubuntu`
-**Build integration** - repository-triggered build/deploy path that ZCP MCP may configure or observe, such as a Zerops dashboard webhook or GitHub Actions. It is separate from git-push capability and delivery mode.
+Default value is `alpine`.
-**Package a running service** - workflow that turns one verified runtime and its managed dependencies into a re-importable, git-backed Zerops bundle.
+We are currently using following os version:
-**Production release** - the release operation that moves verified dev or stage work into a separate production Zerops project. It is set up once per project (production infrastructure) and once per runtime (production deploy trigger), then runs every release.
+-
+ The base runtime environment contains {data.alpine.default}, the
+ selected major version of Bun, Zerops command line tool, `npm`, `yarn`, `git` and `npx` tools.
+
+:::info
+You can change the base environment when you need to. Just simply modify the `zerops.yaml` in your repository.
+:::
-----------------------------------------
+If you need to install more technologies to the runtime environment, set multiple values as a yaml array. For example:
-# Zcp > Workflows > Build With Zcp
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build:
+ # REQUIRED. Sets the base technology for the build environment:
+ base: bun@latest
+ ...
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Sets the base technology for the runtime environment:
+ base:
+ - bun@latest
+ prepareCommands:
+ - zsc add go@latest
+ ...
+```
-Use Build and ship for the decisions that shape normal app work. ZCP MCP gives the agent Zerops project state, platform guidance, project-scoped operations, deploy evidence, and recovery rules. You still decide what should be built, where it should run, how strict the acceptance criteria are, and what happens after proof.
+See the full list of supported [run base environments](/zerops-yaml/base-list).
-```text
-Build a task board.
-Tasks should stay saved after refresh.
-```
+To customise your build environment use the `prepareCommands` attribute.
-A prompt can be that short when the outcome is enough. Add detail when it changes behavior, architecture, stack, runtime layout, acceptance criteria, credentials, delivery, packaging, or the production release.
+### os
-The expected output is a verified running change, not only generated files. The agent should prove the request against a real runtime, real managed services when used, and the logs, events, and checks that explain what happened.
+_OPTIONAL._ Sets the operating system for the runtime environment.
-## The decisions
+Following options are available:
-
+ The base Bun environment contains {data.alpine.default} the selected
+ major version of Bun, [Zerops command line tool](/references/cli) and `npm`, `yarn`, `git` and `npx` tools. To install
+ additional packages or tools add one or more prepare commands:
+
-## 3. Choose delivery after proof {#choose-delivery-after-proof}
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build:
+ ...
-Delivery preference is how app work closes after there is a verified result. Include it in the original prompt or set it later.
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Customise the runtime environment by installing additional packages
+ # or tools to the base Bun runtime environment.
+ prepareCommands:
+ - sudo apt-get something
+ - curl something else
+ ...
+```
-The first functional deploy is still direct so the agent can prove the app runs. Delivery preference decides what happens after that proof and how later sessions should finish similar work.
+When the first deploy with a defined prepare attribute is triggered, Zerops will
-| Delivery preference | What it means | What to tell the agent |
-| ---------------------- | -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
-| **Keep direct deploy** | The agent keeps deploying directly to the target runtime for fast dev/stage iteration. | `Keep direct deploy for now.` |
-| **Push to git** | The agent commits and pushes working changes to the configured repository. | `When the app works, push changes to git@github.com:my-org/task-board.git.` |
-| **CI / handoff** | A repository integration, GitHub Actions workflow, release process, or human owns the next deploy. | `Set up GitHub Actions delivery for future deploys after the app works.` |
-| **CI / handoff** | A repository integration, GitHub Actions workflow, release process, or human owns the next deploy. | `Set up GitHub Actions delivery for future deploys after the app works.` |
+1. create a prepare runtime container
+2. optionally: [copy selected folders or files from your build container](build-pipeline#copy-folders-or-files-from-your-build-container)
+3. run the `prepareCommands` commands in the defined order
-The workflow records the delivery choice so later work can follow it. Git credentials, CI secrets, and production credentials are separate from `ZCP_API_KEY`; see [Tokens and credentials](/zcp/security/tokens-and-project-access).
+:::note
+`run.prepareCommands` run in the `/home/zerops` directory.
+:::
-## 4. Package a verified runtime {#package-a-verified-runtime}
+#### Command exit code
-After a runtime is verified, you can ask the agent to prepare it as a re-importable Zerops project bundle. Use this when the app should become a reusable starter, customer handoff, demo project, or clean staging project.
+If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](logs#prepare-runtime-log) to troubleshoot the error. If the command ends successfully, it returns the exit code 0 and Zerops triggers the following command. When all `prepareCommands` commands are finished, your custom runtime environment is ready for the deploy phase.
-The prompt can be one sentence:
+#### Cache of your custom runtime environment
-```text
-Package appstage as a buildFromGit import bundle, commit it, and push it to git so I can import it into a fresh Zerops project.
-```
+Some packages or tools can take a long time to install. Therefore, Zerops caches your custom runtime environment after the installation of your custom packages or tools is completed. When the second or following deploy is triggered, Zerops will use the custom runtime cache from the previous deploy if following conditions are met:
-The export workflow prepares `zerops-project-import.yaml` and `zerops.yaml` in the same git repo as the app. The import file contains one runtime with `buildFromGit:` pointing back to that repo, plus managed services needed for Zerops env references to resolve when the bundle is imported into a fresh project.
+1. Content of the [build.addToRunPrepare](#copy-folders-or-files-from-your-build-container) and `run.prepareCommands` attributes didn't change from the previous deploy
+2. The custom runtime cache wasn't invalidated in the Zerops GUI.
-The agent may still ask which runtime to package, which half of a dev+stage pair to use, how to classify project env vars, or how to configure git push. Once pushed, the target project can import the bundle from the dashboard or with `zcli project project-import zerops-project-import.yaml`.
+To invalidate the custom runtime cache go to `yyy`
-Packaging is not the next deploy of the same app. For the next app change, keep using the normal build/deploy/verify loop. Use packaging when the output you want is a git-backed import bundle; see [Package a running service](/zcp/workflows/package-running-service).
+When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly.
-## 5. Prepare the production release {#prepare-production-release}
+#### Single or separated shell instances
-The production release is where authority changes. The agent prepares verified work and release evidence; production execution belongs to Zerops project settings, CI, release tooling, or a deliberate human action with production credentials.
+You can configure your prepare commands to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands).
-The useful split is:
+### Copy folders or files from your build container
-| Job | How often | What happens |
-| --- | --- | --- |
-| **Production infrastructure** | Once per production project | Export the verified project as YAML in the GUI, edit it for production, then import it as a new project. |
-| **Production deploy trigger** | Once per production runtime | Connect the production runtime to git, usually with a tag trigger. |
-| **Production release** | Every release | Verify in dev/stage, push source to git, then trigger production through your tag or release process. |
-| **Production release** | Every release | Verify in dev/stage, push source to git, then trigger production through your tag or release process. |
+
+ The prepare runtime container contains {data.alpine.default}, the selected major version of Bun, [Zerops command line tool](/references/cli) and `npm`,
+ `yarn`, `git` and `npx` tools.
+
-Production should be a separate Zerops project without a `zcp` service. Production credentials are not `ZCP_API_KEY`; keep them in CI or release tooling. For the full release guide, see [Promote to production](/zcp/workflows/promote-to-production).
+The prepare runtime container does not contain your application code nor the built application. If you need to copy some folders or files from the build container to the runtime container (e.g. a configuration file) use the `addToRunPrepare` attribute in the [build section](#build-pipeline-configuration).
-## What the final answer should contain
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build:
+ ...
+ addToRunPrepare: ./runtime-config.yaml
-For a completed app task, the agent should report:
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Customise the runtime environment by installing additional packages
+ # or tools to the base Bun runtime environment.
+ prepareCommands:
+ - sudo apt-get something
+ - curl something else
+ ...
+```
-- the runtime service it changed,
-- the deploy or verification target,
-- the URL, endpoint, UI state, job result, or stored data that proves the requested behavior,
-- managed services, env vars, or delivery settings it touched,
-- the delivery preference, packaging output, or production release state that now applies.
+In the example above Zerops will copy the `runtime-config.yaml` file from your build container **after the build has finished** into the new **prepare runtime** container. The copied files and folders will be available in the `/home/zerops` folder in the new prepare runtime container before the prepare commands are triggered.
-If the task is incomplete, the final answer should name the blocker, the evidence read, what was tried, and the decision or credential needed from you.
+### initCommands
+_OPTIONAL._ Defines one or more commands to be run each time a new runtime container is started or a container is restarted.
-----------------------------------------
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build: ...
-# Zcp > Setup > Local Agent Bridge
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Run one or more commands each time a new runtime container
+ # is started or restarted. These commands are triggered before
+ # your Bun application is started.
+ initCommands:
+ - rm -rf ./cache
+```
+These commands are triggered in the runtime container before your Bun application is started via the [start command](build-pipeline#start).
-Local setup installs the `zcp` binary on your machine and runs it from the app directory where your agent works.
+:::note
+`run.initCommands` run in the `/var/www` directory.
+:::
-Use it when the agent should work next to local files, local data, your desktop editor, terminal tools, and git credentials. The MCP server limits Zerops operations to one project, but the agent client runs as your local user, so local approvals and filesystem allowlists matter.
+Use init commands to clean or initialise your application cache or similar operations.
-[Remote setup](/zcp/setup/hosted-workspace) is the safer default when the agent does not need local files or tools. Use local setup when local control is the point.
+:::caution
+The init commands will delay the start of your application each time a new runtime container is started (including the [horizontal scaling](scaling) or when a runtime container is restarted).
-:::warning Local setup maturity
-Local setup has more moving parts than remote setup and may change faster. The binary install path, `.mcp.json` shape, and files written by `zcp init` are still settling between releases.
+Do not use the init commands for customising your runtime environment. Use the [run:prepareCommands](build-pipeline#preparecommands-1) attribute instead.
:::
-## Choose a local starting point
-
-Pick the folder that should own app work:
+#### Command exit code
-- **Empty local directory.** Start with no app code yet. The agent can create the app structure and use the MCP tools to select or create Zerops services.
-- **Existing app directory.** Use this when app code, local data, editor setup, test fixtures, and git credentials already live on your machine.
-- **Recipe prepared for local setup.** Use a recipe to create the Zerops service baseline, then run the agent locally from the directory that should own source changes.
+If any of the `initCommands` fails, it returns an exit code other than 0, but deploy is **not** canceled. After all init commands are finished, regardless of the status code, the application is started. Read the [runtime log](logs#runtime-log) to troubleshoot the error.
-After that choice, the mechanics are the same: install `zcp`, run `zcp init`, add `ZCP_API_KEY`, start VPN when private service access is needed, and link a runtime when the agent should deploy.
+#### Single or separated shell instances
-## What local setup gives the agent
+You can configure your `initCommands` to be run in a single shell instance or multiple shell instances. The format is identical to [build commands](#buildcommands).
-- **Local files as source.** The agent edits the directory on your machine, and deploys use that working directory.
-- **Your editor and terminal.** Framework CLIs, test runners, local data, and local feedback stay under your normal tools.
-- **Your git credentials.** Pushes use your local git CLI, SSH agent, or credential helper.
-- **Zerops operations.** The MCP tools let the agent discover services, generate env snapshots, deploy to linked runtimes, read logs, and verify.
-- **Private service access through VPN.** Your local app and shell reach private service hostnames through `zcli vpn up`.
+### envVariables
-Security note: local setup cannot protect your laptop from the agent client. Configure approvals as you would for any local coding agent.
+_OPTIONAL._ Defines the environment variables for the runtime environment.
-## Prerequisites
+Enter one or more env variables in following format:
-- A Zerops project. Create one from the [Zerops dashboard](https://app.zerops.io/dashboard/project-add), from a [recipe](https://app.zerops.io/recipes), or use an existing development/staging setup.
-- [zCLI](/references/cli) installed and authenticated on your machine.
-- A compatible local agent client installed and logged in.
-- A **single-project Zerops token**. Multi-project tokens are refused at startup.
-- A local directory where the agent should run.
+```yaml
+zerops:
+ # define hostname of your service
+ - setup: app
+ # ==== how to run your application ====
+ run:
+ # OPTIONAL. Defines the env variables for the runtime environment:
+ envVariables:
+ NODE_ENV: production
+ DB_NAME: db
+ DB_HOST: db
+ DB_USER: db
+ DB_PASS: ${db_password}
+```
-You do not need MCP just to develop locally against Zerops services as a human. `zcli vpn up` plus your editor is enough. Add MCP when a local coding agent should also understand and operate Zerops.
+Read more about [environment variables](env-variables) in Zerops.
-## 1. Get `ZCP_API_KEY`
+### start
-The MCP server needs a Zerops API token that reaches exactly one project. For normal agent work, use a full-access token; read-only tokens can authenticate but fail on deploys, env changes, lifecycle actions, and other mutations. Token generation, rejected shapes, and rotation are covered in [Tokens and credentials](/zcp/security/tokens-and-project-access).
+_REQUIRED._ Defines the start command for your Bun application.
-## 2. Install `zcp`
+```yaml
+zerops:
+ # hostname of your service
+ - setup: app
+ # ==== how to build your application ====
+ build: ...
-```bash
-curl -sSfL https://raw.githubusercontent.com/zeropsio/zcp/main/install.sh | sh
+ # ==== how to run your application ====
+ run:
+ # REQUIRED. Your Bun application start command
+ start: bun start
```
-The installer downloads the latest release for your platform into `~/.local/bin`, or `/usr/local/bin` when run as root. Verify the install:
+We recommend starting your Bun application using `bun start`.
-```bash
-zcp version
-```
+### health check
-If your shell cannot find `zcp`, add the install directory to `PATH` and reload the shell.
+_OPTIONAL._ Defines a health check.
-## 3. Run `zcp init`
+`healthCheck` requires either one `httpGet` object or one `exec` object.
-From the local directory the agent should operate:
+#### httpGet
-```bash
-zcp init
-```
+Configures the health check to request a local URL using a HTTP GET method.
-`zcp init` writes local MCP config and agent instructions:
+Following attributes are available:
-- `.mcp.json` - MCP server config for this directory.
-- `CLAUDE.md` - agent instructions for Zerops work.
-- `.claude/settings.local.json` - Claude Code per-project settings when that client is used.
-- `~/.config/zerops/aliases` plus a shell-rc sourcing line - helper aliases for launching the agent here.
-- `.zcp/state/` - workflow state created when MCP first writes local state.
+