# Use Node 18 Slim (Smaller image, based on Debian) FROM node:20-slim # We need to install dependencies for Puppeteer (Chrome) to run # This list covers the libraries missing in the slim node image RUN apt-get update \ && apt-get install -y wget gnupg \ && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg \ && sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] 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-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Copy package files first (better caching) COPY package*.json ./ # Install dependencies # Note: Puppeteer downloads a local version of Chromium by default. # Since we installed google-chrome-stable above for deps, we can let Puppeteer manage its own binary # or point it to the installed one. For simplicity in Spaces, letting Puppeteer download its own is usually safer # provided the OS deps (above) are present. RUN npm install # Copy source code COPY . . # Environment variables ENV NODE_ENV=production ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=false ENV PORT=7860 # HuggingFace Spaces usually expects port 7860 # Expose port EXPOSE 7860 # Start command CMD ["npm", "start"]