Fix build by preventing MongoDB connections during build

This commit is contained in:
yznahmad 2025-06-20 03:10:49 +03:00
parent afe5528a1b
commit 0256b96365
2 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,8 @@ COPY webapp/ .
# Set environment variables for build # Set environment variables for build
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
# Use a dummy DB_URI during build to prevent connection attempts
ENV DB_URI=mongodb://dummy:password@localhost:27017/dummy
# Build the application # Build the application
RUN npm run build RUN npm run build

View File

@ -11,6 +11,14 @@ const nextConfig = {
// to prevent database connection attempts // to prevent database connection attempts
serverComponentsExternalPackages: ['mongoose'], serverComponentsExternalPackages: ['mongoose'],
}, },
// Disable server-side rendering during build for specific pages that require DB access
// This prevents connection attempts during build
exportPathMap: async function() {
return {
'/': { page: '/dashboard' },
// Add other static pages here
};
},
async redirects() { async redirects() {
return [ return [
{ // we redirect '/' to '/dashboard { // we redirect '/' to '/dashboard