Spaces:
Running
Running
File size: 1,206 Bytes
12112bf 7376da3 12112bf 7376da3 12112bf 227c43a | 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 49 50 51 | # Multi-stage build for better optimization
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
# Clear npm cache and install dependencies
RUN npm cache clean --force && \
(npm ci --no-audit --no-fund || npm install --no-audit --no-fund)
# Copy frontend source code
COPY frontend/ ./
# Build the frontend
RUN npm run build
# Python backend stage
FROM python:3.11-slim AS backend
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Copy built frontend from previous stage
COPY --from=frontend-builder /app/frontend/build ./frontend/build
# Set environment variables for containerized environments
ENV PORT=7860
ENV HOST=0.0.0.0
ENV FLASK_ENV=production
ENV PYTHONPATH=/app
# Hugging Face Spaces typically expects the app to be on port 7860 or the PORT env var
EXPOSE 7860
# Use our startup script which ensures directories are properly configured
CMD ["python", "startup_hf.py"] |