File size: 1,666 Bytes
1d6ed18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# User Modeling Agent — DSN × BCT LLM Agent Challenge, Task A
# Containerized Streamlit web application.
#
# Build:   docker build -t user-modeling-agent .
# Run:     docker run -p 7860:7860 --env-file .env user-modeling-agent
# Open:    http://localhost:7860
#
# The container needs an LLM key at runtime. Pass it with --env-file .env
# (a file containing LLM_PROVIDER and GEMINI_API_KEY / OPENAI_API_KEY),
# or with -e LLM_PROVIDER=gemini -e GEMINI_API_KEY=...

FROM python:3.11-slim

# System deps occasionally needed by pandas / pyarrow wheels
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python dependencies first so this layer caches across code changes
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application
COPY . .

# Streamlit serves on 7860
EXPOSE 7860

# Container healthcheck — Streamlit exposes a health endpoint
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
    CMD python -c "import urllib.request,sys; urllib.request.urlopen('http://localhost:7860/_stcore/health'); " || exit 1

# Run the Streamlit web app, reachable from outside the container
ENTRYPOINT ["streamlit", "run", "app.py", \
            "--server.port=7860", \
            "--server.address=0.0.0.0", \
            "--server.headless=true"]

# --- Alternative: run the FastAPI service instead of the Streamlit app ---
# Comment out the ENTRYPOINT above and uncomment below:
# EXPOSE 8000
# ENTRYPOINT ["uvicorn", "task_a_user_modeling.main:app", \
#             "--host", "0.0.0.0", "--port", "8000"]