update fastapi app

This commit is contained in:
saidsurucu
2025-06-29 01:00:32 +03:00
parent a82be5979f
commit 2179582614
4 changed files with 989 additions and 220 deletions
+14 -73
View File
@@ -1,86 +1,27 @@
# Multi-stage Dockerfile for Yargı MCP Server
# Build stage
FROM python:3.12-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY pyproject.toml ./
COPY README.md ./
# Install dependencies
RUN pip install --no-cache-dir uv && \
uv pip install --system --no-cache-dir .
# Runtime stage
# ---------- temel imaj ----------
FROM python:3.12-slim
# Install runtime dependencies
# Playwrightin istediği kitaplıklar
RUN apt-get update && apt-get install -y \
# Required for Playwright
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-1-3 \
libatspi2.0-0 \
libx11-6 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libxcb1 \
libxkbcommon0 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 \
libdrm2 libdbus-1-3 libatspi2.0-0 libx11-6 libxcomposite1 \
libxdamage1 libxext6 libxfixes3 libxrandr2 libgbm1 libxcb1 \
libxkbcommon0 libpango-1.0-0 libcairo2 libasound2 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 mcp && \
mkdir -p /app && \
chown -R mcp:mcp /app
# Set working directory
WORKDIR /app
# Copy from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Gereksinimler
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=mcp:mcp . .
# Uygulama dosyaları
COPY . .
# Install Playwright browsers
# Playwright tarayıcılarını kur
RUN playwright install chromium
# Switch to non-root user
USER mcp
# Expose port
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV HOST=0.0.0.0
ENV PORT=8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8000/health').raise_for_status()"
# Run the ASGI server
CMD ["uvicorn", "asgi_app:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "fastapi_app:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers"]