Update Dockerfile
Browse files- Dockerfile +12 -7
Dockerfile
CHANGED
|
@@ -4,12 +4,14 @@ FROM python:3.10-slim
|
|
| 4 |
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
-
ENV
|
| 8 |
-
ENV
|
|
|
|
| 9 |
|
| 10 |
# Create app directory and set proper permissions
|
| 11 |
WORKDIR /app
|
| 12 |
-
RUN mkdir -p /app/cache
|
|
|
|
| 13 |
|
| 14 |
# Install system dependencies
|
| 15 |
RUN apt-get update && apt-get install -y \
|
|
@@ -22,14 +24,17 @@ RUN apt-get update && apt-get install -y \
|
|
| 22 |
|
| 23 |
# Copy and install Python dependencies
|
| 24 |
COPY requirements.txt .
|
| 25 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
-
|
| 27 |
|
| 28 |
# Copy application code
|
| 29 |
COPY . .
|
| 30 |
|
|
|
|
|
|
|
|
|
|
| 31 |
# Set permissions for the app directory
|
| 32 |
RUN chmod -R 777 /app
|
| 33 |
|
| 34 |
-
EXPOSE
|
| 35 |
-
CMD ["
|
|
|
|
| 4 |
# Set environment variables
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
+
ENV HF_HOME=/app/cache # Only using HF_HOME as TRANSFORMERS_CACHE is deprecated
|
| 8 |
+
ENV NLTK_DATA=/app/nltk_data
|
| 9 |
+
ENV PORT=8080 # Hugging Face Spaces uses port 8080
|
| 10 |
|
| 11 |
# Create app directory and set proper permissions
|
| 12 |
WORKDIR /app
|
| 13 |
+
RUN mkdir -p /app/cache /app/nltk_data && \
|
| 14 |
+
chmod -R 777 /app/cache /app/nltk_data
|
| 15 |
|
| 16 |
# Install system dependencies
|
| 17 |
RUN apt-get update && apt-get install -y \
|
|
|
|
| 24 |
|
| 25 |
# Copy and install Python dependencies
|
| 26 |
COPY requirements.txt .
|
| 27 |
+
RUN pip install --no-cache-dir -r requirements.txt && \
|
| 28 |
+
python -c "import nltk; nltk.download('punkt', download_dir='/app/nltk_data')"
|
| 29 |
|
| 30 |
# Copy application code
|
| 31 |
COPY . .
|
| 32 |
|
| 33 |
+
# Install production WSGI server
|
| 34 |
+
RUN pip install gunicorn
|
| 35 |
+
|
| 36 |
# Set permissions for the app directory
|
| 37 |
RUN chmod -R 777 /app
|
| 38 |
|
| 39 |
+
EXPOSE 8080 # Changed to match Hugging Face's expected port
|
| 40 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--timeout", "600", "app:app"]
|