File size: 1,235 Bytes
6f693aa 4aa09b2 6f693aa 531c962 6f693aa 531c962 6f693aa 4aa09b2 3e0360c 6f693aa 4aa09b2 6f693aa 531c962 3e0360c 6f693aa |
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 40 41 42 43 44 45 |
# --- Stage 1: Build Frontend ---
FROM node:20-alpine as build-stage
WORKDIR /app/frontend
COPY Frontend/package*.json ./
RUN npm install
COPY Frontend/ .
RUN npm run build
# --- Stage 2: Runtime ---
FROM python:3.12-slim
# Install system dependencies
# Note: We keep libpq-dev for Python database libraries
RUN apt-get update && apt-get install -y \
nginx \
build-essential portaudio19-dev libpq-dev git \
&& rm -rf /var/lib/apt/lists/*
# Setup non-root user for HF Spaces (UID 1000)
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
# Copy Backend and install requirements
COPY --chown=user Backend/requirements.txt ./Backend/
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \
pip install --no-cache-dir -r Backend/requirements.txt
COPY --chown=user Backend/ ./Backend/
COPY --chown=user --from=build-stage /app/frontend/dist /usr/share/nginx/html
# Copy Configs
COPY --chown=user nginx.conf /etc/nginx/sites-available/default
COPY --chown=user start.sh ./start.sh
RUN chmod +x ./start.sh
# Environment variables
ENV PORT=7860
EXPOSE 7860
# Set the non-root user
USER user
# Run the startup script
CMD ["./start.sh"] |