tejani commited on
Commit
15edb30
·
verified ·
1 Parent(s): 1b3b60b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -48
Dockerfile CHANGED
@@ -1,60 +1,23 @@
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
- # 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 \
13
- libgl1 \
14
- libglib2.0-0 \
15
- wget \
16
- && rm -rf /var/lib/apt/lists/*
17
-
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
-
25
- # Upgrade pip and install Python dependencies
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
54
 
55
- # Set environment variables for Hugging Face Spaces
56
- ENV PYTHONUNBUFFERED=1
57
- ENV DEVICE=cpu
58
-
59
- # Command to run the API server
60
- CMD ["python", "src/app.py", "--api"]
 
1
+ # Use an official Python runtime as the base image
2
  FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install git to clone the repository
8
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Clone the repository
 
 
 
 
 
 
 
 
11
  RUN git clone https://github.com/rupeshs/fastsdcpu.git .
12
 
13
+ # Install any Python dependencies if requirements.txt exists
14
+ #RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ # Ensure the start-webserver.sh script is executable
17
+ RUN chmod +x start-webserver.sh
18
 
19
+ # Expose port if the webserver uses a specific port (default to 8000, adjust if needed)
 
 
 
 
 
 
 
 
 
20
  EXPOSE 8000
21
 
22
+ # Run the start-webserver.sh script
23
+ CMD ["./start-webserver.sh"]