Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +4 -29
Dockerfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
FROM node:20-slim AS frontend-builder
|
| 2 |
WORKDIR /app/frontend
|
| 3 |
-
COPY frontend/package.json
|
| 4 |
RUN npm install
|
| 5 |
COPY frontend/ ./
|
| 6 |
RUN npm run build
|
|
@@ -8,39 +8,14 @@ RUN npm run build
|
|
| 8 |
FROM python:3.11-slim
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
-
# Install Python deps
|
| 12 |
COPY backend/requirements.txt .
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
| 15 |
-
# Copy backend
|
| 16 |
COPY backend/ ./backend/
|
| 17 |
-
|
| 18 |
-
# Copy built React frontend into backend static folder
|
| 19 |
COPY --from=frontend-builder /app/frontend/dist ./backend/static
|
| 20 |
|
| 21 |
-
|
| 22 |
-
RUN python
|
| 23 |
-
content = open('backend/main.py').read()
|
| 24 |
-
patch = '''
|
| 25 |
-
from fastapi.staticfiles import StaticFiles
|
| 26 |
-
from fastapi.responses import FileResponse
|
| 27 |
-
import os
|
| 28 |
-
|
| 29 |
-
static_dir = os.path.join(os.path.dirname(__file__), 'static')
|
| 30 |
-
if os.path.exists(static_dir):
|
| 31 |
-
app.mount('/assets', StaticFiles(directory=os.path.join(static_dir,'assets')), name='assets')
|
| 32 |
-
|
| 33 |
-
@app.get('/{full_path:path}')
|
| 34 |
-
async def serve_spa(full_path: str):
|
| 35 |
-
index = os.path.join(static_dir, 'index.html')
|
| 36 |
-
return FileResponse(index)
|
| 37 |
-
'''
|
| 38 |
-
# Insert after CORS middleware setup
|
| 39 |
-
insert_after = 'allow_headers=[\"*\"],\n)'
|
| 40 |
-
content = content.replace(insert_after, insert_after + '\n' + patch)
|
| 41 |
-
open('backend/main.py','w').write(content)
|
| 42 |
-
"
|
| 43 |
|
| 44 |
EXPOSE 7860
|
| 45 |
-
|
| 46 |
-
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
FROM node:20-slim AS frontend-builder
|
| 2 |
WORKDIR /app/frontend
|
| 3 |
+
COPY frontend/package.json ./
|
| 4 |
RUN npm install
|
| 5 |
COPY frontend/ ./
|
| 6 |
RUN npm run build
|
|
|
|
| 8 |
FROM python:3.11-slim
|
| 9 |
WORKDIR /app
|
| 10 |
|
|
|
|
| 11 |
COPY backend/requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
|
|
|
| 14 |
COPY backend/ ./backend/
|
|
|
|
|
|
|
| 15 |
COPY --from=frontend-builder /app/frontend/dist ./backend/static
|
| 16 |
|
| 17 |
+
COPY patch.py ./patch.py
|
| 18 |
+
RUN python patch.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
EXPOSE 7860
|
| 21 |
+
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|