Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +17 -12
Dockerfile
CHANGED
|
@@ -4,32 +4,37 @@ FROM python:3.11-slim
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies for MongoDB and other libraries
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
gcc \
|
| 10 |
g++ \
|
| 11 |
libffi-dev \
|
|
|
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
# Copy the requirements file into the container
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
COPY requirements.txt .
|
| 19 |
|
| 20 |
# Install Python dependencies
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
# Copy the entire application code
|
| 30 |
COPY . .
|
| 31 |
|
| 32 |
-
# Expose the port Hugging Face Spaces expects
|
| 33 |
EXPOSE 7860
|
| 34 |
|
| 35 |
# Set environment variables
|
|
@@ -37,5 +42,5 @@ ENV FLASK_ENV=production
|
|
| 37 |
ENV PYTHONUNBUFFERED=1
|
| 38 |
ENV PORT=7860
|
| 39 |
|
| 40 |
-
# Command to run the application with
|
| 41 |
-
CMD ["
|
|
|
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies for MongoDB, FAISS, and other libraries
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
gcc \
|
| 10 |
g++ \
|
| 11 |
libffi-dev \
|
| 12 |
+
wget \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
# Copy the requirements file into the container
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY requirements.txt .
|
| 17 |
|
| 18 |
# Install Python dependencies
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
+
RUN pip install gunicorn certifi eventlet
|
| 21 |
|
| 22 |
+
# Download Boxicons fonts to fix 404 error
|
| 23 |
+
RUN mkdir -p /app/static/fonts && \
|
| 24 |
+
wget -P /app/static/fonts https://unpkg.com/[email protected]/fonts/boxicons.woff2 && \
|
| 25 |
+
wget -P /app/static/fonts https://unpkg.com/[email protected]/fonts/boxicons.woff && \
|
| 26 |
+
wget -P /app/static/fonts https://unpkg.com/[email protected]/fonts/boxicons.ttf
|
| 27 |
|
| 28 |
+
# Set up cache, log, and session directories with proper permissions
|
| 29 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 30 |
+
ENV FLASK_SESSION_DIR=/app/sessions
|
| 31 |
+
RUN mkdir -p /app/.cache/huggingface /app/logs /app/sessions /app/static/fonts /app/embedding_data && \
|
| 32 |
+
chmod -R 777 /app/.cache/huggingface /app/logs /app/sessions /app/static/fonts /app/embedding_data
|
| 33 |
|
| 34 |
+
# Copy the entire application code, including embedding_data
|
| 35 |
COPY . .
|
| 36 |
|
| 37 |
+
# Expose the port Hugging Face Spaces expects
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
# Set environment variables
|
|
|
|
| 42 |
ENV PYTHONUNBUFFERED=1
|
| 43 |
ENV PORT=7860
|
| 44 |
|
| 45 |
+
# Command to run the application with Gunicorn
|
| 46 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "4", "--timeout", "120", "--worker-class", "eventlet", "app:app"]
|