Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -4
Dockerfile
CHANGED
@@ -1,8 +1,20 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
WORKDIR /app
|
3 |
COPY requirements.txt .
|
4 |
-
RUN pip install -r requirements.txt
|
5 |
COPY . .
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
8 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# Stage 1: Build the React frontend
|
2 |
+
FROM node:18 AS frontend-build
|
3 |
+
WORKDIR /app/frontend
|
4 |
+
COPY frontend/package.json frontend/package-lock.json ./
|
5 |
+
RUN npm ci
|
6 |
+
COPY frontend ./
|
7 |
+
RUN npm run build
|
8 |
+
|
9 |
+
# Stage 2: Build the Python backend
|
10 |
+
FROM python:3.10-slim AS backend
|
11 |
WORKDIR /app
|
12 |
COPY requirements.txt .
|
13 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
14 |
COPY . .
|
15 |
+
|
16 |
+
# Copy the built React frontend from the previous stage
|
17 |
+
COPY --from=frontend-build /app/frontend/build ./frontend/build
|
18 |
+
|
19 |
+
# Expose the port and run the FastAPI app
|
20 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|