BloxServer API (FastAPI + SQLAlchemy async): - Database models: users, flows, triggers, executions, usage tracking - Clerk JWT auth with dev mode bypass for local testing - SQLite support for local dev, PostgreSQL for production - CRUD routes for flows, triggers, executions - Public webhook endpoint with token auth - Health/readiness endpoints - Pydantic schemas with camelCase aliases for frontend - Docker + docker-compose setup Architecture documentation: - Librarian architecture with RLM-powered query engine - Stripe billing integration (usage-based, trials, webhooks) - LLM abstraction layer (rate limiting, semantic cache, failover) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.7 KiB
Docker
58 lines
1.7 KiB
Docker
# BloxServer API Dockerfile
|
|
# Multi-stage build for smaller production image
|
|
|
|
# =============================================================================
|
|
# Build stage
|
|
# =============================================================================
|
|
FROM python:3.12-slim as builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for layer caching
|
|
COPY requirements.txt .
|
|
RUN pip wheel --no-cache-dir --wheel-dir /app/wheels -r requirements.txt
|
|
|
|
# =============================================================================
|
|
# Production stage
|
|
# =============================================================================
|
|
FROM python:3.12-slim as production
|
|
|
|
WORKDIR /app
|
|
|
|
# Create non-root user
|
|
RUN groupadd --gid 1000 bloxserver \
|
|
&& useradd --uid 1000 --gid bloxserver --shell /bin/bash --create-home bloxserver
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy wheels from builder and install
|
|
COPY --from=builder /app/wheels /wheels
|
|
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels
|
|
|
|
# Copy application code
|
|
COPY --chown=bloxserver:bloxserver . /app/bloxserver
|
|
|
|
# Set Python path
|
|
ENV PYTHONPATH=/app
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Switch to non-root user
|
|
USER bloxserver
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health/live || exit 1
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Run with uvicorn
|
|
CMD ["uvicorn", "bloxserver.api.main:app", "--host", "0.0.0.0", "--port", "8000"]
|