Skip to content

reusable 4 #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 33 additions & 48 deletions apps/docs/content/bun/how-to/customize-runtime.mdx
Original file line number Diff line number Diff line change
@@ -1,52 +1,37 @@
---
title: Customise Bun runtime environment
description: Learn how you can customise your node.js runtime environment on Zerops.
description: Learn how you can customise your Bun runtime environment on Zerops.
---

<p align="center">
<img
src="/img/screenshots/build_deploy_pipeline_custom_runtime.png"
alt="image"
width="100%"
height="auto"
/>
</p>

import data from '@site/static/data.json';

The default Bun runtime environment contains:

- <span>{data.alpine.default}</span>
- selected version of Bun selected when the runtime service was created.
- <a href="/references/cli">
`zCLI`
</a>
, Zerops command line tool
- `npm`, `yarn`, `git` and `npx` tools

If you prefer the Ubuntu OS instead of Alpine, set the [build.os](/bun/how-to/build-pipeline#os) attribute to `ubuntu`. To install additional packages or tools add one or more <a href="bun/how-to/build-pipeline#preparecommands1">`run.prepareCommands`</a> commands to your `zerops.yaml`.

When the first deploy with a defined `prepareCommands` attribute is triggered, Zerops will

1. create a prepare runtime container
2. optionally: [copy selected folders or files from your build container](bun/how-to/build-pipeline#copy-folders-or-files-from-your-build-container)
3. run the `run.prepareCommands` commands in the defined order

### Command exit code

If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](bun/how-to/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 prepare runtime container is automatically deleted after the prepare runtime phase has finished or failed.

### Custom runtime environment cache

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:

1. Content of the <a href="bun/how-to/build-pipeline#copy-folders-or-files-from-your-build-container">`build.addToRunPrepare`</a> and <a href="bun/how-to/build-pipeline#preparecommands-1">`run.prepareCommands`</a> attributes didn't change from the previous deploy
2. The custom runtime cache wasn't invalidated in the Zerops GUI.

To invalidate the custom runtime cache go to `yyy`

{/*TODO screenshot*/}

When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly.
import data from '@site/static/data.json'
import { SetVar } from '@site/src/components/content/var';
import CustomizeRuntimeContent from '@site/src/components/content/customize-runtime.mdx';

<SetVar name="serviceDisplay" value="Bun" />
<SetVar name="serviceVersion" value={data.bun.base[0][0]} />
<SetVar name="servicePath" value="nodejs" />
<SetVar name="packageManager" value="bun" />
<SetVar name="codeLanguage" value="yaml" />
<SetVar name="defaultEnvironment" value="Bun runtime and Git" />
<SetVar name="customReasons" value={[
'<strong>System packages for processing</strong>: When your app processes images, videos, or files (requiring packages like <code>sudo apk add imagemagick</code>)',
'<strong>Global Bun tools</strong>: When you need CLI tools or utilities available system-wide',
'<strong>Native dependencies</strong>: When your Bun packages require system libraries that aren\'t in the default environment',
'<strong>Different base OS</strong>: When you need Ubuntu instead of Alpine for specific compatibility requirements'
]} />
<SetVar name="basicSetupCode" value={`run:
os: ubuntu
base: {{serviceVersion}}
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- bun add -g some-package`} />
<SetVar name="buildFilesCode" value={`build:
addToRunPrepare:
- package.json
run:
prepareCommands:
- sudo apk add imagemagick
- bun install -g some-package`} />

<CustomizeRuntimeContent />
93 changes: 62 additions & 31 deletions apps/docs/content/deno/how-to/customize-runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,81 @@ title: Customise Deno runtime environment
description: Learn how you can customise your deno runtime environment on Zerops.
---

<p align="center">
<img
src="/img/screenshots/build_deploy_pipeline_custom_runtime.png"
alt="image"
width="100%"
height="auto"
/>
</p>

import data from '@site/static/data.json';
import { SetVar, VarCodeBlock } from '@site/src/components/content/var';

## Build Custom Runtime Images

Zerops allows you to build custom runtime images (CRI) when the default base runtime images don't meet your Deno application's requirements. This is an optional phase in the [build and deploy pipeline](/features/pipeline#runtime-prepare-phase-optional).

:::important
You should not include your application code in the custom runtime image, as your built/packaged code is deployed automatically into fresh containers.
:::

## Configuration

### Default Deno Runtime Environment

The default Deno runtime environment contains:

- <span>{data.alpine.default}</span>
- selected version of Deno selected when the runtime service was created.
- <a href="/references/cli">
`zCLI`
</a>
, Zerops command line tool
- `npm`, `yarn`, `git` and `npx` tools
- <span>{data.ubuntu.default}</span>
- Selected version of Deno when the runtime service was created
- [zCLI](/references/cli)
- Deno and Git

### When You Need a Custom Runtime Image

If your Deno application needs more than what's included in the default environment, you'll need to build a custom runtime image. Common scenarios include:

- **System packages for processing**: When your app processes images, videos, or files (requiring packages like `sudo apt-get install -y imagemagick`)
- **Global Deno tools**: When you need CLI tools or utilities available system-wide
- **Native dependencies**: When your Deno modules require system libraries that aren't in the default environment

Here are Deno-specific examples of configuring custom runtime images in your `zerops.yml`:

If you prefer the Ubuntu OS instead of Alpine, set the [build.os](/deno/how-to/build-pipeline#os) attribute to `ubuntu`. To install additional packages or tools add one or more <a href="/deno/how-to/build-pipeline#preparecommands-1">`run.prepareCommands`</a> commands to your `zerops.yaml`.
### Basic Deno Setup

When the first deploy with a defined `prepareCommands` attribute is triggered, Zerops will
<SetVar name="serviceVersion" value={data.deno.base[0][0]} />
<SetVar name="basicSetupCode" value={`run:
base: {{serviceVersion}}
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- deno install --allow-all --global some-tool`} />
<SetVar name="codeLanguage" value="yaml" />
<VarCodeBlock codeVar="basicSetupCode" languageVar="codeLanguage" />

1. create a prepare runtime container
2. optionally: [copy selected folders or files from your build container](/deno/how-to/build-pipeline#copy-folders-or-files-from-your-build-container)
3. run the `run.prepareCommands` commands in the defined order
### Using Build Files in Runtime Preparation

### Command exit code
```yaml
build:
addToRunPrepare:
- deno.json
- import_map.json
run:
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- deno cache deps.ts
```

If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/deno/how-to/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.
For complete configuration details, see the [runtime prepare phase configuration guide](/features/pipeline#configuration).

The prepare runtime container is automatically deleted after the prepare runtime phase has finished or failed.
## Process and Caching

### Custom runtime environment cache
### 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.

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:
### 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.

1. Content of the <a href="/deno/how-to/build-pipeline#copy-folders-or-files-from-your-build-container">`build.addToRunPrepare`</a> and <a href="/deno/how-to/build-pipeline#preparecommands-1">`run.prepareCommands`</a> attributes didn't change from the previous deploy
2. The custom runtime cache wasn't invalidated in the Zerops GUI.
### Build Management
For information about managing builds and deployments, see [managing builds and deployments](/features/pipeline#manage-build-and-deploys).

To invalidate the custom runtime cache go to `yyy`
:::warning
Shared storage mounts are not available during the runtime prepare phase.
:::

{/*TODO screenshot*/}
## Troubleshooting

When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly.
If your `prepareCommands` fail, check the [prepare runtime log](/deno/how-to/logs#prepare-runtime-log) for specific error messages.
85 changes: 32 additions & 53 deletions apps/docs/content/dotnet/how-to/customize-runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,36 @@ title: Customize .NET runtime environment
description: Learn how you can customize your dotnet runtime environment on Zerops.
---

import Image from '/src/components/Image';

<p align="center">
<Image
lightImage="/img/screenshots/build_deploy_pipeline_custom_runtime.png"
darkImage="/img/screenshots/build_deploy_pipeline_custom_runtime.png"
alt="Build Deploy pipeline"
style={{ width: '95%', height: 'auto' }}
/>
</p>

import data from '@site/static/data.json';

The default .NET runtime environment contains:

- <span>{data.alpine.default}</span>
- Selected version of .NET when the runtime service was created.
- [zCLI](/references/cli)
- ASP .NET and Git

:::note
To use Ubuntu instead of the default Alpine, set the [run.os](/zerops-yaml/specification#os--1) attribute.

Additional packages and tools can be installed using [run.prepareCommands](/zerops-yaml/specification#preparecommands--1).
:::

## Runtime Flow

When the first deploy with a defined `prepareCommands` attribute is triggered, Zerops will

1. Create a prepare runtime container
2. Optionally: [copy selected folders or files from your build container](/dotnet/how-to/build-pipeline#copy-folders-or-files-from-your-build-container)
3. Run the `prepareCommands` in the defined order

## Command exit code

If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/dotnet/how-to/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 prepare runtime container is automatically deleted after the prepare runtime phase has finished or failed.

## Custom runtime environment cache

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:

1. Content of the <a href="/dotnet/how-to/build-pipeline#copy-folders-or-files-from-your-build-container">build.addToRunPrepare</a> and <a href="/dotnet/how-to/build-pipeline#preparecommands-1">run.prepareCommands</a> attributes didn't change from the previous deploy
2. The custom runtime cache wasn't invalidated in the Zerops GUI.

:::tip
To invalidate the Zerops runtime cache go to your service detail in Zerops GUI, choose **Service dashboard & runtime containers** from the left menu and click on the **Open pipeline detail** button. Then click on the **Clear runtime prepare cache** button.
:::

{/* TODO - Screenshot */}

When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly.
import { SetVar } from '@site/src/components/content/var';
import CustomizeRuntimeContent from '@site/src/components/content/customize-runtime.mdx';

<SetVar name="serviceDisplay" value=".NET" />
<SetVar name="serviceVersion" value={data.dotnet.base[0][0]} />
<SetVar name="servicePath" value="dotnet" />
<SetVar name="defaultEnvironment" value="ASP .NET and Git" />
<SetVar name="packageManager" value="build tools" />
<SetVar name="codeLanguage" value="yaml" />
<SetVar name="customReasons" value={[
'<strong>System packages for processing</strong>: When your app processes images, videos, or files (requiring packages like <code>sudo apk add imagemagick</code>)',
'<strong>Native libraries</strong>: When your .NET packages require system libraries that aren\'t in the default environment',
'<strong>Development tools</strong>: When you need additional debugging or profiling tools',
'<strong>Different base OS</strong>: When you need Ubuntu instead of Alpine for specific compatibility requirements'
]} />
<SetVar name="basicSetupCode" value={`run:
os: ubuntu
base: {{serviceVersion}}
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- dotnet tool install -g some-global-tool`} />
<SetVar name="buildFilesCode" value={`build:
addToRunPrepare:
- *.csproj
- nuget.config
run:
prepareCommands:
- sudo apk add imagemagick
- dotnet restore`} />

<CustomizeRuntimeContent />
79 changes: 33 additions & 46 deletions apps/docs/content/elixir/how-to/customize-runtime.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,37 @@ title: Customise Elixir runtime environment
description: Learn how you can customise your Elixir runtime environment on Zerops.
---

<p align="center">
<img
src="/img/screenshots/build_deploy_pipeline_custom_runtime.png"
alt="image"
width="100%"
height="auto"
/>
</p>

import data from '@site/static/data.json';

The default Elixir runtime environment contains:

- <span>{data.alpine.default}</span>
- selected version of Elixir selected when the runtime service was created.
- <a href="/references/cli">
`zCLI`
</a>
, Zerops command line tool
- `npm`, `yarn`, `git` and `npx` tools

If you prefer the Ubuntu OS instead of Alpine, set the [build.os](/elixir/how-to/build-pipeline#os) attribute to `ubuntu`. To install additional packages or tools add one or more <a href="/elixir/how-to/build-pipeline#preparecommands-1">`run.prepareCommands`</a> commands to your `zerops.yaml`.

When the first deploy with a defined `prepareCommands` attribute is triggered, Zerops will

1. create a prepare runtime container
2. optionally: [copy selected folders or files from your build container](/elixir/how-to/build-pipeline#copy-folders-or-files-from-your-build-container)
3. run the `run.prepareCommands` commands in the defined order

### Command exit code

If any command fails, it returns an exit code other than 0 and the deploy is canceled. Read the [prepare runtime log](/elixir/how-to/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 prepare runtime container is automatically deleted after the prepare runtime phase has finished or failed.

### Custom runtime environment cache

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:

1. Content of the <a href="/elixir/how-to/build-pipeline#copy-folders-or-files-from-your-build-container">`build.addToRunPrepare`</a> and <a href="/elixir/how-to/build-pipeline#preparecommands-1">`run.prepareCommands`</a> attributes didn't change from the previous deploy
2. The custom runtime cache wasn't invalidated in the Zerops GUI.

To invalidate the custom runtime cache go to `yyy`

{/*TODO screenshot*/}

When the custom runtime cache is used, Zerops doesn't create a prepare runtime container and executes the deployment of your application directly.
import { SetVar } from '@site/src/components/content/var';
import CustomizeRuntimeContent from '@site/src/components/content/customize-runtime.mdx';

<SetVar name="serviceDisplay" value="Elixir" />
<SetVar name="serviceVersion" value={data.elixir.base[0][0]} />
<SetVar name="servicePath" value="elixir" />
<SetVar name="defaultEnvironment" value="Erlang, Elixir, Hex, Rebar and Git" />
<SetVar name="packageManager" value="hex/mix" />
<SetVar name="codeLanguage" value="yaml" />
<SetVar name="customReasons" value={[
'<strong>System packages for processing</strong>: When your app processes images, videos, or files (requiring packages like <code>sudo apk add imagemagick</code>)',
'<strong>Erlang libraries</strong>: When you need additional Erlang libraries not included by default',
'<strong>Native dependencies</strong>: When your Mix dependencies require system libraries that aren\'t in the default environment',
'<strong>Different base OS</strong>: When you need Ubuntu instead of Alpine for specific compatibility requirements'
]} />
<SetVar name="basicSetupCode" value={`run:
os: ubuntu
base: {{serviceVersion}}
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- mix local.hex --force
- mix archive.install hex phx_new`} />
<SetVar name="buildFilesCode" value={`build:
addToRunPrepare:
- mix.exs
- mix.lock
run:
prepareCommands:
- sudo apk add imagemagick
- mix deps.get`} />

<CustomizeRuntimeContent />
Loading