LegalMind12 / Dockerfile
Nguyendat92929's picture
Upload 91 files
08b74f7 verified
# Use the official Python 3.11 slim image as the base
FROM python:3.11-slim
# Set the working directory inside the container
WORKDIR /app
# Install system dependencies for MongoDB, FAISS, and other libraries
RUN apt-get update && apt-get install -y \
gcc \
g++ \
libffi-dev \
wget \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install gunicorn certifi eventlet
# Download Boxicons fonts to fix 404 error
RUN mkdir -p /app/static/fonts && \
wget -P /app/static/fonts https://unpkg.com/boxicons@2.1.4/fonts/boxicons.woff2 && \
wget -P /app/static/fonts https://unpkg.com/boxicons@2.1.4/fonts/boxicons.woff && \
wget -P /app/static/fonts https://unpkg.com/boxicons@2.1.4/fonts/boxicons.ttf
# Set up cache, log, and session directories with proper permissions
ENV HF_HOME=/app/.cache/huggingface
ENV FLASK_SESSION_DIR=/app/sessions
RUN mkdir -p /app/.cache/huggingface /app/logs /app/sessions /app/static/fonts /app/embedding_data && \
chmod -R 777 /app/.cache/huggingface /app/logs /app/sessions /app/static/fonts /app/embedding_data
# Copy the entire application code, including embedding_data
COPY . .
# Expose the port Hugging Face Spaces expects
EXPOSE 7860
# Set environment variables
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Command to run the application with Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "4", "--timeout", "120", "--worker-class", "eventlet", "app:app"]