timetablev2 / Dockerfile
notha99y's picture
build frontend
86fb3c2
Raw History Blame Contribute Delete
1.14 kB
# Use Python 3.11 as base image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js 18
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs
# Copy backend requirements and install Python dependencies
COPY backend/requirements.txt /app/backend/
RUN pip install --no-cache-dir -r backend/requirements.txt
# Copy frontend package files and install Node dependencies
COPY frontend/package*.json /app/frontend/
WORKDIR /app/frontend
# Try npm ci first, fallback to npm install if lock file is out of sync
RUN npm ci || npm install
# Copy all source code
WORKDIR /app
COPY . .
# Build the React frontend
WORKDIR /app/frontend
RUN npm run build
# Set working directory back to app root and add to Python path
WORKDIR /app
ENV PYTHONPATH=/app
# Expose port 7860 (required by Hugging Face Spaces)
EXPOSE 7860
# Start the FastAPI server from the backend directory
CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]