Skip to content

Commit a1289ac

Browse files
committed
fixing some docker issues
1 parent 8501fc7 commit a1289ac

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

Dockerfile

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,46 @@
11
FROM node:22-slim
22

3+
ARG TARGETARCH
4+
35
# 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)
57
RUN apt-get update && apt-get install -y --no-install-recommends \
68
curl ca-certificates fonts-liberation libasound2 \
79
libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 \
810
libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 \
911
libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 xdg-utils \
1012
python3 make g++ \
13+
&& if [ "$TARGETARCH" = "arm64" ]; then apt-get install -y --no-install-recommends chromium; fi \
1114
&& 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
1416

1517
WORKDIR /fredy
1618

17-
# Everything from here runs as the built-in non-root node user (UID 1000)
18-
USER node
19-
2019
ENV NODE_ENV=production \
2120
IS_DOCKER=true
2221

23-
COPY --chown=node:node package.json yarn.lock ./
22+
COPY package.json yarn.lock ./
2423

2524
# Install dependencies and purge build tools (only needed to compile better-sqlite3)
2625
RUN yarn config set network-timeout 600000 \
2726
&& yarn --frozen-lockfile \
2827
&& yarn cache clean
2928

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
3331

3432
# Purge build tools now that native modules are compiled
35-
USER root
3633
RUN apt-get purge -y python3 make g++ \
3734
&& apt-get autoremove -y \
3835
&& rm -rf /var/lib/apt/lists/*
39-
USER node
4036

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
4440

4541
RUN yarn build:frontend
4642

47-
COPY --chown=node:node index.js ./
43+
COPY index.js ./
4844

4945
RUN ln -s /db /fredy/db \
5046
&& ln -s /conf /fredy/conf

docker-test.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,28 @@ for i in $(seq 1 30); do
4242
sleep 2
4343
done
4444

45-
# Verify the process is NOT running as root
46-
RUNNING_USER=$(docker exec fredy id -u)
47-
if [ "$RUNNING_USER" = "0" ]; then
48-
echo "Process is running as root!"
45+
# Verify the DB is readable/writable via the API.
46+
# /api/demo is unauthenticated and reads the settings table — if SQLite is broken this returns an error.
47+
echo "Testing DB via API (/api/demo)..."
48+
DEMO_RESPONSE=$(docker exec fredy curl -sf http://localhost:9998/api/demo 2>&1)
49+
if echo "$DEMO_RESPONSE" | grep -q "demoMode"; then
50+
echo "DB is readable (got demoMode from /api/demo)"
51+
else
52+
echo "DB check failed — unexpected response from /api/demo: $DEMO_RESPONSE"
53+
docker logs fredy
4954
exit 1
5055
fi
51-
echo "Process runs as UID $RUNNING_USER (not root)"
5256

53-
# Verify Chrome launches without crashing
57+
# Verify Chrome launches without crashing.
58+
# On amd64: Chrome for Testing lives in the puppeteer cache.
59+
# On arm64: system Chromium is used instead.
5460
echo "Testing Chrome..."
55-
CHROME=$(docker exec fredy find /home/node/.cache/puppeteer -name chrome -type f 2>/dev/null | head -1)
61+
CHROME=$(docker exec fredy find /root/.cache/puppeteer /home -name chrome -type f 2>/dev/null | head -1)
62+
if [ -z "$CHROME" ]; then
63+
CHROME=$(docker exec fredy which chromium 2>/dev/null || true)
64+
fi
5665
if [ -z "$CHROME" ]; then
57-
echo "Chrome binary not found"
66+
echo "Chrome/Chromium binary not found"
5867
exit 1
5968
fi
6069
if docker exec fredy "$CHROME" --headless --no-sandbox --disable-gpu --dump-dom https://example.com 2>&1 | grep -q "<html"; then

lib/services/extractor/puppeteerExtractor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,17 @@ export async function launchBrowser(url, options) {
4747
removeUserDataDir = true;
4848
}
4949

50+
// On ARM64 Docker, Chrome for Testing has no native binary — use system Chromium instead.
51+
const executablePath =
52+
options?.executablePath ||
53+
(process.arch === 'arm64' && process.env.IS_DOCKER === 'true' ? '/usr/bin/chromium' : undefined);
54+
5055
const browser = await puppeteer.launch({
5156
headless: options?.puppeteerHeadless ?? true,
5257
args: launchArgs,
5358
timeout: options?.puppeteerTimeout || 45_000,
5459
userDataDir,
55-
executablePath: options?.executablePath,
60+
executablePath,
5661
});
5762

5863
browser.__fredy_userDataDir = userDataDir;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fredy",
3-
"version": "20.0.7",
3+
"version": "20.0.8",
44
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
55
"scripts": {
66
"prepare": "husky",

0 commit comments

Comments
 (0)