Spaces:
Running
Running
File size: 946 Bytes
aaa634c 96b4d2b aaa634c 40ed212 aaa634c | 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 | # Stage 1: Build the React frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files and install dependencies
COPY algospaced-ui/package*.json ./
RUN npm install
# Copy the rest of the frontend source code
COPY algospaced-ui/ ./
# Run the build
RUN npm run build
# Stage 2: Run the FastAPI backend
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy all source files
COPY . .
# Copy compiled frontend from Stage 1 into the backend's static directory
COPY --from=frontend-builder /app/frontend/dist ./algospaced-ui/dist
# Expose port (Render/Railway will set PORT env var, default to 8000)
ENV PORT=8000
CMD uvicorn main:app --host 0.0.0.0 --port $PORT
|