mirror of
https://github.com/lintsinghua/DeepAudit.git
synced 2026-11-21 20:56:55 +08:00
60 lines
1.2 KiB
Docker
60 lines
1.2 KiB
Docker
# Backend Dockerfile for XCodeReviewer
|
|
# Multi-stage build for production
|
|
|
|
# Build stage
|
|
FROM python:3.11-slim as builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
g++ \
|
|
libpq-dev \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir --user -r requirements.txt
|
|
|
|
# Production stage
|
|
FROM python:3.11-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
libpq5 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy Python dependencies from builder
|
|
COPY --from=builder /root/.local /root/.local
|
|
|
|
# Make sure scripts in .local are usable
|
|
ENV PATH=/root/.local/bin:$PATH
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p logs storage
|
|
|
|
# Set Python path
|
|
ENV PYTHONPATH=/app
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health || exit 1
|
|
|
|
# Default command (can be overridden in docker-compose)
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|