mike23415 commited on
Commit
815609b
·
verified ·
1 Parent(s): ea9f9f7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -42
Dockerfile CHANGED
@@ -1,53 +1,26 @@
 
1
  FROM python:3.9-slim
2
 
3
- # System dependencies with improved virtual display and fonts support
4
- RUN apt-get update && \
5
- apt-get install -y \
6
- gcc \
7
- libssl-dev \
8
- wkhtmltopdf \
9
- xvfb \
10
- xfonts-75dpi \
11
- xfonts-base \
12
- fonts-liberation \
13
- fonts-dejavu \
14
- fonts-noto \
15
- fonts-noto-cjk \
16
- fonts-freefont-ttf \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
- # Create non-root user and cache directory
20
- RUN useradd -m appuser && \
21
- mkdir -p /app/.cache && \
22
- chown -R appuser:appuser /app
23
-
24
- # Environment variables
25
- ENV HF_HOME=/app/.cache \
26
- XDG_CACHE_HOME=/app/.cache \
27
- PYTHONUNBUFFERED=1 \
28
- PYTHONFAULTHANDLER=1
29
-
30
  WORKDIR /app
31
 
32
- # Install Python dependencies
33
  COPY requirements.txt .
34
- RUN pip install --no-cache-dir -r requirements.txt
35
-
36
- # Configure accelerate for optimal performance
37
- RUN python -c "from accelerate.utils import write_basic_config; write_basic_config(mixed_precision='fp16')" && \
38
- chown -R appuser:appuser /app/.cache
39
 
 
 
40
 
 
 
41
 
42
- # Verify wkhtmltopdf installation
43
- RUN which wkhtmltopdf && \
44
- wkhtmltopdf --version
45
-
46
- # Copy application code
47
- COPY --chown=appuser:appuser . .
48
-
49
- # Switch to non-root user
50
- USER appuser
51
 
52
- # Runtime
53
- CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--timeout", "900", "--workers", "1", "--preload", "app:app"]
 
1
+ # Use a Python base image
2
  FROM python:3.9-slim
3
 
4
+ # Install system dependencies required by rembg and OpenCV
5
+ RUN apt-get update && apt-get install -y \
6
+ libgl1 \
7
+ libglib2.0-0 \
 
 
 
 
 
 
 
 
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Set working directory
 
 
 
 
 
 
 
 
 
 
11
  WORKDIR /app
12
 
13
+ # Copy requirements first to leverage Docker cache
14
  COPY requirements.txt .
 
 
 
 
 
15
 
16
+ # Install Python dependencies
17
+ RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy the rest of the application
20
+ COPY app.py .
21
 
22
+ # Expose the port the app runs on
23
+ EXPOSE 5000
 
 
 
 
 
 
 
24
 
25
+ # Command to run the application
26
+ CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--timeout", "120", "app:app"]