|
1 | 1 | FROM node:22-slim |
2 | 2 |
|
| 3 | +ARG TARGETARCH |
| 4 | + |
3 | 5 | # System deps for Chrome for Testing + build tools for native modules (better-sqlite3) |
4 | | -# Must run as root |
| 6 | +# On ARM64 we also install system Chromium (Chrome for Testing has no ARM64 binary) |
5 | 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
6 | 8 | curl ca-certificates fonts-liberation libasound2 \ |
7 | 9 | libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 \ |
8 | 10 | libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 \ |
9 | 11 | libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 xdg-utils \ |
10 | 12 | python3 make g++ \ |
| 13 | + && if [ "$TARGETARCH" = "arm64" ]; then apt-get install -y --no-install-recommends chromium; fi \ |
11 | 14 | && rm -rf /var/lib/apt/lists/* \ |
12 | | - && mkdir -p /db /conf /fredy \ |
13 | | - && chown node:node /db /conf /fredy |
| 15 | + && mkdir -p /db /conf /fredy |
14 | 16 |
|
15 | 17 | WORKDIR /fredy |
16 | 18 |
|
17 | | -# Everything from here runs as the built-in non-root node user (UID 1000) |
18 | | -USER node |
19 | | - |
20 | 19 | ENV NODE_ENV=production \ |
21 | 20 | IS_DOCKER=true |
22 | 21 |
|
23 | | -COPY --chown=node:node package.json yarn.lock ./ |
| 22 | +COPY package.json yarn.lock ./ |
24 | 23 |
|
25 | 24 | # Install dependencies and purge build tools (only needed to compile better-sqlite3) |
26 | 25 | RUN yarn config set network-timeout 600000 \ |
27 | 26 | && yarn --frozen-lockfile \ |
28 | 27 | && yarn cache clean |
29 | 28 |
|
30 | | -# Install Chrome for Testing in a separate layer — it's ~150MB and rarely changes, |
31 | | -# so keeping it separate avoids re-downloading on every code/dependency change |
32 | | -RUN npx puppeteer browsers install chrome |
| 29 | +# on arm64 use the system Chromium installed above |
| 30 | +RUN if [ "$TARGETARCH" != "arm64" ]; then npx puppeteer browsers install chrome; fi |
33 | 31 |
|
34 | 32 | # Purge build tools now that native modules are compiled |
35 | | -USER root |
36 | 33 | RUN apt-get purge -y python3 make g++ \ |
37 | 34 | && apt-get autoremove -y \ |
38 | 35 | && rm -rf /var/lib/apt/lists/* |
39 | | -USER node |
40 | 36 |
|
41 | | -COPY --chown=node:node index.html vite.config.js ./ |
42 | | -COPY --chown=node:node ui ./ui |
43 | | -COPY --chown=node:node lib ./lib |
| 37 | +COPY index.html vite.config.js ./ |
| 38 | +COPY ui ./ui |
| 39 | +COPY lib ./lib |
44 | 40 |
|
45 | 41 | RUN yarn build:frontend |
46 | 42 |
|
47 | | -COPY --chown=node:node index.js ./ |
| 43 | +COPY index.js ./ |
48 | 44 |
|
49 | 45 | RUN ln -s /db /fredy/db \ |
50 | 46 | && ln -s /conf /fredy/conf |
|
0 commit comments