# Hugging Face Spaces Dockerfile - 修复版本 FROM node:18-slim # Install dependencies for Puppeteer with updated Chrome repository RUN apt-get update \ && apt-get install -y wget gnupg ca-certificates \ && wget -q -O - https://dl.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-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \ libdrm2 libgtk-3-0 libnspr4 libnss3 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 \ libgbm1 libxss1 libgconf-2-4 --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \ && mkdir -p /home/pptruser/Downloads \ && chown -R pptruser:pptruser /home/pptruser # Set working directory WORKDIR /app # Copy package files first for better caching COPY package*.json ./ # Install dependencies RUN npm ci --only=production && npm cache clean --force # Copy application code COPY . . # Change ownership to pptruser RUN chown -R pptruser:pptruser /app # Switch to non-root user USER pptruser # Set Puppeteer environment variables ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable # Expose port for Hugging Face Spaces EXPOSE 7860 # Set environment for HF Spaces ENV PORT=7860 ENV NODE_ENV=production # Start the application CMD ["npm", "start"]