-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (67 loc) · 2.08 KB
/
Copy pathDockerfile
File metadata and controls
82 lines (67 loc) · 2.08 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# ─── Stage 1: Build ──────────────────────────────────────────────────────────
FROM node:22-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts
COPY tsconfig.json tsconfig.build.json ./
COPY src/ ./src/
COPY api/ ./api/
RUN npm run build
# ─── Stage 2: Runtime ────────────────────────────────────────────────────────
FROM node:22-slim AS runner
# Playwright system dependencies (Chromium) — must run as root
RUN apt-get update && apt-get install -y --no-install-recommends \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
wget \
ca-certificates \
fonts-liberation \
xdg-utils \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts
# Install Playwright browser as root so it lands in /root/.cache (accessible system-wide)
# then copy to a path the node user can reach
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN npx playwright install chromium --with-deps
# Create output dirs, set permissions on everything including browser cache
RUN mkdir -p output .scraper-state \
&& chown -R node:node /app \
&& chown -R node:node /ms-playwright
# Copy compiled output from builder
COPY --from=builder /app/dist ./dist
# Run as non-root
USER node
EXPOSE 3000
CMD ["node", "dist/api/server.js"]