From bddd70cfca9bd821d134e2751d1fca0398782722 Mon Sep 17 00:00:00 2001 From: germondai Date: Wed, 1 Jul 2026 12:36:06 +0200 Subject: [PATCH 1/3] fix(api): return 503 from /health while browser pool is initializing --- apps/api/src/index.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 23863b4..e31fa4b 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -73,19 +73,22 @@ function flareSolverrError(url: string, message: string): FlareSolverrResponse { } new Elysia() - .get("/health", () => ({ - status: pool ? "ok" : "starting", - uptime: Math.floor((Date.now() - startTime) / 1000), - pool: - pool?.getStats() ?? - ({ - total: 0, - busy: 0, - available: 0, - restarts: 0, - avgRestarts: 0, - } satisfies PoolStats), - })) + .get("/health", ({ set }) => { + if (!pool) set.status = 503 + return { + status: pool ? "ok" : "starting", + uptime: Math.floor((Date.now() - startTime) / 1000), + pool: + pool?.getStats() ?? + ({ + total: 0, + busy: 0, + available: 0, + restarts: 0, + avgRestarts: 0, + } satisfies PoolStats), + } + }) .get("/stats", () => { const stats = pool?.getStats() ?? { From 23ff002fd42396c44dab9d83ee45c635f4b75fc6 Mon Sep 17 00:00:00 2001 From: germondai Date: Wed, 1 Jul 2026 12:36:06 +0200 Subject: [PATCH 2/3] fix(dockerfile): add curl to runtime stage, drop duplicate camoufox fetch --- apps/api/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index a364c98..ce67e4f 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -33,9 +33,6 @@ RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ # Secret mount keeps GITHUB_TOKEN out of image layers. # Token prevents GitHub API rate-limits that cause the binary download to stall. -RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \ - bun x camoufox-js fetch \ - && rm -rf /opt/camoufox/fonts/macos /opt/camoufox/fonts/windows # ── Stage 3: lean runtime (only API-required files) ──────────────────────────── FROM ubuntu:22.04 @@ -60,6 +57,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ libasound2 \ fonts-liberation \ ca-certificates \ + curl \ && apt-get clean COPY --from=oven/bun:1.3.14 /usr/local/bin/bun /usr/local/bin/bun From 177f598f837acf5dc1f04219d08ac93d0abf922e Mon Sep 17 00:00:00 2001 From: germondai Date: Wed, 1 Jul 2026 12:36:06 +0200 Subject: [PATCH 3/3] fix(docker): replace wget with curl healthcheck, add timeout and start_period --- docker-compose.full.yml | 6 ++++++ docker-compose.minimal.yml | 6 ++++++ docker-compose.prod.yml | 5 ++++- docker-compose.yml | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docker-compose.full.yml b/docker-compose.full.yml index 9c19a8d..cdcd350 100644 --- a/docker-compose.full.yml +++ b/docker-compose.full.yml @@ -25,6 +25,12 @@ services: dns: - 1.1.1.1 - 8.8.8.8 + healthcheck: + test: ["CMD", "curl", "-sf", "http://localhost:8191/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 90s web: build: diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index bb7fc1a..59a8c4a 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -6,3 +6,9 @@ services: shm_size: 1gb environment: BROWSER_POOL_SIZE: 1 + healthcheck: + test: ["CMD", "curl", "-sf", "http://localhost:8191/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 90s diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index a7ad80e..a779972 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -18,8 +18,11 @@ services: depends_on: - redis healthcheck: - test: wget -qO- http://localhost:8191/health + test: ["CMD", "curl", "-sf", "http://localhost:8191/health"] interval: 30s + timeout: 10s + retries: 3 + start_period: 90s volumes: redis_data: diff --git a/docker-compose.yml b/docker-compose.yml index 3c1aaea..614f18d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,12 @@ services: BROWSER_POOL_SIZE: 3 depends_on: - redis + healthcheck: + test: ["CMD", "curl", "-sf", "http://localhost:8191/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 90s volumes: redis_data: