Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +44 -42
Dockerfile
CHANGED
|
@@ -1,43 +1,45 @@
|
|
| 1 |
-
# Use an Ubuntu-based image with Python 3.10
|
| 2 |
-
FROM python:3.10-slim
|
| 3 |
-
|
| 4 |
-
# Set working directory
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Install system dependencies
|
| 8 |
-
RUN apt-get update && apt-get install -y \
|
| 9 |
-
ffmpeg \
|
| 10 |
-
libsm6 \
|
| 11 |
-
libxext6 \
|
| 12 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
-
|
| 14 |
-
# Install UV for faster dependency installation
|
| 15 |
-
RUN pip install uv
|
| 16 |
-
|
| 17 |
-
# Copy requirements and install
|
| 18 |
-
COPY requirements.txt .
|
| 19 |
-
RUN uv pip install --system -r requirements.txt
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
ENV
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Use an Ubuntu-based image with Python 3.10
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
ffmpeg \
|
| 10 |
+
libsm6 \
|
| 11 |
+
libxext6 \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
+
|
| 14 |
+
# Install UV for faster dependency installation
|
| 15 |
+
RUN pip install uv
|
| 16 |
+
|
| 17 |
+
# Copy requirements and install
|
| 18 |
+
COPY requirements.txt .
|
| 19 |
+
RUN uv pip install --system -r requirements.txt
|
| 20 |
+
|
| 21 |
+
RUN pip install -q "optimum-intel[openvino,diffusers]@git+https://github.com/huggingface/optimum-intel.git" "transformers>=4.33" --extra-index-url https://download.pytorch.org/whl/cpu
|
| 22 |
+
|
| 23 |
+
# Create cache directories with write permissions
|
| 24 |
+
RUN mkdir -p /app/cache/huggingface /app/cache/openvino /app/matplotlib_cache /app/openvino_cache \
|
| 25 |
+
&& chmod -R 777 /app/cache /app/matplotlib_cache /app/openvino_cache
|
| 26 |
+
|
| 27 |
+
# Set environment variables for cache directories
|
| 28 |
+
ENV HF_HOME=/app/cache/huggingface
|
| 29 |
+
ENV MPLCONFIGDIR=/app/matplotlib_cache
|
| 30 |
+
ENV OPENVINO_TELEMETRY_DIR=/app/openvino_cache
|
| 31 |
+
|
| 32 |
+
# Pre-download base SDXL model
|
| 33 |
+
RUN python -c "from optimum.intel.openvino import OVStableDiffusionPipeline; \
|
| 34 |
+
OVStableDiffusionPipeline.from_pretrained('rupeshs/hyper-sd-sdxl-1-step-openvino-int8', ov_config={'CACHE_DIR': '/app/cache/openvino'})"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
# Copy application code
|
| 38 |
+
COPY app.py .
|
| 39 |
+
|
| 40 |
+
# Expose port (default 5000, configurable via PORT env variable)
|
| 41 |
+
ENV PORT=7860
|
| 42 |
+
EXPOSE $PORT
|
| 43 |
+
|
| 44 |
+
# Command to run the Flask app
|
| 45 |
CMD ["python", "app.py"]
|