CoolFace
Apppublic

WebashalarForML/scratch_chat

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes
Dockerfile85 linesDownload Raw Back to root
1# # Multi-stage build for production optimization2# FROM python:3.11-slim as builder3 4# # Set working directory5# WORKDIR /app6 7# # Install system dependencies for building Python packages8# RUN apt-get update && apt-get install -y \9#     gcc \10#     g++ \11#     libpq-dev \12#     && rm -rf /var/lib/apt/lists/*13 14# # Copy requirements and install Python dependencies15# COPY requirements.txt .16# # RUN pip install --no-cache-dir --user -r requirements.txt17# RUN pip install --no-cache-dir -r requirements.txt18 19# # Production stage20# FROM python:3.11-slim21 22# # Set working directory23# WORKDIR /app24 25# # Install runtime dependencies26# RUN apt-get update && apt-get install -y \27#     libpq5 \28#     && rm -rf /var/lib/apt/lists/*29 30# # Copy Python packages from builder stage31# COPY --from=builder /root/.local /root/.local32 33# # Make sure scripts in .local are usable34# ENV PATH=/root/.local/bin:$PATH35 36# # Copy application code37# COPY . .38 39# # Create non-root user for security40# RUN groupadd -r chatuser && useradd -r -g chatuser chatuser41# RUN chown -R chatuser:chatuser /app42# USER chatuser43 44# # Expose port45# EXPOSE 786046 47# # Health check48# # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \49# #     CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 150 51# # Default command52# CMD ["python", "app.py"]53 54# Use a public Python image55FROM python:3.11-slim56 57# Set working directory58WORKDIR /app59 60# Install system dependencies needed for your packages61RUN apt-get update && apt-get install -y \62    gcc \63    g++ \64    libpq-dev \65    libpq5 \66    && rm -rf /var/lib/apt/lists/*67 68# Copy requirements and install dependencies69COPY requirements.txt .70RUN pip install --upgrade pip71RUN pip install --no-cache-dir -r requirements.txt72 73# Copy application code74COPY . .75 76# Create logs directory and give full access77RUN mkdir -p /app/logs && chmod 777 /app/logs78 79# Expose port (HF Spaces typically uses 7860)80EXPOSE 786081 82# Default command to run your Flask app83CMD ["python", "app.py"]84 85