mike23415 commited on
Commit
4ef3090
·
verified ·
1 Parent(s): a5beb14

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -16
Dockerfile CHANGED
@@ -1,30 +1,37 @@
 
1
  FROM python:3.10-slim
2
 
3
- WORKDIR /app
 
 
 
 
4
 
5
  # Install system dependencies
6
- RUN apt-get update && \
7
- apt-get install -y --no-install-recommends \
8
  build-essential \
9
- && apt-get clean \
10
- && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
11
 
12
- # Copy requirements and install dependencies
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Copy application code
17
  COPY . .
18
 
19
- # Set environment variables
20
- ENV PYTHONUNBUFFERED=1
21
-
22
- # Create cache directory with proper permissions
23
- RUN mkdir -p /root/.cache/huggingface && \
24
- chmod -R 777 /root/.cache/huggingface
25
-
26
- # Expose port for the service
27
  EXPOSE 7860
28
 
29
- # Command to run the application
30
  CMD ["python", "app.py"]
 
1
+ # Base image
2
  FROM python:3.10-slim
3
 
4
+ # Set env to avoid interactive prompts and ensure models cache to /tmp
5
+ ENV HF_HOME=/tmp \
6
+ XDG_CACHE_HOME=/tmp \
7
+ TRANSFORMERS_CACHE=/tmp \
8
+ PYTHONUNBUFFERED=1
9
 
10
  # Install system dependencies
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
 
12
  build-essential \
13
+ libsm6 \
14
+ libxext6 \
15
+ libxrender-dev \
16
+ libglib2.0-0 \
17
+ libblas-dev \
18
+ liblapack-dev \
19
+ gfortran \
20
+ && apt-get clean \
21
+ && rm -rf /var/lib/apt/lists/*
22
+
23
+ # Set working directory
24
+ WORKDIR /app
25
 
26
+ # Copy requirements first for better caching
27
  COPY requirements.txt .
28
  RUN pip install --no-cache-dir -r requirements.txt
29
 
30
+ # Copy the application code
31
  COPY . .
32
 
33
+ # Expose port (for local or HF Spaces)
 
 
 
 
 
 
 
34
  EXPOSE 7860
35
 
36
+ # Start the Flask app
37
  CMD ["python", "app.py"]