Update Dockerfile
Browse files- Dockerfile +15 -11
Dockerfile
CHANGED
|
@@ -1,34 +1,38 @@
|
|
| 1 |
# ==========================================
|
| 2 |
-
# STAGE 1: Build the
|
| 3 |
# ==========================================
|
| 4 |
FROM node:20-alpine AS frontend-builder
|
| 5 |
WORKDIR /app/frontend
|
|
|
|
|
|
|
| 6 |
COPY frontend/package*.json ./
|
| 7 |
RUN npm install
|
|
|
|
|
|
|
| 8 |
COPY frontend/ .
|
| 9 |
RUN npm run build
|
| 10 |
|
| 11 |
# ==========================================
|
| 12 |
-
# STAGE 2: Setup Python Backend &
|
| 13 |
# ==========================================
|
| 14 |
FROM python:3.11-slim
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
# Install Node
|
| 18 |
-
RUN apt-get update && apt-get install -y nodejs npm && rm -rf /lib/apt/lists/*
|
| 19 |
RUN npm install -g serve
|
| 20 |
|
| 21 |
-
# Copy
|
| 22 |
-
COPY --from=frontend-builder /app/frontend/
|
| 23 |
|
| 24 |
-
#
|
| 25 |
COPY backend/ ./backend
|
| 26 |
WORKDIR /app/backend
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
-
# Hugging Face Spaces
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
-
# Launch Step: Start the Python
|
| 33 |
-
# and
|
| 34 |
-
CMD uvicorn
|
|
|
|
| 1 |
# ==========================================
|
| 2 |
+
# STAGE 1: Build the Vite Frontend Assets
|
| 3 |
# ==========================================
|
| 4 |
FROM node:20-alpine AS frontend-builder
|
| 5 |
WORKDIR /app/frontend
|
| 6 |
+
|
| 7 |
+
# Copy dependencies descriptor files
|
| 8 |
COPY frontend/package*.json ./
|
| 9 |
RUN npm install
|
| 10 |
+
|
| 11 |
+
# Copy frontend source and build it
|
| 12 |
COPY frontend/ .
|
| 13 |
RUN npm run build
|
| 14 |
|
| 15 |
# ==========================================
|
| 16 |
+
# STAGE 2: Setup Python Backend & Final Image
|
| 17 |
# ==========================================
|
| 18 |
FROM python:3.11-slim
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
+
# Install Node.js runtime inside the Python container to serve frontend static pages
|
| 22 |
+
RUN apt-get update && apt-get install -y nodejs npm && rm -rf /var/lib/apt/lists/*
|
| 23 |
RUN npm install -g serve
|
| 24 |
|
| 25 |
+
# Copy Vite production build assets from Stage 1 into /app/dist
|
| 26 |
+
COPY --from=frontend-builder /app/frontend/dist ./dist
|
| 27 |
|
| 28 |
+
# Set up the Python Backend requirements
|
| 29 |
COPY backend/ ./backend
|
| 30 |
WORKDIR /app/backend
|
| 31 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 32 |
|
| 33 |
+
# Hugging Face Spaces strictly requires listening on port 7860
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Launch Step: Start the Python backend (app.py) on port 8000,
|
| 37 |
+
# and start the frontend serving application directly on port 7860
|
| 38 |
+
CMD uvicorn app:app --host 0.0.0.0 --port 8000 & serve -s /app/dist -l 7860
|