Spaces:
Sleeping
Sleeping
File size: 1,307 Bytes
c806578 |
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 46 47 48 |
# Build UI
FROM node:20 AS ui-builder
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
COPY . .
RUN npm run build
# Build AI
FROM python:3.10-slim AS ai-builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py dataset.json ./
# Final image
FROM nginx:latest
# Install Python for backend and build tools for pip packages
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv build-essential pkg-config && \
rm -rf /var/lib/apt/lists/*
# Copy UI build
COPY --from=ui-builder /app/dist /usr/share/nginx/html
# Copy AI app and requirements to /app BEFORE pip install
COPY --from=ai-builder /app/app.py /app/dataset.json /app/
COPY requirements.txt /app/
# Custom Nginx config for reverse proxy
COPY nginx.conf /etc/nginx/nginx.conf
# Create and activate a virtual environment, then install requirements
RUN python3 -m venv /venv
ENV PATH="/venv/bin:$PATH"
RUN pip install --no-cache-dir cython
RUN pip install --no-cache-dir -r /app/requirements.txt
# Expose port
EXPOSE 7860
# Fix Nginx cache directory permissions
RUN mkdir -p /var/cache/nginx && chmod 777 /var/cache/nginx
# Start both Nginx and Flask
CMD python /app/app.py & nginx -g 'daemon off;'
|