Spaces:
Running
Running
ReportRaahat CI commited on
Commit Β·
6c11af5
1
Parent(s): ee7023b
Deploy from GitHub: 7a7927111c5e8750df20b6932a399ea948a415d9
Browse files- Dockerfile +4 -3
- backend/app/main.py +7 -0
- start.sh +17 -0
Dockerfile
CHANGED
|
@@ -40,9 +40,10 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
| 40 |
# Remove default nginx site
|
| 41 |
RUN rm -f /etc/nginx/sites-enabled/default
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
COPY
|
|
|
|
| 45 |
|
| 46 |
EXPOSE 7860
|
| 47 |
|
| 48 |
-
CMD ["
|
|
|
|
| 40 |
# Remove default nginx site
|
| 41 |
RUN rm -f /etc/nginx/sites-enabled/default
|
| 42 |
|
| 43 |
+
# ββ Startup script (writes HF secrets to .env) ββ
|
| 44 |
+
COPY start.sh /app/start.sh
|
| 45 |
+
RUN chmod +x /app/start.sh
|
| 46 |
|
| 47 |
EXPOSE 7860
|
| 48 |
|
| 49 |
+
CMD ["/app/start.sh"]
|
backend/app/main.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
# main.py β MERGED VERSION
|
| 2 |
# Source backend routers (analyze, chat, doctor_upload) + scaffold routers (nutrition, exercise)
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
from contextlib import asynccontextmanager
|
|
@@ -34,8 +38,11 @@ app.add_middleware(
|
|
| 34 |
CORSMiddleware,
|
| 35 |
allow_origins=[
|
| 36 |
"http://localhost:3000",
|
|
|
|
| 37 |
"https://reportraahat.vercel.app",
|
| 38 |
"https://*.vercel.app",
|
|
|
|
|
|
|
| 39 |
],
|
| 40 |
allow_credentials=True,
|
| 41 |
allow_methods=["*"],
|
|
|
|
| 1 |
# main.py β MERGED VERSION
|
| 2 |
# Source backend routers (analyze, chat, doctor_upload) + scaffold routers (nutrition, exercise)
|
| 3 |
|
| 4 |
+
import os
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
load_dotenv() # Load .env file before anything else
|
| 7 |
+
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from contextlib import asynccontextmanager
|
|
|
|
| 38 |
CORSMiddleware,
|
| 39 |
allow_origins=[
|
| 40 |
"http://localhost:3000",
|
| 41 |
+
"http://localhost:7860",
|
| 42 |
"https://reportraahat.vercel.app",
|
| 43 |
"https://*.vercel.app",
|
| 44 |
+
"https://*.hf.space",
|
| 45 |
+
"https://huggingface.co",
|
| 46 |
],
|
| 47 |
allow_credentials=True,
|
| 48 |
allow_methods=["*"],
|
start.sh
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Startup script for HF Spaces
|
| 3 |
+
# HF injects secrets as environment variables β write them to .env so dotenv can load them
|
| 4 |
+
|
| 5 |
+
ENV_FILE="/app/backend/.env"
|
| 6 |
+
|
| 7 |
+
# Write HF-injected secrets to .env
|
| 8 |
+
echo "OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}" > "$ENV_FILE"
|
| 9 |
+
echo "HF_TOKEN=${HF_TOKEN:-}" >> "$ENV_FILE"
|
| 10 |
+
echo "HF_MODEL_ID=${HF_MODEL_ID:-CaffeinatedCoding/reportraahat-simplifier}" >> "$ENV_FILE"
|
| 11 |
+
echo "HF_INDEX_REPO=${HF_INDEX_REPO:-CaffeinatedCoding/reportraahat-indexes}" >> "$ENV_FILE"
|
| 12 |
+
echo "NEXT_PUBLIC_API_URL=http://localhost:8000" >> "$ENV_FILE"
|
| 13 |
+
|
| 14 |
+
echo "β
.env written with $(wc -l < $ENV_FILE) variables"
|
| 15 |
+
|
| 16 |
+
# Start supervisord
|
| 17 |
+
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf
|