File size: 1,054 Bytes
b6e5012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# --- Stage 1: Build the Frontend ---
FROM node:20-slim AS build-stage
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build

# --- Stage 2: Production Environment ---
# Use the official Playwright image which includes all system dependencies
FROM mcr.microsoft.com/playwright/python:v1.42.0-jammy

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PORT 7860

WORKDIR /app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Pre-install Chromium in the image to prevent timeouts at runtime
RUN playwright install chromium

# Copy the built frontend from Stage 1
COPY --from=build-stage /app/frontend/dist ./frontend/dist

# Copy the backend code and tools
COPY app.py .
COPY tools/ ./tools/

# Create a temporary directory for results
RUN mkdir -p .tmp && chmod 777 .tmp

# Expose the port (Hugging Face Spaces uses 7860)
EXPOSE 7860

# Run the backend (which also serves the frontend)
CMD ["python", "app.py"]