Skip to content

Commit 01bbbbe

Browse files
authored
Merge pull request #16 from neuraparse/fix/docker-startup-noise
Fix/docker startup noise
2 parents 3694fa2 + df8bad5 commit 01bbbbe

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
104104
# Copy static files
105105
COPY --from=builder --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
106106

107+
# Force `experimental.trustHostHeader: true` in the standalone server.
108+
# Next.js hard-codes this to `false` at build time unless running on Vercel
109+
# (`build/index.js`: `trustHostHeader: _ciinfo.hasNextSupport`). Behind our
110+
# nginx reverse proxy the host header is the public domain, which differs
111+
# from the standalone server's bound address — so when next-intl emits an
112+
# absolute `x-middleware-rewrite` value, Next's `relativizeURL` sees a host
113+
# mismatch and falls through to `proxyRequest`. That proxy then tries to
114+
# loop back through DNS and fails with `ECONNREFUSED 127.0.0.2:443` on
115+
# every locale-rewritten route (`/dashboard` → `/en/dashboard`, causing a
116+
# 500 right after login). Patching the embedded config blob flips the flag
117+
# so the standalone server builds its `initUrl` from the same host header
118+
# next-intl uses, the rewrite stays internal, and the proxy path is never
119+
# entered. Idempotent: sed is a no-op if the substring is absent.
120+
RUN sed -i 's/"trustHostHeader":false/"trustHostHeader":true/g' ./apps/web/server.js
121+
107122
# Copy database package with migrations and seed
108123
COPY --from=builder /app/packages/db/src ./packages/db/src
109124
COPY --from=builder /app/packages/db/scripts ./packages/db/scripts

apps/web/next.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ const nextConfig: NextConfig = {
6161
};
6262

6363
export default withNextIntl(nextConfig);
64-

packages/db/drizzle/0051_pgvector_hnsw_content_embeddings.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
-- The DROP IF EXISTS line removes any prior IVFFlat index (the legacy naming
1212
-- drizzle-kit would have used for the same column) so this migration is safe
1313
-- whether or not a previous ANN index exists.
14-
BEGIN;
15-
14+
--
15+
-- No explicit BEGIN/COMMIT here: drizzle-kit's migrator already wraps each
16+
-- migration in a transaction. Nesting one manually produced the
17+
-- "there is already a transaction in progress" / "there is no transaction
18+
-- in progress" warnings logged by Postgres on every startup.
1619
DROP INDEX IF EXISTS "content_embeddings_embedding_ivfflat_idx";
1720
DROP INDEX IF EXISTS "content_embeddings_embedding_idx";
1821

1922
CREATE INDEX IF NOT EXISTS "content_embeddings_embedding_hnsw_idx"
2023
ON "content_embeddings"
2124
USING hnsw ("embedding" vector_cosine_ops)
2225
WITH (m = 16, ef_construction = 64);
23-
24-
COMMIT;

0 commit comments

Comments
 (0)