abbasi1982 commited on
Commit
67dfd77
·
verified ·
1 Parent(s): 1c73101

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -36
Dockerfile CHANGED
@@ -1,50 +1,48 @@
1
- # Hugging Face Spaces Dockerfile (clone-from-GitHub variant).
2
- #
3
- # Pulls the source from a private GitHub repo using a build-time GITHUB_TOKEN
4
- # secret, then runs BOTH apps behind a single port that HF exposes:
5
- # nginx (:8000 = app_port) -> FastAPI voice app (:8001)
6
- # -> Streamlit dashboard (:8501, under /dashboard)
7
- # supervisord keeps all three processes alive.
8
-
9
  FROM python:3.12
10
 
11
- LABEL maintainer="ductz-demo"
12
-
13
- WORKDIR /workspace
14
 
15
- # git/build tools + nginx (reverse-proxies the app and dashboard onto one port).
16
- RUN apt-get update && apt-get install -y \
17
  git \
18
  build-essential \
19
- nginx \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # Clone the private repo using the GITHUB_TOKEN build secret. The token is
23
- # mounted only for this step and is NOT baked into any image layer.
24
- RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
25
- git clone https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/saghir-abbasi/duct_z.git /workspace
26
 
27
- RUN pip install uv
28
- RUN uv sync --frozen
29
- # supervisord (in the project venv) manages uvicorn + streamlit + nginx.
30
- RUN uv pip install supervisor
31
 
32
- # Run as a non-root user with UID 1000 (Hugging Face Spaces convention) and let
33
- # it own /workspace plus nginx's runtime dirs so nginx can run unprivileged.
34
- RUN useradd -m -u 1000 appuser \
35
- && mkdir -p /var/lib/nginx /var/log/nginx \
36
- && chown -R appuser:appuser /workspace /var/lib/nginx /var/log/nginx
37
 
38
- USER appuser
 
 
 
 
 
 
 
 
39
 
40
- # Build the structured catalog DB and the local Chroma vector store at
41
- # image-build time. `uv run ingest` also downloads the fastembed model
42
- # (~110MB) into the cache, so the first runtime query is fast.
43
- RUN uv run build_db
44
- RUN uv run ingest
45
 
46
- EXPOSE 8000
 
 
 
47
 
48
- # nginx (public :8000) fronts FastAPI :8001 and Streamlit :8501 (/dashboard).
49
- CMD ["/workspace/.venv/bin/supervisord", "-c", "/workspace/deploy/supervisord.conf"]
50
 
 
 
 
 
1
+ # Hugging Face Docker Space.
2
+ # Space settings -> Variables and secrets:
3
+ # GITHUB_TOKEN (secret, read access to the private repo; used at build time)
4
+ # OPENAI_API_KEY and the other .env values (secrets/variables, used at runtime)
 
 
 
 
5
  FROM python:3.12
6
 
7
+ LABEL maintainer="insurance_agent"
 
 
8
 
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
 
10
  git \
11
  build-essential \
 
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ RUN pip install --no-cache-dir uv
 
 
 
15
 
16
+ # Spaces run the container as UID 1000; build as that user so every file
17
+ # (profiles, active_profile.json, Chroma stores) is writable at runtime.
18
+ RUN useradd --create-home --uid 1000 user
19
+ USER user
20
 
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/app/.venv/bin:$PATH \
23
+ PYTHONUNBUFFERED=1 \
24
+ UV_LINK_MODE=copy \
25
+ FASTEMBED_CACHE_PATH=/home/user/app/.cache/fastembed
26
 
27
+ WORKDIR /home/user/app
28
+
29
+ # Bump to force a fresh clone when the Docker layer cache would reuse an old one.
30
+ ARG REPO_REVISION=1
31
+
32
+ # Use token to clone the private repo
33
+ RUN --mount=type=secret,id=GITHUB_TOKEN,mode=0444,required=true \
34
+ git clone --depth 1 https://$(cat /run/secrets/GITHUB_TOKEN)@github.com/saghir-abbasi/call_center_demo.git . \
35
+ && rm -rf .git
36
 
37
+ RUN uv sync --frozen --no-dev
 
 
 
 
38
 
39
+ # Build the Chroma vector stores of every agent profile (data/profiles/*/knowledge.*)
40
+ # at image-build time. This also downloads the fastembed model (~110MB) into
41
+ # FASTEMBED_CACHE_PATH, so the first runtime call is fast.
42
+ RUN uv run --no-sync ingest --all
43
 
44
+ EXPOSE 7860
 
45
 
46
+ # The browser call page (/app) opens its WebSocket on whatever host served it,
47
+ # so no DOMAIN_URL override is needed for the port.
48
+ CMD ["uvicorn", "src.insurance_agent.main:app", "--host", "0.0.0.0", "--port", "7860"]