CoolFace
Apppublic

itsprasun/pythonic-rag-fastapi-react

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
Dockerfile60 linesDownload Raw Back to root
1# Stage 1: Build the React frontend2FROM node:18 AS frontend-builder3WORKDIR /app/frontend4COPY frontend/package*.json ./5RUN npm install6COPY frontend/ ./7# Explicitly set NODE_ENV to production to use .env.production8ENV NODE_ENV=production9RUN npm run build10 11# Stage 2: Set up the Python backend and Nginx12FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim13 14# Install nginx15RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*16 17# Create app directory and set permissions18RUN mkdir /app && \19    useradd -m -u 1000 user && \20    chown -R user:user /app21 22# Set the working directory23WORKDIR /app24 25# Copy the backend app and set permissions26COPY --chown=user . /app27 28# Copy the built frontend from the previous stage29COPY --from=frontend-builder --chown=user /app/frontend/build /app/static30 31# Configure nginx32COPY nginx.conf /etc/nginx/nginx.conf33RUN mkdir -p /var/log/nginx && \34    chown -R user:user /var/log/nginx && \35    chown -R user:user /var/lib/nginx && \36    touch /var/run/nginx.pid && \37    chown -R user:user /var/run/nginx.pid38 39# Switch to user40USER user41 42# Set the environment variables43ENV HOME=/home/user \44    PATH=/home/user/.local/bin:$PATH \45    UVICORN_WS_PROTOCOL=websockets46 47# Install the Python dependencies48RUN uv sync49 50# Create start script51RUN echo '#!/bin/bash\n\52nginx -g "daemon off;" &\n\53source /app/.venv/bin/activate && exec uvicorn api:app --host 0.0.0.0 --port 8000\n\54' > /app/start.sh && chmod +x /app/start.sh55 56# Expose the Hugging Face port57EXPOSE 786058 59# Run the start script60CMD ["./start.sh"]