Spaces:
Running
Running
# Use Python 3.12 as base image | |
FROM python:3.12 | |
# Install system packages (Node.js) as root before switching users | |
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/* | |
# Create user and switch to it | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Set working directory | |
WORKDIR /app | |
# Copy project files | |
COPY --chown=user . . | |
# Install Python dependencies | |
WORKDIR /app/backend | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Install Node.js dependencies and build frontend | |
WORKDIR /app/frontend | |
RUN npm install && npm run build | |
# Copy built frontend files to backend static directory | |
RUN mkdir -p /app/backend/static && cp -r dist/* /app/backend/static/ | |
# Set working directory to backend for running the app | |
WORKDIR /app/backend | |
# Expose port | |
EXPOSE 7860 | |
# Start the application directly | |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |