Skip to main content

Customize Packages

Superblocks supports common Python and JavaScript libraries in backend APIs. If you're running the OPA, you can also install your own custom libraries from public and private package registries, or by using an install script.

Python

Python dependencies can be updated by creating a custom Docker image for the Superblocks agent. You’ll need to update the Dockerfile based on how your modules are installed.

Public registry

1. Create a new directory for your custom Python worker
2. Create a requirements.txt file that includes the packages you want to install
3. Create a Dockerfile with the following contents

FROM ${SUPERBLOCKS_IMAGE_NAME}
COPY requirements.txt custom-requirements.txt
RUN pip3 install -r custom-requirements.txt
info

If running the agent on Google Cloud Run, use us-east1-docker.pkg.dev/superblocks-registry/superblocks/agent for ${SUPERBLOCKS_IMAGE_NAME}. Otherwise, use ghcr.io/superblocksteam/agent.

4. Build and tag the new image

docker buildx build --platform linux/amd64 -f Dockerfile . -t ${IMAGE_REGISTRY}/${IMAGE_NAME:-agent}:${IMAGE_TAG}

5. Push the new image tag to your container registry

docker push ${IMAGE_REGISTRY}/${IMAGE_NAME:-agent}:${IMAGE_TAG}

6. Configure your OPA to pull your custom agent image

Update the following value in your agent's Terraform file

variable "superblocks_agent_image" {
type = string
default = "${IMAGE_REGISTRY}/${IMAGE_NAME:-agent}:${IMAGE_TAG}"
description = "The docker image used by Superblocks Agent container instance"
}

7. Redeploy the agent

Private registry

To install from a private registry, follow the same instructions used for installing from a public registry, but add an extra index URL for your private repository.

Update your Dockerfile to include:

FROM ${SUPERBLOCKS_IMAGE_NAME}
COPY requirements.txt custom-requirements.txt
RUN pip3 install -r custom-requirements.txt --extra-index-url ${PRIVATE_REGISTRY_URL}

Reference your package registry’s instructions for how to set up authentication.

Manually install

Python packages with a setup.py script can be installed by creating a wheel, copying it to your Docker image, and installing it using pip.

Update your Dockerfile to include:

FROM ${SUPERBLOCKS_IMAGE_NAME}
COPY PATH/TO/PACKAGE.whl PACKAGE.whl
RUN pip3 install PACKAGE.whl