Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +35 -0
Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:20-bullseye AS frontend_build
|
| 2 |
+
WORKDIR /app/frontend
|
| 3 |
+
COPY frontend/package.json frontend/package-lock.json* ./
|
| 4 |
+
RUN npm install
|
| 5 |
+
COPY frontend/ ./
|
| 6 |
+
RUN npm run build
|
| 7 |
+
|
| 8 |
+
FROM python:3.11-slim AS runtime
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
# backend
|
| 12 |
+
COPY backend/requirements.txt /app/backend/requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir -r /app/backend/requirements.txt
|
| 14 |
+
COPY backend/ /app/backend/
|
| 15 |
+
|
| 16 |
+
# frontend dist
|
| 17 |
+
COPY --from=frontend_build /app/frontend/dist /app/frontend_dist
|
| 18 |
+
|
| 19 |
+
# simple static serving via fastapi
|
| 20 |
+
RUN pip install --no-cache-dir starlette==0.38.5
|
| 21 |
+
|
| 22 |
+
ENV PORT=7860
|
| 23 |
+
|
| 24 |
+
# Start FastAPI + serve frontend dist
|
| 25 |
+
CMD ["bash", "-lc", "python -c \"\
|
| 26 |
+
import os; \
|
| 27 |
+
from fastapi import FastAPI; \
|
| 28 |
+
from fastapi.staticfiles import StaticFiles; \
|
| 29 |
+
from backend.main import app as api; \
|
| 30 |
+
app = FastAPI(); \
|
| 31 |
+
app.mount('/api', api); \
|
| 32 |
+
app.mount('/', StaticFiles(directory='/app/frontend_dist', html=True), name='static'); \
|
| 33 |
+
import uvicorn; \
|
| 34 |
+
uvicorn.run(app, host='0.0.0.0', port=int(os.environ.get('PORT','7860'))); \
|
| 35 |
+
\""]
|