-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.web-scraper
More file actions
60 lines (51 loc) · 2.81 KB
/
Dockerfile.web-scraper
File metadata and controls
60 lines (51 loc) · 2.81 KB
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
54
55
56
57
58
59
FROM --platform=$BUILDPLATFORM node:22-slim@sha256:80fdb3f57c815e1b638d221f30a826823467c4a56c8f6a8d7aa091cd9b1675ea AS builder
WORKDIR /app
# Copy workspace root `package.json` and `package-lock.json` files,
# and `package.json` file from the component, to just install dependencies.
COPY ["./*.json", "./"]
COPY ["./components/retrack-web-scraper/package.json", "./components/retrack-web-scraper/"]
RUN set -x && npm ci --ws
# Now copy the rest of the component files, test and build it.
COPY ["./components/retrack-web-scraper", "./components/retrack-web-scraper"]
RUN set -x && npm test --ws
RUN set -x && npm run build --ws
FROM node:22-slim@sha256:80fdb3f57c815e1b638d221f30a826823467c4a56c8f6a8d7aa091cd9b1675ea
ENV NODE_ENV=production \
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
RETRACK_WEB_SCRAPER_BROWSER_CHROMIUM_EXECUTABLE_PATH=/usr/local/bin/chromium
WORKDIR /app
EXPOSE 7272
# Install system dependencies: dumb-init, fonts, and the minimal set of shared
# libraries that Chromium actually links against (instead of `playwright install
# --with-deps` which pulls in ~350 MB of Mesa/LLVM/X11 packages).
RUN set -x && apt-get update && \
apt-get install -y --no-install-recommends \
dumb-init fonts-freefont-ttf fonts-noto-color-emoji fonts-wqy-zenhei fontconfig \
libasound2 libatk-bridge2.0-0 libatk1.0-0 libcairo2 libcups2 libdbus-1-3 \
libdrm2 libgbm1 libglib2.0-0 libnspr4 libnss3 libpango-1.0-0 \
libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxkbcommon0 \
libxrandr2 && \
rm -rf /var/lib/apt/lists/*
COPY ./dev/docker/chromium_local.conf /etc/fonts/local.conf
RUN set -x && fc-cache -fv
COPY --from=builder ["/app/components/retrack-web-scraper/dist/", "./"]
COPY --from=builder ["/app/components/retrack-web-scraper/package.json", "/app/package-lock.json", "./"]
# Install production dependencies, then use Playwright to install only the
# Chromium binary (no --with-deps). Create a stable symlink so the app can
# find the binary regardless of the Playwright revision number.
# Post-install cleanup: remove headless-shell, ffmpeg, all but en-US locale.
RUN set -x && npm ci --production && \
npx playwright install chromium && \
rm -rf /ms-playwright/chromium_headless_shell-* && \
rm -rf /ms-playwright/ffmpeg-* && \
find /ms-playwright -path '*/locales/*' ! -name 'en-US.pak' -delete && \
CHROMIUM_BIN=$(find /ms-playwright -name chrome -type f -path '*/chrome-linux*/chrome' | head -1) && \
echo "Playwright installed Chromium at: $CHROMIUM_BIN" && \
ln -sf "$CHROMIUM_BIN" /usr/local/bin/chromium && \
npm cache clean --force && \
rm -rf /usr/local/lib/node_modules && \
rm -rf /opt/yarn-* && \
rm -f /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/yarn
USER node
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["node", "src/index.js"]