Spaces:
Sleeping
Sleeping
File size: 1,121 Bytes
5ad56ab 5cb756d 5ad56ab | 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 | FROM python:3.9-slim
# Install Node.js for frontend build
RUN apt-get update && apt-get install -y curl && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Hugging Face Spaces require running as a non-root user with ID 1000
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Copy requirements and install Python deps
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy frontend source and build
COPY --chown=user frontend/ ./frontend/
RUN cd frontend && npm install && npm run build
# Copy backend source
COPY --chown=user backend/ ./backend/
COPY --chown=user codeblue_context.py .
# Copy built frontend to backend static directory
RUN rm -rf backend/static && mkdir -p backend/static && cp -r frontend/dist/* backend/static/
# Set environment variables for Hugging Face
ENV PORT=7860
ENV HOST=0.0.0.0
EXPOSE 7860
# Run FastAPI server
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|