Custom Docker Images

Custom Docker Images

Vellum Workflows are designed to run in a sandboxed environment. By default, the Vellum Python SDK uses a default Docker Image to run Workflows generated by the UI and pushed by the user from the CLI. However, sometimes you may want to use pre-existing logic from the rest of your repository, or some bespoke binaries that don’t translate well to the currently supported Vellum SDK languages. In these cases, you can use a custom Docker Image to run your Workflow.

Configuring a Custom Docker Image

To configure a custom Docker Image for a Vellum Workflow, you should first create a Dockerfile in the root of your project.

1FROM vellumai/python-workflow-runtime:0.14.10.post3
2
3RUN pip install --upgrade pip \
4 && pip install numpy
5
6COPY ./utils /custom/utils
7
8ENV PYTHONPATH=/custom
9CMD ["vellum_start_server"]

There are few important things to note about this Dockerfile:

  • You must inherit from the vellumai/python-workflow-runtime image in order to run the Workflow on our infrastructure.
  • You have the flexibility to add any other dependencies you need to the image.
  • The vellum_start_server command is required to start the Vellum Server.

Once you have your Dockerfile, you can push it to a container registry:

1docker buildx build -f my_workflow/Dockerfile --platform=linux/amd64 -t my-workflow-image-example:1.0.0 .

Then, you can give Vellum access to the image by pushing it via the Vellum CLI:

1vellum image push my-workflow-image-example:1.0.0 --tag latest

Once you’ve pushed the image, you can configure your Vellum Workflow to use the custom Docker Image by adding the following to your pyproject.toml file:

1[[tool.vellum.workflows]]
2module = "my_workflow"
3custom_container_image = "my-workflow-image-example"
4custom_container_image_tag = "1.0.0"

This will tell Vellum to use the custom Docker Image when running the defined Workflow.