File size: 1,802 Bytes
6dc9d46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# RagBot API - Multi-stage Docker Build

FROM python:3.11-slim as base

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    git \
    && rm -rf /var/lib/apt/lists/*

# ============================================================================
# STAGE 1: Install RagBot core dependencies
# ============================================================================
FROM base as ragbot-deps

# Copy RagBot requirements
COPY ../requirements.txt /app/ragbot_requirements.txt

# Install RagBot dependencies
RUN pip install --no-cache-dir -r /app/ragbot_requirements.txt

# ============================================================================
# STAGE 2: Install API dependencies
# ============================================================================
FROM ragbot-deps as api-deps

# Copy API requirements
COPY requirements.txt /app/api_requirements.txt

# Install API dependencies
RUN pip install --no-cache-dir -r /app/api_requirements.txt

# ============================================================================
# STAGE 3: Build final image
# ============================================================================
FROM api-deps as final

# Copy entire RagBot source (needed for imports)
COPY ../ /app/ragbot/

# Set Python path to include RagBot
ENV PYTHONPATH=/app/ragbot:$PYTHONPATH

# Copy API application
COPY ./app /app/api/app

# Set working directory to API
WORKDIR /app/api

# Expose API port
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD python -c "import requests; requests.get('http://localhost:8000/api/v1/health')"

# Run FastAPI with uvicorn
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]