Custom Images
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.
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"],
),
),
)
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'],
)
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")
Was this page helpful?