WebashalarForML commited on
Commit
a147cd0
·
verified ·
1 Parent(s): 840ea23

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -50
Dockerfile CHANGED
@@ -1,51 +1,51 @@
1
- # Multi-stage build for production optimization
2
- FROM python:3.11-slim as builder
3
-
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Install system dependencies for building Python packages
8
- RUN apt-get update && apt-get install -y \
9
- gcc \
10
- g++ \
11
- libpq-dev \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Copy requirements and install Python dependencies
15
- COPY requirements.txt .
16
- RUN pip install --no-cache-dir --user -r requirements.txt
17
-
18
- # Production stage
19
- FROM python:3.11-slim
20
-
21
- # Set working directory
22
- WORKDIR /app
23
-
24
- # Install runtime dependencies
25
- RUN apt-get update && apt-get install -y \
26
- libpq5 \
27
- && rm -rf /var/lib/apt/lists/*
28
-
29
- # Copy Python packages from builder stage
30
- COPY --from=builder /root/.local /root/.local
31
-
32
- # Make sure scripts in .local are usable
33
- ENV PATH=/root/.local/bin:$PATH
34
-
35
- # Copy application code
36
- COPY . .
37
-
38
- # Create non-root user for security
39
- RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
40
- RUN chown -R chatuser:chatuser /app
41
- USER chatuser
42
-
43
- # Expose port
44
- EXPOSE 5000
45
-
46
- # Health check
47
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
48
- CMD python -c "import requests; requests.get('http://localhost:5000/health')" || exit 1
49
-
50
- # Default command
51
  CMD ["python", "app.py"]
 
1
+ # Multi-stage build for production optimization
2
+ FROM python:3.11-slim as builder
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies for building Python packages
8
+ RUN apt-get update && apt-get install -y \
9
+ gcc \
10
+ g++ \
11
+ libpq-dev \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Copy requirements and install Python dependencies
15
+ COPY requirements.txt .
16
+ RUN pip install --no-cache-dir --user -r requirements.txt
17
+
18
+ # Production stage
19
+ FROM python:3.11-slim
20
+
21
+ # Set working directory
22
+ WORKDIR /app
23
+
24
+ # Install runtime dependencies
25
+ RUN apt-get update && apt-get install -y \
26
+ libpq5 \
27
+ && rm -rf /var/lib/apt/lists/*
28
+
29
+ # Copy Python packages from builder stage
30
+ COPY --from=builder /root/.local /root/.local
31
+
32
+ # Make sure scripts in .local are usable
33
+ ENV PATH=/root/.local/bin:$PATH
34
+
35
+ # Copy application code
36
+ COPY . .
37
+
38
+ # Create non-root user for security
39
+ RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
40
+ RUN chown -R chatuser:chatuser /app
41
+ USER chatuser
42
+
43
+ # Expose port
44
+ EXPOSE 7860
45
+
46
+ # Health check
47
+ # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
48
+ # CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
49
+
50
+ # Default command
51
  CMD ["python", "app.py"]