Update Dockerfile
Browse files- Dockerfile +21 -31
Dockerfile
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Install system dependencies
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
git \
|
| 9 |
-
git-lfs \
|
| 10 |
-
gcc \
|
| 11 |
-
python3-dev \
|
| 12 |
libgl1 \
|
| 13 |
libglib2.0-0 \
|
|
|
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
RUN git lfs install
|
| 18 |
-
|
| 19 |
-
# Clone the fastsdcpu repository
|
| 20 |
RUN git clone https://github.com/rupeshs/fastsdcpu.git .
|
| 21 |
|
| 22 |
-
# Create
|
| 23 |
-
RUN
|
| 24 |
-
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
ENV OPENVINO_TELEMETRY=0
|
| 30 |
|
| 31 |
-
# Install
|
| 32 |
-
RUN
|
| 33 |
-
. env/bin/activate && \
|
| 34 |
-
pip install --upgrade pip && \
|
| 35 |
-
pip install torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu && \
|
| 36 |
-
pip install -r requirements.txt
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
RUN
|
| 40 |
-
echo "Model clone failed. Please check network or manually download the model."
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
chmod 666 configs/lcm-lora-models.txt
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use Python 3.10 slim as the base image for compatibility with FastSD CPU
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 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 \
|
|
|
|
|
|
|
|
|
|
| 10 |
libgl1 \
|
| 11 |
libglib2.0-0 \
|
| 12 |
+
wget \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
+
# Clone the FastSD CPU repository
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN git clone https://github.com/rupeshs/fastsdcpu.git .
|
| 17 |
|
| 18 |
+
# Create a virtual environment and activate it
|
| 19 |
+
RUN python -m venv /app/env
|
| 20 |
+
ENV PATH="/app/env/bin:$PATH"
|
| 21 |
|
| 22 |
+
# Upgrade pip and install Python dependencies
|
| 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 (optional)
|
| 27 |
+
RUN pip install --no-cache-dir openvino-dev
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# Pre-download the default model (stabilityai/sd-turbo) to avoid runtime downloads
|
| 30 |
+
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='stabilityai/sd-turbo', local_dir='/app/models/sd-turbo')"
|
|
|
|
| 31 |
|
| 32 |
+
# Expose port 8000 for the API server
|
| 33 |
+
EXPOSE 8000
|
|
|
|
| 34 |
|
| 35 |
+
# Set environment variables for Hugging Face Spaces
|
| 36 |
+
ENV PYTHONUNBUFFERED=1
|
| 37 |
+
ENV DEVICE=cpu
|
| 38 |
|
| 39 |
+
# Command to run the API server
|
| 40 |
+
CMD ["python", "src/app.py", "--api"]
|