Spaces:
Building
Building
File size: 1,505 Bytes
400e9d1 1fad674 400e9d1 1fad674 400e9d1 1fad674 400e9d1 1fad674 439467e 1fad674 400e9d1 1fad674 400e9d1 1fad674 400e9d1 1fad674 7f44928 1fad674 621bbc1 400e9d1 1fad674 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# Stage 1: Build React frontend
FROM node:14-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend code and install dependencies
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# Stage 2: Build FastAPI backend
FROM python:3.8-alpine AS backend-builder
WORKDIR /app/backend
# Install system dependencies (use lightweight alternatives)
RUN apk update && apk add --no-cache gcc libpq-dev
# Copy backend code and install Python dependencies
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ ./
# Stage 3: Final stage
FROM python:3.8-alpine
WORKDIR /app
# Step 1: Install nodejs, npm, and supervisor
RUN apk update
RUN apk add --no-cache nodejs npm supervisor
# Step 2: Install Python dependencies
RUN pip install --no-cache-dir uvicorn fastapi tqdm wikitextparser pydantic requests beautifulsoup4
# Step 3: Install serve globally for serving React app
RUN npm install -g serve
# No need for apk clean, it's not required
# Copy supervisord configuration
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy built frontend from the first stage
COPY --from=frontend-builder /app/frontend/build /app/frontend/build
# Copy backend from the second stage
COPY --from=backend-builder /app/backend /app/backend
# Expose ports
EXPOSE 7860
EXPOSE 8000
# Start supervisord to manage both React frontend and FastAPI backend
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|