Update Dockerfile
Browse files- Dockerfile +24 -4
Dockerfile
CHANGED
|
@@ -4,6 +4,9 @@ FROM python:3.10-slim
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# Install system dependencies required for FastSD CPU
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
git \
|
|
@@ -15,7 +18,7 @@ RUN apt-get update && apt-get install -y \
|
|
| 15 |
# Clone the FastSD CPU repository
|
| 16 |
RUN git clone https://github.com/rupeshs/fastsdcpu.git .
|
| 17 |
|
| 18 |
-
# Create a virtual environment
|
| 19 |
RUN python -m venv /app/env
|
| 20 |
ENV PATH="/app/env/bin:$PATH"
|
| 21 |
|
|
@@ -23,11 +26,28 @@ ENV PATH="/app/env/bin:$PATH"
|
|
| 23 |
RUN pip install --no-cache-dir --upgrade pip
|
| 24 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
-
# Install OpenVINO for performance optimization
|
| 27 |
RUN pip install --no-cache-dir openvino-dev
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Expose port 8000 for the API server
|
| 33 |
EXPOSE 8000
|
|
|
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Create a non-root user to avoid permission issues
|
| 8 |
+
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
| 9 |
+
|
| 10 |
# Install system dependencies required for FastSD CPU
|
| 11 |
RUN apt-get update && apt-get install -y \
|
| 12 |
git \
|
|
|
|
| 18 |
# Clone the FastSD CPU repository
|
| 19 |
RUN git clone https://github.com/rupeshs/fastsdcpu.git .
|
| 20 |
|
| 21 |
+
# Create a virtual environment
|
| 22 |
RUN python -m venv /app/env
|
| 23 |
ENV PATH="/app/env/bin:$PATH"
|
| 24 |
|
|
|
|
| 26 |
RUN pip install --no-cache-dir --upgrade pip
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
+
# Install OpenVINO for performance optimization
|
| 30 |
RUN pip install --no-cache-dir openvino-dev
|
| 31 |
|
| 32 |
+
# Set cache directories for Hugging Face and Transformers
|
| 33 |
+
ENV HF_HOME=/app/cache/huggingface
|
| 34 |
+
ENV TRANSFORMERS_CACHE=/app/cache/huggingface/hub
|
| 35 |
+
ENV HUGGINGFACE_HUB_CACHE=/app/cache/huggingface/hub
|
| 36 |
+
|
| 37 |
+
# Create cache directory and set permissions
|
| 38 |
+
RUN mkdir -p /app/cache/huggingface/hub && chown -R appuser:appuser /app/cache
|
| 39 |
+
|
| 40 |
+
# Pre-download the default model (stabilityai/sd-turbo) to the cache
|
| 41 |
+
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='stabilityai/sd-turbo', local_dir='/app/cache/huggingface/hub/models--stabilityai--sd-turbo', local_dir_use_symlinks=False)"
|
| 42 |
+
|
| 43 |
+
# Suppress OpenVINO telemetry by setting a writable telemetry directory
|
| 44 |
+
ENV OPENVINO_TELEMETRY_DIR=/app/cache/openvino
|
| 45 |
+
|
| 46 |
+
# Create OpenVINO telemetry directory and set permissions
|
| 47 |
+
RUN mkdir -p /app/cache/openvino && chown -R appuser:appuser /app/cache/openvino
|
| 48 |
+
|
| 49 |
+
# Switch to non-root user
|
| 50 |
+
USER appuser
|
| 51 |
|
| 52 |
# Expose port 8000 for the API server
|
| 53 |
EXPOSE 8000
|