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 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() ?? { 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: