Update Dockerfile
Browse files- Dockerfile +12 -4
Dockerfile
CHANGED
|
@@ -8,15 +8,19 @@ RUN apt-get update && apt-get install -y \
|
|
| 8 |
libglib2.0-0 libsm6 libxext6 libxrender-dev poppler-utils \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
# Create app directory
|
| 12 |
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
RUN mkdir -p /.cache && chmod 777 /.cache
|
| 16 |
-
# Alternative: Set HF_HOME to a writable location
|
| 17 |
ENV HF_HOME=/app/.cache
|
| 18 |
ENV TRANSFORMERS_CACHE=/app/.cache
|
| 19 |
ENV HF_DATASETS_CACHE=/app/.cache
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# Copy files
|
| 22 |
COPY app.py requirements.txt ./
|
|
@@ -24,6 +28,10 @@ COPY app.py requirements.txt ./
|
|
| 24 |
# Install dependencies
|
| 25 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
# Expose port for Hugging Face
|
| 28 |
EXPOSE 7860
|
| 29 |
|
|
|
|
| 8 |
libglib2.0-0 libsm6 libxext6 libxrender-dev poppler-utils \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Create app directory and cache directories
|
| 12 |
WORKDIR /app
|
| 13 |
+
RUN mkdir -p /app/.cache && \
|
| 14 |
+
mkdir -p /.cache && \
|
| 15 |
+
chmod -R 777 /app && \
|
| 16 |
+
chmod -R 777 /.cache
|
| 17 |
|
| 18 |
+
# Set environment variables for HuggingFace cache
|
|
|
|
|
|
|
| 19 |
ENV HF_HOME=/app/.cache
|
| 20 |
ENV TRANSFORMERS_CACHE=/app/.cache
|
| 21 |
ENV HF_DATASETS_CACHE=/app/.cache
|
| 22 |
+
ENV HUGGINGFACE_HUB_CACHE=/app/.cache
|
| 23 |
+
ENV TORCH_HOME=/app/.cache
|
| 24 |
|
| 25 |
# Copy files
|
| 26 |
COPY app.py requirements.txt ./
|
|
|
|
| 28 |
# Install dependencies
|
| 29 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 30 |
|
| 31 |
+
# Pre-download models to avoid runtime download issues (optional but recommended)
|
| 32 |
+
# Uncomment the next line if you want to download models during build
|
| 33 |
+
# RUN python -c "from transformers import DonutProcessor, VisionEncoderDecoderModel; DonutProcessor.from_pretrained('naver-clova-ix/donut-base'); VisionEncoderDecoderModel.from_pretrained('naver-clova-ix/donut-base')"
|
| 34 |
+
|
| 35 |
# Expose port for Hugging Face
|
| 36 |
EXPOSE 7860
|
| 37 |
|