mike23415 commited on
Commit
8d9b5ef
·
verified ·
1 Parent(s): dbf9148

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -45
Dockerfile CHANGED
@@ -1,51 +1,10 @@
1
- # Use Python 3.9 slim image as base
2
- FROM python:3.9-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- libglib2.0-0 \
10
- libsm6 \
11
- libxext6 \
12
- libxrender-dev \
13
- libgomp1 \
14
- libgl1-mesa-glx \
15
- libglib2.0-0 \
16
- libgtk-3-0 \
17
- libgdk-pixbuf2.0-0 \
18
- wget \
19
- && rm -rf /var/lib/apt/lists/*
20
-
21
- # Copy requirements first to leverage Docker cache
22
- COPY requirements.txt .
23
-
24
- # Install Python dependencies
25
  RUN pip install --no-cache-dir -r requirements.txt
26
 
27
- # Copy application code
28
- COPY app.py .
29
-
30
- # Create cache directories with proper permissions
31
- RUN mkdir -p /app/.cache/huggingface/hub && \
32
- mkdir -p /app/.cache/torch && \
33
- chmod -R 777 /app/.cache
34
-
35
- # Set environment variables
36
- ENV FLASK_APP=app.py
37
- ENV FLASK_ENV=production
38
- ENV PYTHONUNBUFFERED=1
39
- ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
40
- ENV HF_HOME=/app/.cache/huggingface
41
- ENV TORCH_HOME=/app/.cache/torch
42
-
43
- # Expose port
44
- EXPOSE 5000
45
-
46
- # Health check
47
- HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \
48
- CMD curl -f http://localhost:5000/ || exit 1
49
 
50
- # Run the application with gunicorn
51
- CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--timeout", "300", "--keep-alive", "2", "--preload", "app:app"]
 
1
+ FROM python:3.10-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
+ COPY requirements.txt ./
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
8
+ COPY . .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ CMD ["python", "app.py"]