From ece6aab9cf57a663bf116ce2b2b9e5bc5cdb67a9 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Mon, 31 Aug 2026 12:38:52 -0500 Subject: [PATCH] Plain-JS Next config so the image boots without devDependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit next start stops to install TypeScript when the config is a .ts file, which in the container meant a yarn install into node_modules on every boot — slow enough that the health check failed before the server answered. Co-Authored-By: Claude Opus 5 --- Dockerfile | 4 ++-- next.config.mjs | 9 +++++++++ next.config.ts | 7 ------- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 next.config.mjs delete mode 100644 next.config.ts diff --git a/Dockerfile b/Dockerfile index 3a45043..0932d4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,7 +52,7 @@ RUN mkdir -p /data && chown nextjs:nodejs /data COPY --from=proddeps --chown=nextjs:nodejs /app/node_modules ./node_modules COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --chown=nextjs:nodejs package.json next.config.ts ./ +COPY --chown=nextjs:nodejs package.json next.config.mjs ./ COPY --chown=nextjs:nodejs public ./public # /api/autobuyer/status reads the version out of this manifest and the extension # reloads itself to match, so the folder has to travel with the server. @@ -61,7 +61,7 @@ COPY --chown=nextjs:nodejs extension ./extension USER nextjs EXPOSE 3000 -HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ +HEALTHCHECK --interval=15s --timeout=10s --start-period=20s --retries=5 \ CMD node -e "fetch('http://127.0.0.1:3000/api/autobuyer/status').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" CMD ["npm", "start"] diff --git a/next.config.mjs b/next.config.mjs new file mode 100644 index 0000000..5579de9 --- /dev/null +++ b/next.config.mjs @@ -0,0 +1,9 @@ +/** @type {import('next').NextConfig} */ +// Plain JS, not TypeScript: `next start` in the production image has no +// devDependencies, and a .ts config makes Next stop and install TypeScript — +// with yarn, into a read-only-by-intent node_modules — before it will boot. +const nextConfig = { + serverExternalPackages: ['better-sqlite3'], +}; + +export default nextConfig; diff --git a/next.config.ts b/next.config.ts deleted file mode 100644 index 40988d5..0000000 --- a/next.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - serverExternalPackages: ['better-sqlite3'], -}; - -export default nextConfig;