crawler / Dockerfile
GitHub Actions Bot
🚀 Auto-deploy: 8f573d2e3346c23b6a220024dfe7dffd3fb854ff
4164c72
Raw
History Blame Contribute Delete
1.35 kB
# Use Node.js 20 slim image
FROM node:20-slim
# Set working directory
WORKDIR /app
# 1. Install system dependencies required by Playwright (系统库变动极少,缓存命中率极高)
RUN apt-get update && apt-get install -y \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-1-3 \
libxcb1 \
libxkbcommon0 \
libx11-6 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
libatspi2.0-0 \
wget \
gnupg \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# 2. Copy ONLY package files first (关键步骤:先只复制依赖配置文件)
COPY package.json package-lock.json ./
# 3. Install npm dependencies AND Playwright browsers together
# 如果 package.json 没变,这一步会直接从缓存读取,秒完成!
RUN npm ci && \
npx playwright install chromium && \
npx playwright install-deps
# 4. Copy platform code (最后复制代码,因为代码经常变)
# 注意:确保你的 .dockerignore 文件里包含了 node_modules
COPY . .
# Set environment variables
ENV NODE_ENV=production
ENV HEADLESS=true
ENV PORT=7860
# Expose port huggingface
EXPOSE 7860
# Default command
CMD ["npm", "run", "start:prod"]