WebashalarForML commited on
Commit
2cf7d68
·
verified ·
1 Parent(s): 5bd27b9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +55 -33
Dockerfile CHANGED
@@ -1,52 +1,74 @@
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
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  # Production stage
20
  FROM python:3.11-slim
21
 
22
- # Set working directory
23
  WORKDIR /app
24
 
25
- # Install runtime dependencies
26
- RUN apt-get update && apt-get install -y \
27
- libpq5 \
28
- && rm -rf /var/lib/apt/lists/*
29
 
30
- # Copy Python packages from builder stage
31
- COPY --from=builder /root/.local /root/.local
 
32
 
33
- # Make sure scripts in .local are usable
34
- ENV PATH=/root/.local/bin:$PATH
35
-
36
- # Copy application code
37
  COPY . .
38
 
39
- # Create non-root user for security
40
  RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
41
  RUN chown -R chatuser:chatuser /app
42
  USER chatuser
43
 
44
- # Expose port
45
  EXPOSE 7860
46
-
47
- # Health check
48
- # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
49
- # CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
50
-
51
- # Default command
52
  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
+ # RUN pip install --no-cache-dir -r requirements.txt
18
+
19
+ # # Production stage
20
+ # FROM python:3.11-slim
21
+
22
+ # # Set working directory
23
+ # WORKDIR /app
24
+
25
+ # # Install runtime dependencies
26
+ # RUN apt-get update && apt-get install -y \
27
+ # libpq5 \
28
+ # && rm -rf /var/lib/apt/lists/*
29
+
30
+ # # Copy Python packages from builder stage
31
+ # COPY --from=builder /root/.local /root/.local
32
 
33
+ # # Make sure scripts in .local are usable
34
+ # ENV PATH=/root/.local/bin:$PATH
 
 
 
 
35
 
36
+ # # Copy application code
37
+ # COPY . .
38
+
39
+ # # Create non-root user for security
40
+ # RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
41
+ # RUN chown -R chatuser:chatuser /app
42
+ # USER chatuser
43
+
44
+ # # Expose port
45
+ # EXPOSE 7860
46
+
47
+ # # Health check
48
+ # # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
49
+ # # CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
50
+
51
+ # # Default command
52
+ # CMD ["python", "app.py"]
53
 
54
  # Production stage
55
  FROM python:3.11-slim
56
 
 
57
  WORKDIR /app
58
 
59
+ RUN apt-get update && apt-get install -y libpq5 && rm -rf /var/lib/apt/lists/*
 
 
 
60
 
61
+ # Copy installed packages from builder
62
+ COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
63
+ COPY --from=builder /usr/local/bin /usr/local/bin
64
 
65
+ # Copy app code
 
 
 
66
  COPY . .
67
 
68
+ # Non-root user
69
  RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
70
  RUN chown -R chatuser:chatuser /app
71
  USER chatuser
72
 
 
73
  EXPOSE 7860
 
 
 
 
 
 
74
  CMD ["python", "app.py"]