cgoodmaker commited on
Commit
72b1012
·
1 Parent(s): 86f402d

Add HF Spaces Dockerfile, Git LFS for model weights

Browse files
Files changed (4) hide show
  1. .gitattributes +4 -0
  2. .gitignore +0 -4
  3. Dockerfile +18 -15
  4. models/seed42_fold0.pt +3 -0
.gitattributes CHANGED
@@ -1 +1,5 @@
 
 
 
 
1
  guidelines/index/faiss.index filter=lfs diff=lfs merge=lfs -text
 
1
+ models/*.safetensors filter=lfs diff=lfs merge=lfs -text
2
+ models/*.pt filter=lfs diff=lfs merge=lfs -text
3
+ models/*.pth filter=lfs diff=lfs merge=lfs -text
4
+ models/*.bin filter=lfs diff=lfs merge=lfs -text
5
  guidelines/index/faiss.index filter=lfs diff=lfs merge=lfs -text
.gitignore CHANGED
@@ -25,10 +25,6 @@ data/lesions/
25
  data/patients.json
26
 
27
  # Model weights (large binaries — store separately)
28
- models/*.pt
29
- models/*.pth
30
- models/*.bin
31
- models/*.safetensors
32
 
33
  # macOS
34
  .DS_Store
 
25
  data/patients.json
26
 
27
  # Model weights (large binaries — store separately)
 
 
 
 
28
 
29
  # macOS
30
  .DS_Store
Dockerfile CHANGED
@@ -1,40 +1,43 @@
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
3
  WORKDIR /app
4
 
5
  # Install Node.js for building the React frontend
6
  RUN apt-get update && \
7
- apt-get install -y curl && \
8
  curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
9
- apt-get install -y nodejs && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
- # Install Python dependencies
13
- COPY requirements.txt ml-requirements.txt
14
- COPY backend/requirements.txt api-requirements.txt
15
  RUN pip install --no-cache-dir -r ml-requirements.txt -r api-requirements.txt
16
 
17
  # Build React frontend
18
- COPY web/ web/
19
  WORKDIR /app/web
20
  RUN npm ci && npm run build
21
 
22
  WORKDIR /app
23
 
24
  # Copy application source
25
- COPY models/ models/
26
- COPY backend/ backend/
27
- COPY data/case_store.py data/case_store.py
28
- COPY guidelines/ guidelines/
29
 
30
- # Runtime directories (writable by the app)
31
  RUN mkdir -p data/uploads data/patient_chats data/lesions && \
32
- echo '{"patients": []}' > data/patients.json
 
33
 
34
- # HF Spaces runs as a non-root user — ensure data dirs are writable
35
- RUN chmod -R 777 data/
36
 
37
- # HF Spaces uses port 7860
38
  EXPOSE 7860
39
 
40
  CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
  FROM python:3.10-slim
3
 
4
+ # HF Spaces runs as uid 1000
5
+ RUN useradd -m -u 1000 user
6
+ ENV PATH="/home/user/.local/bin:$PATH"
7
+
8
  WORKDIR /app
9
 
10
  # Install Node.js for building the React frontend
11
  RUN apt-get update && \
 
12
  curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
13
+ apt-get install -y nodejs curl && \
14
  rm -rf /var/lib/apt/lists/*
15
 
16
+ # Install Python dependencies as root (faster) then hand off to user
17
+ COPY --chown=user requirements.txt ml-requirements.txt
18
+ COPY --chown=user backend/requirements.txt api-requirements.txt
19
  RUN pip install --no-cache-dir -r ml-requirements.txt -r api-requirements.txt
20
 
21
  # Build React frontend
22
+ COPY --chown=user web/ web/
23
  WORKDIR /app/web
24
  RUN npm ci && npm run build
25
 
26
  WORKDIR /app
27
 
28
  # Copy application source
29
+ COPY --chown=user models/ models/
30
+ COPY --chown=user backend/ backend/
31
+ COPY --chown=user data/case_store.py data/case_store.py
32
+ COPY --chown=user guidelines/ guidelines/
33
 
34
+ # Runtime data directories — must be writable by user 1000
35
  RUN mkdir -p data/uploads data/patient_chats data/lesions && \
36
+ echo '{"patients": []}' > data/patients.json && \
37
+ chown -R user:user data/
38
 
39
+ USER user
 
40
 
 
41
  EXPOSE 7860
42
 
43
  CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
models/seed42_fold0.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:377e92a4f813a15b11c67977d27025ce5c526e95b069730719235b3ae471e42a
3
+ size 355288009