Tas01 commited on
Commit
5f0c90f
·
verified ·
1 Parent(s): af31e0f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -17
Dockerfile CHANGED
@@ -1,37 +1,42 @@
1
- FROM python:3.9-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- # Install minimal system dependencies
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
 
7
  libgl1 \
8
  libglib2.0-0 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Copy requirements
12
  COPY requirements.txt .
13
 
14
  # Install Python dependencies
15
  RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # Create cache directory
18
- RUN mkdir -p /app/cache
19
 
20
- # Copy application
21
- COPY app.py .
 
 
 
 
 
 
 
 
22
 
23
  # Set environment variables
24
  ENV PYTHONUNBUFFERED=1
25
  ENV GRADIO_SERVER_NAME="0.0.0.0"
26
  ENV GRADIO_SERVER_PORT=7860
27
- ENV TRANSFORMERS_CACHE=/app/cache
28
- ENV HUGGINGFACE_HUB_CACHE=/app/cache
29
-
30
- # Expose port
31
- EXPOSE 7860
32
-
33
- # Run as non-root user
34
- RUN useradd -m appuser && chown -R appuser:appuser /app
35
- USER appuser
36
 
 
37
  CMD ["python", "app.py"]
 
1
+ # Use official Python runtime as base image
2
+ FROM python:3.10-slim
3
 
4
+ # Set working directory in container
5
  WORKDIR /app
6
 
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ git \
10
+ gcc \
11
+ g++ \
12
  libgl1 \
13
  libglib2.0-0 \
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 -r requirements.txt
21
 
22
+ # Copy application code
23
+ COPY . .
24
 
25
+ # Create a non-root user and switch to it
26
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
27
+ USER appuser
28
+
29
+ # Expose port for Gradio
30
+ EXPOSE 7860
31
+
32
+ # Health check
33
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
34
+ CMD python -c "import requests; requests.get('http://localhost:7860')"
35
 
36
  # Set environment variables
37
  ENV PYTHONUNBUFFERED=1
38
  ENV GRADIO_SERVER_NAME="0.0.0.0"
39
  ENV GRADIO_SERVER_PORT=7860
 
 
 
 
 
 
 
 
 
40
 
41
+ # Command to run the application
42
  CMD ["python", "app.py"]