Omartificial-Intelligence-Space commited on
Commit
8b24b95
·
verified ·
1 Parent(s): 0d2793f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -7
Dockerfile CHANGED
@@ -3,10 +3,14 @@ FROM python:3.10-slim
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
- RUN apt-get update && apt-get install -y \
 
 
7
  build-essential \
8
  curl \
9
- && rm -rf /var/lib/apt/lists/*
 
 
10
 
11
  # Copy requirements first for better caching
12
  COPY requirements.txt .
@@ -17,8 +21,8 @@ RUN pip install --no-cache-dir -r requirements.txt
17
  # Copy application code
18
  COPY . .
19
 
20
- # Create uploads directory
21
- RUN mkdir -p /app/uploads
22
 
23
  # Set environment variables
24
  ENV PYTHONUNBUFFERED=1
@@ -27,9 +31,10 @@ ENV FLASK_APP=app.py
27
  # Expose the port
28
  EXPOSE 7860
29
 
30
- # Health check
31
- HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
32
  CMD curl -f http://localhost:7860/health || exit 1
33
 
34
- # Run the application
 
35
  CMD ["python", "app.py"]
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
+ # build-essential is needed for some Python packages with C extensions
7
+ # curl is needed for the health check
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
  build-essential \
10
  curl \
11
+ # Clean up apt cache to reduce image size
12
+ && rm -rf /var/lib/apt/lists/* \
13
+ && apt-get clean
14
 
15
  # Copy requirements first for better caching
16
  COPY requirements.txt .
 
21
  # Copy application code
22
  COPY . .
23
 
24
+ # Create uploads directory (although not strictly needed for this version as files are not saved locally)
25
+ # RUN mkdir -p /app/uploads
26
 
27
  # Set environment variables
28
  ENV PYTHONUNBUFFERED=1
 
31
  # Expose the port
32
  EXPOSE 7860
33
 
34
+ # Health check - checks if the /health endpoint returns a 200 status code
35
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
36
  CMD curl -f http://localhost:7860/health || exit 1
37
 
38
+ # Run the application using Python directly (Flask's development server)
39
+ # In production, consider a WSGI server like Gunicorn
40
  CMD ["python", "app.py"]