File size: 2,037 Bytes
2cf7d68
 
a147cd0
2cf7d68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a147cd0
2cf7d68
 
a147cd0
2cf7d68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a147cd0
fbf6006
a147cd0
 
fbf6006
a147cd0
 
fbf6006
 
 
 
 
 
 
a147cd0
fbf6006
 
 
 
a147cd0
fbf6006
a147cd0
 
390a2a6
 
 
fbf6006
a147cd0
fbf6006
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# # Multi-stage build for production optimization
# FROM python:3.11-slim as builder

# # Set working directory
# WORKDIR /app

# # Install system dependencies for building Python packages
# RUN apt-get update && apt-get install -y \
#     gcc \
#     g++ \
#     libpq-dev \
#     && rm -rf /var/lib/apt/lists/*

# # Copy requirements and install Python dependencies
# COPY requirements.txt .
# # RUN pip install --no-cache-dir --user -r requirements.txt
# RUN pip install --no-cache-dir -r requirements.txt

# # Production stage
# FROM python:3.11-slim

# # Set working directory
# WORKDIR /app

# # Install runtime dependencies
# RUN apt-get update && apt-get install -y \
#     libpq5 \
#     && rm -rf /var/lib/apt/lists/*

# # Copy Python packages from builder stage
# COPY --from=builder /root/.local /root/.local

# # Make sure scripts in .local are usable
# ENV PATH=/root/.local/bin:$PATH

# # Copy application code
# COPY . .

# # Create non-root user for security
# RUN groupadd -r chatuser && useradd -r -g chatuser chatuser
# RUN chown -R chatuser:chatuser /app
# USER chatuser

# # Expose port
# EXPOSE 7860

# # Health check
# # HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
# #     CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1

# # Default command
# CMD ["python", "app.py"]

# Use a public Python image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies needed for your packages
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    libpq-dev \
    libpq5 \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Create logs directory and give full access
RUN mkdir -p /app/logs && chmod 777 /app/logs

# Expose port (HF Spaces typically uses 7860)
EXPOSE 7860

# Default command to run your Flask app
CMD ["python", "app.py"]