File size: 1,304 Bytes
28c9bc5
21cac8a
00d9823
 
21cac8a
00d9823
 
 
 
21cac8a
 
 
00d9823
21cac8a
 
 
 
 
 
 
 
 
 
 
 
 
 
10a9639
21cac8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
FROM node:20

# Install system dependencies for Puppeteer
RUN apt-get update && apt-get install -y \
    chromium \
    fonts-freefont-ttf \
    libxss1 \
    --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*

# Set Puppeteer to use installed Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

# Set environment variables
ENV PORT=7860
ENV NODE_ENV=production

# Create app directory
WORKDIR /app

# Copy root package files and install dependencies
COPY package*.json ./
RUN npm ci --only=production

# Build the frontend
COPY frontend ./frontend
RUN cd frontend && npm install --include=dev && npm run build

# Copy backend package files and install backend dependencies
COPY backend/package*.json ./backend/
RUN cd backend && npm ci --only=production

# Copy backend source code
COPY backend ./backend

# Create data directories
RUN mkdir -p data/screenshots logs

# Set proper permissions
RUN chown -R node:node /app
USER node

# Expose port (mandatory for HF Spaces)
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node -e "require('http').get('http://localhost:7860/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"

# Start the application
CMD ["npm", "start"]