mike23415 commited on
Commit
64a3625
·
verified ·
1 Parent(s): 2c22460

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -9
Dockerfile CHANGED
@@ -1,30 +1,46 @@
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y \
 
 
 
 
 
7
  libgl1-mesa-glx \
8
  libglib2.0-0 \
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create a directory for the Hugging Face cache and make it writable
12
- RUN mkdir -p /huggingface_cache && chmod 777 /huggingface_cache
13
- ENV TRANSFORMERS_CACHE=/huggingface_cache
14
- ENV HF_HOME=/huggingface_cache
15
-
16
  # Copy requirements first to leverage Docker cache
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 uploads directory
24
- RUN mkdir -p uploads && chmod 777 uploads
 
 
 
 
 
25
 
26
  # Expose port
27
  EXPOSE 5000
28
 
29
- # Run the application
30
- CMD ["python", "app.py"]
 
 
 
 
 
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 directory for model cache
31
+ RUN mkdir -p /root/.cache
32
+
33
+ # Set environment variables
34
+ ENV FLASK_APP=app.py
35
+ ENV FLASK_ENV=production
36
+ ENV PYTHONUNBUFFERED=1
37
 
38
  # Expose port
39
  EXPOSE 5000
40
 
41
+ # Health check
42
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
43
+ CMD curl -f http://localhost:5000/health || exit 1
44
+
45
+ # Run the application with gunicorn
46
+ CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--timeout", "120", "--keep-alive", "2", "app:app"]