Chaitanya895 commited on
Commit
827c087
·
verified ·
1 Parent(s): 84a6e0f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -34
Dockerfile CHANGED
@@ -1,34 +1,39 @@
1
- # Use the official Python slim image for a smaller footprint
2
- FROM python:3.11-slim
3
-
4
- # Set the working directory in the container
5
- WORKDIR /app
6
-
7
- # Install system dependencies (e.g., for psycopg2 if using PostgreSQL)
8
- RUN apt-get update && apt-get install -y --no-install-recommends \
9
- gcc \
10
- python3-dev \
11
- libpq-dev \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Copy the requirements file first to leverage Docker cache
15
- COPY requirements.txt .
16
-
17
- # Install Python dependencies
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
- # Copy the entire application code
21
- COPY . .
22
-
23
- # Ensure static files are collected (if using Flask's static folder)
24
- RUN mkdir -p /app/static
25
-
26
- # Expose the port (Render or other platforms may override this)
27
- EXPOSE 5000
28
-
29
- # Set environment variables for Flask and Gunicorn
30
- ENV FLASK_ENV=production
31
- ENV PYTHONUNBUFFERED=1
32
-
33
- # Command to run the application with gunicorn
34
- CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "3", "--timeout", "120", "app:app"]
 
 
 
 
 
 
1
+ # Use the official Python slim image for a smaller footprint
2
+ FROM python:3.11-slim
3
+
4
+ # Set the working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies for psycopg2 and other potential native extensions
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ gcc \
10
+ python3-dev \
11
+ libpq-dev \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Copy requirements file to leverage Docker cache
15
+ COPY requirements.txt .
16
+
17
+ # Install Python dependencies
18
+ RUN pip install --no-cache-dir -r requirements.txt
19
+
20
+ # Copy the entire application code
21
+ COPY . .
22
+
23
+ # Ensure static files directory exists
24
+ RUN mkdir -p /app/static /app/templates
25
+
26
+ # Expose port 5000 (Render may override)
27
+ EXPOSE 5000
28
+
29
+ # Set environment variables for production
30
+ ENV FLASK_ENV=production
31
+ ENV PYTHONUNBUFFERED=1
32
+ ENV GUNICORN_CMD_ARGS="--workers=3 --timeout=120 --log-level=info"
33
+
34
+ # Command to run the application with gunicorn
35
+ CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
36
+
37
+ # Health check to ensure the app is responsive
38
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
39
+ CMD curl -f http://localhost:5000/health || exit 1