Skip to main content
Cerebrium supports deploying existing containerized apps — from standard Python apps to compiled Rust binaries - using a custom Dockerfile. This allows portable, locally reproducible deployment environments.

Building Dockerized Python Apps

A simple containerized FastAPI server:
The corresponding Dockerfile:
Dockerfiles for Cerebrium have three requirements:
  1. Expose a port with the EXPOSE command - this port is referenced in cerebrium.toml
  2. Include a CMD command to specify the container’s startup process (typically the server)
  3. Set the working directory with WORKDIR to ensure correct file paths (defaults to root if not specified)
Update cerebrium.toml to include a custom runtime section with the dockerfile_path parameter:
The configuration requires three key parameters:
  • port: The port the server listens on.
  • healthcheck_endpoint: The endpoint used to confirm instance health. If unspecified, defaults to a TCP ping on the configured port. If the health check registers a non-200 response, it will be considered unhealthy, and be restarted should it not recover timely.
  • readycheck_endpoint: The endpoint used to confirm if the instance is ready to receive. If unspecified, defaults to a TCP ping on the configured port. If the ready check registers a non-200 response, it will not be a viable target for request routing.
  • dockerfile_path: The relative path to the Dockerfile used to build the app.
If the Dockerfile omits a CMD clause, specify the entrypoint parameter in cerebrium.toml:
When specifying a dockerfile_path, all dependencies and necessary commands should be installed and executed within the Dockerfile. Dependencies listed under cerebrium.dependencies.*, as well as cerebrium.deployment.shell_commands and cerebrium.deployment.pre_build_commands, will be ignored.

Building Generic Dockerized Apps

Cerebrium supports non-Python apps as long as a Dockerfile is provided. The following example shows a Rust-based API server using the Axum framework:
A multi-stage Dockerfile separates the build step from the runtime, producing a smaller and more secure image:
Configure the application in cerebrium.toml the same way as the FastAPI example: