ayush2917 commited on
Commit
b7877e2
·
verified ·
1 Parent(s): 2dcee35

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -12
Dockerfile CHANGED
@@ -2,27 +2,36 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
- # Copy requirements and scripts
6
- COPY requirements.txt .
7
- COPY cache_embeddings.py .
 
8
 
9
- # Install dependencies
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
- gcc \
12
- && pip install --no-cache-dir --upgrade pip \
13
- && pip install --no-cache-dir -r requirements.txt --index-url https://download.pytorch.org/whl/cpu \
14
- && python cache_embeddings.py \
15
- && apt-get purge -y --auto-remove gcc \
16
  && rm -rf /var/lib/apt/lists/*
17
 
 
 
 
 
 
 
 
18
  # Copy application code
19
  COPY . .
20
 
 
 
 
21
  # Expose port
22
  EXPOSE 7860
23
 
24
- # Run Gunicorn
25
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
26
 
27
  # Healthcheck
28
- HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Set environment variables
6
+ ENV PYTHONDONTWRITEBYTECODE 1
7
+ ENV PYTHONUNBUFFERED 1
8
+ ENV HUGGINGFACE_API_TOKEN=${HUGGINGFACE_API_TOKEN}
9
 
10
+ # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential \
13
+ curl \
 
 
 
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ # Copy requirements first to leverage Docker cache
17
+ COPY requirements.txt .
18
+
19
+ # Install Python dependencies
20
+ RUN pip install --no-cache-dir --upgrade pip \
21
+ && pip install --no-cache-dir -r requirements.txt
22
+
23
  # Copy application code
24
  COPY . .
25
 
26
+ # Create necessary directories
27
+ RUN mkdir -p static/audio static/assets
28
+
29
  # Expose port
30
  EXPOSE 7860
31
 
32
+ # Run Gunicorn with optimized settings
33
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--threads", "4", "--timeout", "120", "app:app"]
34
 
35
  # Healthcheck
36
+ HEALTHCHECK --interval=30s --timeout=3s \
37
+ CMD curl -f http://localhost:7860/health || exit 1