Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Dockerfile-load-balancer-sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Load Balancer SLS Dockerfile - Dual-capability serverless runtime
# Supports both remote execution and HTTP endpoints

# Use Python 3.11 base image with CUDA support
FROM pytorch/pytorch:2.2.0-cuda12.1-cudnn8-runtime AS builder

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Install uv for fast Python package management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Copy Python project files
COPY pyproject.toml uv.lock ./
COPY src/ ./src/

# Install Python dependencies
RUN uv sync --frozen

# Set Python path
ENV PYTHONPATH="/app/src:$PYTHONPATH"

# Environment variables for Load Balancer SLS
ENV RUNTIME_MODE="dual"
ENV ENABLE_HTTP_SERVER="true"
ENV ENABLE_REMOTE_EXECUTION="true"
ENV PORT="8000"

# Expose port for HTTP endpoints
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

# Default command - can run in both serverless and HTTP modes
CMD ["uv", "run", "python", "src/load_balancer_sls_handler.py"]
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
IMAGE = runpod/tetra-rp
LOAD_BALANCER_SLS_IMAGE = mwiki/worker-tetra-load-balancer-sls
TAG = local
FULL_IMAGE = $(IMAGE):$(TAG)
FULL_IMAGE_CPU = $(IMAGE)-cpu:$(TAG)
FULL_IMAGE_LOAD_BALANCER_SLS = $(LOAD_BALANCER_SLS_IMAGE):$(TAG)

.PHONY: setup help

Expand Down Expand Up @@ -35,9 +37,10 @@ setup: dev # Initialize project, sync deps, update submodules
git submodule update --remote --merge
cp tetra-rp/src/tetra_rp/protos/remote_execution.py src/

build: # Build both GPU and CPU Docker images
build: # Build all Docker images (GPU, CPU, Load Balancer SLS)
make build-gpu
make build-cpu
make build-load-balancer-sls

build-gpu: setup # Build GPU Docker image (linux/amd64)
docker buildx build \
Expand All @@ -52,6 +55,13 @@ build-cpu: setup # Build CPU-only Docker image (linux/amd64)
-t $(FULL_IMAGE_CPU) \
. --load

build-load-balancer-sls: setup # Build Load Balancer SLS dual-capability image (linux/amd64)
docker buildx build \
--platform linux/amd64 \
-f Dockerfile-load-balancer-sls \
-t $(FULL_IMAGE_LOAD_BALANCER_SLS) \
. --load

# Test commands
test: # Run all tests
uv run pytest tests/ -v
Expand All @@ -71,6 +81,9 @@ test-fast: # Run tests with fast-fail mode
test-handler: # Test handler locally with all test_*.json files
cd src && ./test-handler.sh

test-load-balancer-sls: build-load-balancer-sls # Test Load Balancer SLS container locally
docker run --rm -p 8000:8000 $(FULL_IMAGE_LOAD_BALANCER_SLS)

# Smoke Tests (local on Mac OS)

smoketest-macos-build: setup # Build CPU-only Mac OS Docker image (macos/arm64)
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ dependencies = [
"pydantic>=2.11.4",
"requests>=2.25.0",
"runpod",
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"aiohttp>=3.9.0",
"hf_transfer>=0.1.0",
"huggingface_hub>=0.32.0",
]
Expand Down
Loading
Loading