Spaces:
Sleeping
Sleeping
Commit Β·
e92e954
1
Parent(s): 37eddd3
Add root route for HF Space homepage
Browse files- Dockerfile +15 -5
- lifeline-ai/next.config.js +14 -0
Dockerfile
CHANGED
|
@@ -12,6 +12,9 @@ LABEL maintainer="MediRoute Team" \
|
|
| 12 |
# ββ System dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
curl \
|
|
|
|
|
|
|
|
|
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
# ββ Python runtime defaults βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -36,6 +39,14 @@ RUN if [ -f ./lifeline-backend-requirements.txt ]; then \
|
|
| 36 |
# Copying the full project avoids file-not-found build breaks and is HF-Spaces-friendly.
|
| 37 |
COPY . .
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# ββ Non-root user for security ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 40 |
RUN adduser --disabled-password --gecos "" appuser
|
| 41 |
USER appuser
|
|
@@ -46,10 +57,9 @@ ENV OPENAI_API_KEY="EMPTY" \
|
|
| 46 |
MODEL_NAME="gpt-4o-mini" \
|
| 47 |
HF_TOKEN=""
|
| 48 |
|
| 49 |
-
# ββ Expose the port expected by Hugging Face Spaces
|
| 50 |
EXPOSE 7860
|
| 51 |
|
| 52 |
-
# Default command: start
|
| 53 |
-
#
|
| 54 |
-
|
| 55 |
-
CMD ["sh", "-c", "uvicorn backend.app.main:app --host 0.0.0.0 --port 7860"]
|
|
|
|
| 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 βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 39 |
# Copying the full project avoids file-not-found build breaks and is HF-Spaces-friendly.
|
| 40 |
COPY . .
|
| 41 |
|
| 42 |
+
# Install Node.js and build the Next.js frontend (do this as root before switching user)
|
| 43 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 44 |
+
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
|
| 45 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 46 |
+
&& cd lifeline-ai \
|
| 47 |
+
&& npm ci --no-audit --no-fund || npm install \
|
| 48 |
+
&& npm run build
|
| 49 |
+
|
| 50 |
# ββ Non-root user for security ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 51 |
RUN adduser --disabled-password --gecos "" appuser
|
| 52 |
USER appuser
|
|
|
|
| 57 |
MODEL_NAME="gpt-4o-mini" \
|
| 58 |
HF_TOKEN=""
|
| 59 |
|
| 60 |
+
# ββ Expose the port expected by Hugging Face Spaces (frontend)
|
| 61 |
EXPOSE 7860
|
| 62 |
|
| 63 |
+
# Default command: start backend on 8000 (background) and run Next.js frontend on 7860
|
| 64 |
+
# The frontend proxies /api to the backend via next.config.js rewrites.
|
| 65 |
+
CMD ["sh", "-c", "uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 & cd lifeline-ai && exec npm run start -- -p 7860"]
|
|
|
lifeline-ai/next.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Next.js configuration: proxy /api requests to the local FastAPI backend
|
| 3 |
+
* so the frontend can call /api/* and the backend remains accessible.
|
| 4 |
+
*/
|
| 5 |
+
/** @type {import('next').NextConfig} */
|
| 6 |
+
module.exports = {
|
| 7 |
+
reactStrictMode: true,
|
| 8 |
+
async rewrites() {
|
| 9 |
+
return [
|
| 10 |
+
{ source: '/api/:path*', destination: 'http://127.0.0.1:8000/:path*' },
|
| 11 |
+
{ source: '/api', destination: 'http://127.0.0.1:8000/' },
|
| 12 |
+
];
|
| 13 |
+
},
|
| 14 |
+
};
|