Spaces:
Sleeping
Sleeping
riteshraut commited on
Commit ·
07274f3
1
Parent(s): f6d6be5
fix/nltk
Browse files- Dockerfile +21 -30
Dockerfile
CHANGED
|
@@ -1,40 +1,31 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
# Set working directory
|
| 4 |
-
WORKDIR /
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
RUN apt-get update
|
| 9 |
-
|
| 10 |
-
# Install each main package and its dependencies in a separate layer
|
| 11 |
-
RUN apt-get install -y --no-install-recommends libfaiss-dev && rm -rf /var/lib/apt/lists/*
|
| 12 |
-
RUN apt-get update && apt-get install -y --no-install-recommends tesseract-ocr && rm -rf /var/lib/apt/lists/*
|
| 13 |
-
RUN apt-get update && apt-get install -y --no-install-recommends libgl1 && rm -rf /var/lib/apt/lists/*
|
| 14 |
-
|
| 15 |
-
# Set environment variables for writable directories
|
| 16 |
-
ENV HOME=/tmp
|
| 17 |
ENV NLTK_DATA=/tmp/nltk_data
|
| 18 |
-
ENV
|
| 19 |
-
ENV
|
| 20 |
-
ENV
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
RUN
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# Copy
|
| 27 |
COPY requirements.txt .
|
| 28 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
RUN
|
| 32 |
|
| 33 |
-
# Copy application
|
| 34 |
COPY . .
|
| 35 |
|
| 36 |
-
# Expose port
|
| 37 |
EXPOSE 7860
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
CMD ["gunicorn", "
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Set writable cache directories for Hugging Face models and NLTK data
|
| 8 |
+
ENV HF_HOME=/tmp/huggingface_cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
ENV NLTK_DATA=/tmp/nltk_data
|
| 10 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib_cache
|
| 11 |
+
ENV FONTCONFIG_PATH=/tmp/fontconfig
|
| 12 |
+
ENV XDG_CACHE_HOME=/tmp/xdg_cache
|
| 13 |
+
# Copy the system dependencies file and install them
|
| 14 |
+
COPY packages.txt .
|
| 15 |
+
RUN apt-get update && apt-get install -y --no-install-recommends $(cat packages.txt) && \
|
| 16 |
+
rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Copy the Python requirements file
|
| 19 |
COPY requirements.txt .
|
|
|
|
| 20 |
|
| 21 |
+
# Install the Python dependencies
|
| 22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
|
| 24 |
+
# Copy the rest of your application code into the container
|
| 25 |
COPY . .
|
| 26 |
|
| 27 |
+
# Expose the port that Hugging Face Spaces uses
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
+
# Command to run your application using gunicorn
|
| 31 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|