Sanchit7's picture
$(cat <<EOF
9e76be1
# Multi-stage build for smaller final image
FROM python:3.11-slim as builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --user -r requirements.txt
# Final stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies from builder
COPY --from=builder /root/.local /root/.local
# Set working directory
WORKDIR /app
# Copy application code
COPY src/ ./src/
COPY setup.py .
COPY README.md .
# Make sure scripts are in PATH
ENV PATH=/root/.local/bin:$PATH
# Set Python path
ENV PYTHONPATH=/app
# Expose ports
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/ || exit 1
# Default command - run web server
CMD ["python", "-m", "src.api.server"]