# Root-level Dockerfile # Stage 1: Build React frontend FROM node:18-alpine AS frontend-build WORKDIR /app/frontend COPY frontend/package.json frontend/package-lock.json ./ RUN npm install COPY frontend/ ./ RUN npm run build # Stage 2: Build Python backend + serve frontend with Nginx FROM python:3.9-slim # Set working directory WORKDIR /app # Install Python dependencies COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy backend code COPY backend/ /app/backend COPY model/ /app/model/ ENV TRANSFORMERS_CACHE=/app/model ENV HF_HUB_OFFLINE=1 ENV TRANSFORMERS_OFFLINE=1 COPY --from=frontend-build /app/frontend/build /app/frontend_build # Install nginx RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/* # Copy global nginx config to override default one COPY frontend/nginx.global.conf /etc/nginx/nginx.conf # Copy nginx server block COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf # Link built frontend to nginx root RUN rm -rf /usr/share/nginx/html && \ ln -s /app/frontend_build /usr/share/nginx/html # Create required writable directories RUN mkdir -p /app/tmp/body /app/tmp/proxy /app/tmp/fastcgi /app/tmp/uwsgi /app/tmp/scgi /app/logs && \ chmod -R 777 /app/tmp /app/logs # Create log directory for NGINX RUN mkdir -p /app/logs && chmod -R 777 /app/logs # Copy start script COPY start.sh /start.sh RUN chmod +x /start.sh # Expose port 7860 for Hugging Face EXPOSE 7860 # Start both backend and nginx CMD ["/start.sh"]