Deploying Next.js outside of Vercel requires a specific configuration to ensure optimal performance and minimal image sizes. Here is how we configured the Luxima portfolio for Coolify.
The Standalone Output
Next.js automatically traces dependencies, but to package it into a minimal Docker container, we must enable the standalone output in next.config.ts:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone", // Crucial for Coolify/Docker deployments
images: {
remotePatterns: [
{ protocol: "https", hostname: "**" }
],
}
};
export default nextConfig;Coolify Nixpacks Configuration
Coolify uses Nixpacks (created by Railway) to automatically generate the Dockerfile. Because we use pnpm, we had to ensure the build command was correctly mapped. In the Coolify dashboard, we set:
- Build Command:
pnpm build - Install Command:
pnpm install
Nixpacks detects the standalone folder and automatically routes traffic to the internal Node.js server.
Handling i18n without Edge Middleware
Since Vercel's Edge network isn't available, using heavy middleware.ts for i18n routing can degrade performance on a single VPS. We solved this by bypassing middleware entirely and creating a <LocalizedLink> wrapper that injects the current [lang] segment statically on the client, preserving 100% SSG capabilities.
