File size: 1,519 Bytes
68b95db
ef5ef96
 
 
9ee7abb
 
 
 
ef5ef96
9ee7abb
 
 
 
ef5ef96
a156160
9ee7abb
af49a43
9ee7abb
 
 
977b1c3
9ab4c95
ef5ef96
9ee7abb
 
 
ef5ef96
9ee7abb
9ab4c95
 
5855a4f
d8a9f5f
a156160
977b1c3
 
 
9ab4c95
015d69d
9ab4c95
9ee7abb
 
 
 
 
68b95db
a156160
977b1c3
ef5ef96
9ab4c95
 
 
 
68b95db
015d69d
9ee7abb
feee140
 
5855a4f
af49a43
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
FROM python:3.9-slim

WORKDIR /app

# Install system dependencies with verbose output
RUN set -x && \
    apt-get update && \
    apt-get install -y \
    build-essential \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/* \
    && echo "System dependencies installed successfully"

# Create directories with secure permissions
RUN set -x && \
    mkdir -p cache/huggingface cache/matplotlib vector_store chat_history && \
    chown -R 1000:1000 . && \
    chmod -R 755 . && \
    echo "Directories created successfully"

# Copy requirements first for better caching
COPY requirements.txt .
RUN set -x && \
    pip install --no-cache-dir -r requirements.txt && \
    echo "Python dependencies installed successfully"

# Copy application files
COPY app.py .
COPY index.html .
COPY api/ ./api/

# Set environment variables
ENV HF_HOME=/app/cache/huggingface
ENV HUGGINGFACE_HUB_CACHE=/app/cache/huggingface
ENV XDG_CACHE_HOME=/app/cache
ENV PORT=8000

# Set permissions
RUN set -x && \
    chown -R 1000:1000 /app && \
    find /app -type d -exec chmod 755 {} \; && \
    find /app -type f -exec chmod 644 {} \; && \
    echo "Permissions set successfully"

# Run as non-privileged user
USER 1000

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:8000/health || exit 1

EXPOSE 8000

# Use a startup script with debug output
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
CMD ["python", "app.py"]