scratch_chat / Dockerfile
WebashalarForML's picture
Update Dockerfile
390a2a6 verified
# # Multi-stage build for production optimization
# FROM python:3.11-slim as builder
# # Set working directory
# WORKDIR /app
# # Install system dependencies for building Python packages
# RUN apt-get update && apt-get install -y \
# gcc \
# g++ \
# libpq-dev \
# && rm -rf /var/lib/apt/lists/*
# # Copy requirements and install Python dependencies
# COPY requirements.txt .
# # RUN pip install --no-cache-dir --user -r requirements.txt
# RUN pip install --no-cache-dir -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 \
# && rm -rf /var/lib/apt/lists/*
# # Copy Python packages from builder stage
# 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 non-root user for security
# RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
# RUN chown -R chatuser:chatuser /app
# USER chatuser
# # Expose port
# EXPOSE 7860
# # Health check
# # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
# # CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
# # Default command
# CMD ["python", "app.py"]
# Use a public Python image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies needed for your packages
RUN apt-get update && apt-get install -y \
gcc \
g++ \
libpq-dev \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create logs directory and give full access
RUN mkdir -p /app/logs && chmod 777 /app/logs
# Expose port (HF Spaces typically uses 7860)
EXPOSE 7860
# Default command to run your Flask app
CMD ["python", "app.py"]