Update Dockerfile
Browse files- Dockerfile +20 -17
Dockerfile
CHANGED
|
@@ -1,35 +1,38 @@
|
|
| 1 |
# ==========================================
|
| 2 |
-
# STAGE 1: Build the
|
| 3 |
# ==========================================
|
| 4 |
FROM node:20-alpine AS frontend-builder
|
| 5 |
WORKDIR /app/frontend
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
COPY frontend/ .
|
| 9 |
-
RUN
|
| 10 |
|
| 11 |
# ==========================================
|
| 12 |
-
# STAGE 2:
|
| 13 |
# ==========================================
|
| 14 |
-
FROM
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
-
# Install
|
|
|
|
| 18 |
RUN npm install -g serve
|
| 19 |
|
| 20 |
-
# Copy
|
| 21 |
-
COPY --from=frontend-builder /app/frontend/
|
| 22 |
|
| 23 |
-
#
|
| 24 |
COPY backend/ ./backend
|
| 25 |
-
|
| 26 |
-
# Install backend dependencies (Assuming Node.js backend. If Go/Python, we adapt)
|
| 27 |
WORKDIR /app/backend
|
| 28 |
-
|
| 29 |
-
RUN yarn install --frozen-lockfile
|
| 30 |
|
| 31 |
-
#
|
| 32 |
EXPOSE 7860
|
| 33 |
|
| 34 |
-
# Launch
|
| 35 |
-
|
|
|
|
|
|
| 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
|