Skip to main content

Deployment: Docker Compose

This reference guide will walk you through self-hosting WhyLabs Guardrails API with Docker Compose.

Each WhyLabs Guardrails container requires the following resources.

WhyLabs Guardrails container

  • 4 vCPU
  • 6GiB of memory

Nginx container

  • 1 vCPU
  • 1 GiB of memory

The default compose.yaml file will create 3 WhyLabs Guardrails containers as well as an nginx container. This default deployment will require a VM with at least 16 vCPU and typically 32 GiB of memory.

It's also recommended to deploy to instances with Intel Xeon Scalable processors for best performance.

Image Access Token

In order to access the WhyLabs Guardrails API deployment image, you'll need to have the secrets to our container registry. Please reach out to [email protected] for help.

Prerequisites

Credentials

  • Create a WhyLabs API Key which must be stored in a WHYLABS_API_KEY environment variable, described below.
export WHYLABS_API_KEY=<whylabs-api-key>
  • Generate a random value for the CONTAINER_PASSWORD environment variable, also described below. This secret is required to call the container API endpoint.
# You can use `openssl rand -base64 18 | tr -d '\n'` to generate a random string
export CONTAINER_PASSWORD=<random-string>
docker login registry.gitlab.com -u "${username}" -p "${password}"

Docker Compose Installation

Clone the github.com/whylabs/charts repository and navigate to the charts/docs/compose directory.

Running the Application

To run the application, use the following command from the directory containing your compose.yaml file.

⚠️ It is important to execute docker compose commands from the charts/docs/compose directory, which contains the compose.yaml and nginx.conf files. The compose.yaml file expects the nginx.conf file to be a sibling within the same directory.

docker compose up -d

Adjusting Replicas

To change the number of replicas for the Guardrails service:

  1. Open the compose.yaml file.
  2. Find the Guardrails service section.
  3. Modify the replicas value under the deploy key.

Example:

deploy:
replicas: 3 # Change this number as needed

Adjusting Resources

To modify the CPU and memory limits for the Guardrails or nginx services:

  1. Navigate to the resources section under the respective service in the compose.yaml file.
  2. Adjust the cpus and memory under both limits and reservations.

Example for Guardrails:

resources:
limits:
cpus: '6.0' # From 4.0 to 6.0 for example
memory: 81928M # From 4096M to 81928M for example

Updating the Image and Tag

To update the Docker image used by the Guardrails service:

  1. Locate the image key under the Guardrails service in the compose.yaml file.
  2. Update the image name and tag.

Example:

image: registry.gitlab.com/whylabs/whylogs-container:newtag

This will start all services defined in the Docker Compose file.

Stopping the Application

To stop all services, run:

docker compose down

Monitoring and Logs

To view the logs for a specific service, use:

docker compose logs -f guardrails

Replace Guardrails with nginx to view logs for the NGINX service.

Prefooter Illustration Mobile
Run AI With Certainty
Get started for free
Prefooter Illustration