From e1c0434ed10e0f9aeb5f2d5ce6f3ed0e42c1fa93 Mon Sep 17 00:00:00 2001 From: rameen Date: Sun, 23 Aug 2026 16:34:58 +0330 Subject: [PATCH] Fix frontend staging healthcheck for locale redirect Accept 2xx/3xx on / so next-intl redirect to /en no longer marks the container unhealthy and blocks nginx from starting. Co-authored-by: Cursor --- frontend/Dockerfile | 2 +- infrastructure/STAGING-DEPLOY.md | 2 +- infrastructure/docker-compose.registry.yml | 3 ++- infrastructure/docker-compose.staging.yml | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 1a89df2..62f4fb9 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -53,7 +53,7 @@ USER dyolink EXPOSE 3000 HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \ - CMD node -e "require('http').get('http://127.0.0.1:3000/', (r) => {if(r.statusCode!==200)process.exit(1)})" + CMD node -e "require('http').get('http://127.0.0.1:3000/', (r) => { process.exit(r.statusCode >= 200 && r.statusCode < 400 ? 0 : 1); }).on('error', () => process.exit(1))" ENTRYPOINT ["dumb-init", "--", "docker-entrypoint.sh"] diff --git a/infrastructure/STAGING-DEPLOY.md b/infrastructure/STAGING-DEPLOY.md index 4e879c8..ef42a9b 100644 --- a/infrastructure/STAGING-DEPLOY.md +++ b/infrastructure/STAGING-DEPLOY.md @@ -250,7 +250,7 @@ On the Windows host, from repo `infrastructure/`: | Backend restart loop | JWT secrets still placeholder; fix `backend.staging.env` | | Backend DB auth error | `DATABASE_URL` password ≠ `POSTGRES_PASSWORD` | | `dumb-init docker-entrypoint.sh: No such file or directory` | Windows CRLF in shell scripts — fixed in Dockerfiles (rebuild images). | -| `nginx: host not found in upstream "backend:3000"` | Backend/frontend not running yet — fix entrypoint/env first; nginx config uses Docker DNS resolver. | +| `frontend is unhealthy` / deploy waits on frontend | Next.js `/` redirects to `/en` (3xx). Rebuild after healthcheck fix (accepts 2xx/3xx). | **Logs:** diff --git a/infrastructure/docker-compose.registry.yml b/infrastructure/docker-compose.registry.yml index 0d9306f..d212259 100644 --- a/infrastructure/docker-compose.registry.yml +++ b/infrastructure/docker-compose.registry.yml @@ -75,7 +75,8 @@ services: - dyolink_staging restart: unless-stopped healthcheck: - test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/', (r) => {if(r.statusCode!==200)process.exit(1)})"] + # Root redirects to /en (next-intl) — accept 2xx/3xx as healthy. + test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/', (r) => { process.exit(r.statusCode >= 200 && r.statusCode < 400 ? 0 : 1); }).on('error', () => process.exit(1))"] interval: 30s timeout: 10s retries: 3 diff --git a/infrastructure/docker-compose.staging.yml b/infrastructure/docker-compose.staging.yml index 043bd2e..cec0402 100644 --- a/infrastructure/docker-compose.staging.yml +++ b/infrastructure/docker-compose.staging.yml @@ -77,7 +77,8 @@ services: - dyolink_staging restart: unless-stopped healthcheck: - test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/', (r) => {if(r.statusCode!==200)process.exit(1)})"] + # Root redirects to /en (next-intl) — accept 2xx/3xx as healthy. + test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/', (r) => { process.exit(r.statusCode >= 200 && r.statusCode < 400 ? 0 : 1); }).on('error', () => process.exit(1))"] interval: 30s timeout: 10s retries: 3