Sameer-Handsome173 commited on
Commit
a38e6cf
·
verified ·
1 Parent(s): a877280

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -16
Dockerfile CHANGED
@@ -1,30 +1,40 @@
1
- FROM python:3.10-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- git ffmpeg libsm6 libxext6 \
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # Ensure numpy compatibility
11
- RUN pip install --no-cache-dir "numpy<2.0"
12
 
13
- # Install safe PyTorch CPU version (2.6.0 works fine for Spaces)
14
- RUN pip install --no-cache-dir torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0
 
15
 
16
- # Copy project files
17
- COPY . /app
18
 
19
- # Install your app dependencies
20
- RUN pip install --no-cache-dir --upgrade pip && \
21
- pip install --no-cache-dir fastapi uvicorn transformers pillow langchain langsmith python-multipart
22
 
23
- # Use /tmp as Hugging Face cache (prevents write permission issues)
24
  ENV HF_HOME=/tmp/huggingface_cache
 
 
 
25
 
26
- # Expose Hugging Face default port
27
  EXPOSE 7860
28
 
29
- # Start FastAPI
30
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
1
+ FROM python:3.10
2
 
3
+ # Set working directory
4
  WORKDIR /app
5
 
6
  # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ build-essential \
9
+ git \
10
+ curl \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Upgrade pip
14
+ RUN pip install --upgrade pip
15
 
16
+ # Copy requirements and install dependencies
17
+ COPY requirements.txt .
18
+ RUN pip install --no-cache-dir -r requirements.txt
19
 
20
+ # Copy application code
21
+ COPY app.py .
22
 
23
+ # Create cache directory
24
+ RUN mkdir -p /tmp/huggingface_cache && chmod 777 /tmp/huggingface_cache
 
25
 
26
+ # Set environment variables
27
  ENV HF_HOME=/tmp/huggingface_cache
28
+ ENV TRANSFORMERS_CACHE=/tmp/huggingface_cache
29
+ ENV PYTHONUNBUFFERED=1
30
+ ENV PORT=7860
31
 
32
+ # Expose port
33
  EXPOSE 7860
34
 
35
+ # Health check
36
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
37
+ CMD curl -f http://localhost:7860/health || exit 1
38
+
39
+ # Run the application
40
+ CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]