Nothing12Man commited on
Commit
d0dcff2
Β·
1 Parent(s): d4e5928

Fix missing backend requirements path

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -58
Dockerfile CHANGED
@@ -1,70 +1,41 @@
1
- # ── Base image (lightweight, CPU-only) ────────────────────────────────────────
2
- FROM python:3.11-slim
3
 
4
- # ── Metadata ──────────────────────────────────────────────────────────────────
5
- LABEL maintainer="MediRoute Team" \
6
- env_id="mediroute-openenv-v1" \
7
- version="1.0.0" \
8
- description="Medical Triage and Hospital Routing OpenEnv Environment" \
9
- org.opencontainers.image.title="MediRoute OpenEnv" \
10
- org.opencontainers.image.licenses="MIT"
11
 
12
- # ── System dependencies ───────────────────────────────────────────────────────
13
- RUN apt-get update && apt-get install -y --no-install-recommends \
14
- curl \
15
- ca-certificates \
16
- gnupg \
17
- build-essential \
18
- && rm -rf /var/lib/apt/lists/*
19
-
20
- # ── Python runtime defaults ───────────────────────────────────────────────────
21
- ENV PYTHONDONTWRITEBYTECODE=1 \
22
- PYTHONUNBUFFERED=1
23
 
24
- # ── Working directory ─────────────────────────────────────────────────────────
25
  WORKDIR /app
26
 
27
- # ── Install Python dependencies first (cache-friendly layer) ──────────────────
28
- COPY requirements.txt .
29
- RUN pip install --no-cache-dir --upgrade pip \
30
- && pip install --no-cache-dir -r requirements.txt
 
31
 
32
- # If a backend requirements file exists (lifeline-ai/backend/requirements.txt), install it too
33
- COPY backend/requirements.txt ./backend-requirements.txt
34
- RUN if [ -f ./backend-requirements.txt ]; then \
35
- pip install --no-cache-dir -r ./backend-requirements.txt; \
36
- fi
 
 
37
 
38
- # Backwards-compat: install lifeline-ai/backend/requirements.txt if present
39
- COPY lifeline-ai/backend/requirements.txt ./lifeline-ai-backend-requirements.txt
40
- RUN if [ -f ./lifeline-ai-backend-requirements.txt ]; then \
41
- pip install --no-cache-dir -r ./lifeline-ai-backend-requirements.txt; \
42
- fi
43
 
44
- # ── Copy application source safely ────────────────────────────────────────────
45
- # Copying the full project avoids file-not-found build breaks and is HF-Spaces-friendly.
46
  COPY . .
 
47
 
48
- # Install Node.js and build the Next.js frontend (do this as root before switching user)
49
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
50
- && apt-get update && apt-get install -y --no-install-recommends nodejs \
51
- && rm -rf /var/lib/apt/lists/* \
52
- && npm ci --prefix lifeline-ai --no-audit --no-fund || npm install --prefix lifeline-ai \
53
- && npm run build --prefix lifeline-ai
54
-
55
- # ── Non-root user for security ────────────────────────────────────────────────
56
- RUN adduser --disabled-password --gecos "" appuser
57
- USER appuser
58
-
59
- # ── Environment variable defaults (override at runtime) ───────────────────────
60
- ENV OPENAI_API_KEY="EMPTY" \
61
- API_BASE_URL="https://api.openai.com/v1" \
62
- MODEL_NAME="gpt-4o-mini" \
63
- HF_TOKEN=""
64
-
65
- # ── Expose the port expected by Hugging Face Spaces (frontend)
66
  EXPOSE 7860
67
 
68
- # Default command: start backend on 8000 (background) and run Next.js frontend on 7860
69
- # The frontend proxies /api to the backend via next.config.js rewrites.
70
- CMD ["sh", "-c", "uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 & exec npm run start --prefix lifeline-ai -- -p 7860"]
 
1
+ # LifeLine AI - Spaces-ready Dockerfile (clean, repo-root centric)
2
+ FROM node:20-slim
3
 
4
+ LABEL maintainer="LifeLine Team" \
5
+ org.opencontainers.image.title="LifeLine AI" \
6
+ description="Next.js frontend with optional Python FastAPI backend (Hugging Face Spaces ready)"
 
 
 
 
7
 
8
+ ENV NODE_ENV=production \
9
+ PYTHONUNBUFFERED=1 \
10
+ DEBIAN_FRONTEND=noninteractive
 
 
 
 
 
 
 
 
11
 
 
12
  WORKDIR /app
13
 
14
+ # Install minimal system deps (python + build tools)
15
+ RUN apt-get update \
16
+ && apt-get install -y --no-install-recommends \
17
+ python3 python3-pip ca-certificates curl build-essential \
18
+ && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Copy Node package manifests and install Node deps from repo root
21
+ COPY package*.json ./
22
+ RUN if [ -f package-lock.json ]; then \
23
+ npm ci --no-audit --no-fund; \
24
+ else \
25
+ npm install --no-audit --no-fund; \
26
+ fi
27
 
28
+ # Install Python dependencies from repo-root requirements.txt only
29
+ COPY requirements.txt .
30
+ RUN pip install --no-cache-dir --upgrade pip && \
31
+ pip install --no-cache-dir -r requirements.txt
 
32
 
33
+ # Copy the rest of the repository and build the Next.js frontend
 
34
  COPY . .
35
+ RUN npm run build
36
 
37
+ # Expose the UI port for Hugging Face Spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  EXPOSE 7860
39
 
40
+ # Start backend (if present) on localhost:8000 in background, then run Next.js frontend on 7860
41
+ CMD ["sh", "-c", "uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 2>/dev/null & exec npm run start -- -p 7860"]