File size: 1,316 Bytes
a0333cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2963d39
 
a0333cd
 
 
 
 
 
 
 
 
07c8737
 
 
a0333cd
 
 
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
# Stage 1: Build the Client
FROM node:20 AS client-builder
WORKDIR /client
COPY client/package*.json ./
RUN npm install
COPY client/ .
RUN npm run build

# Stage 2: Final Production Environment
FROM node:20
WORKDIR /app

# Install Google Chrome for Puppeteer inside Docker
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y \
    google-chrome-stable \
    fonts-freefont-ttf \
    --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*

# Copy Server files
COPY server/package*.json ./
RUN npm install
COPY server/ .

# Copy Client build (the server expects it at ../client/out relative to server/src/index.js)
COPY --from=client-builder /client/out /client/out

# Environment
ENV PORT=7860
ENV NODE_ENV=production
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable

EXPOSE 7860

# Hugging Face Spaces runs as UID 1000. The 'node' image already has a 'node' user with this ID.
RUN chown -R node:node /app /client
USER node

# Run the server
CMD ["node", "src/index.js"]