Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Guardrails ai Guardrails Docker Deployment

From Leeroopedia
Knowledge Sources
Domains Deployment, Containerization
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete Docker build and deployment scripts for running the Guardrails API server in containers provided by the guardrails repository.

Description

This is an External Tool Doc documenting the Docker deployment infrastructure in the server_ci/ directory. It includes build scripts, Flask (gunicorn) and FastAPI (uvicorn) entrypoints, and configuration for containerized Guardrails server deployment.

Usage

Use the build script to create a Docker image, then run it with the appropriate entrypoint and environment variables.

Code Reference

Source Location

  • Repository: guardrails
  • Files:
    • server_ci/build.sh (L1-12)
    • server_ci/flask-entry.sh (L1-10)
    • server_ci/fastapi-entry.sh (L1-6)

Build Script

# server_ci/build.sh - Docker image build
docker build -t guardrails-server .

Flask Entrypoint

# server_ci/flask-entry.sh - Gunicorn entrypoint
gunicorn --bind 0.0.0.0:8000 --timeout 120 \
    "guardrails_api.app:create_app()"

FastAPI Entrypoint

# server_ci/fastapi-entry.sh - Uvicorn entrypoint
uvicorn guardrails_api.app:create_app --host 0.0.0.0 --port 8000

I/O Contract

Inputs

Name Type Required Description
Dockerfile File Yes Docker build instructions
config.py File Yes Guard configuration (copied/mounted)
GUARDRAILS_BASE_URL Env Var No Server base URL
GUARDRAILS_API_KEY Env Var No API key for authentication

Outputs

Name Type Description
Docker image Image Container image running Guardrails API server on port 8000

Usage Examples

Build and Run

# Build the image
docker build -t guardrails-server .

# Run with Flask/gunicorn
docker run -p 8000:8000 \
    -e GUARDRAILS_API_KEY="your-key" \
    -v $(pwd)/config.py:/app/config.py \
    guardrails-server

# Run with FastAPI/uvicorn
docker run -p 8000:8000 \
    -e GUARDRAILS_API_KEY="your-key" \
    --entrypoint /app/fastapi-entry.sh \
    guardrails-server

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment