When your apps are run on Beam, they are attached to a custom Runtime, which you can customize with your own Image.

The Image object encapsulates the container image your code will run in.

Beam’s default container OS is Ubuntu 20.04.

Adding custom base images

You can import existing images from remote Docker registries, like Dockerhub, Google Artifact Registry, ECR, Github Container Registry, Nvidia and more.

Just supply a base_image argument to Image.

from beam import App, Runtime, Image

app = App(
    name="custom-image",
    runtime=Runtime(
        image=Image(
            base_image="ubuntu:22.04",
            python_packages=["numpy"],
            commands=["apt-get update && apt-get install -y ffmpeg"],
        ),
    ),
)
Currently, Beam only supports Debian-based images.

Adding shell commands

You can also run any shell commands you want in the environment before it starts up. Just pass them into the commands field in your app definition.

Below, we’ll customize our image with requests and some shell commands:

from beam import App, Runtime, Image

app = App(
    name="custom-container-example",
    runtime=Runtime(
        image=Image(
            python_packages=["requests"],
            commands=["apt-get update && pip install beautifulsoup4"],
        ),
    ),
)

Adding Python packages

You can add Python packages to the runtime in the python_packages field:

from beam import Image

Image(
    python_version="python3.8",
    python_packages=['numpy', 'pandas'],
)
Beam will default to Python 3.8 if no python_version is provided.

Alternatively, you can pass in a path to a requirements.txt file:

from beam import Image

Image(python_packages="requirements.txt")