Laravel SSR on nixpacks via Dokploy
I started using Laravel only a few weeks ago and I am loving it so far, and even building two serious production apps using the framework. I deploy the apps on VPS (typically from Hetzner) by using Dokploy via nixpacks, and despite having RUN npm ci && npm run build:ssr in the Dockerfile, the SSR bundle still wasn't being created during the build process.
Upon investigating, I discovered that nixpacks ignores the Dockerfile completely and uses its own build process, so I created a nixpacks.toml and added the below lines:
[phases.build]
cmds = ["npm run build:ssr"]
[start]
cmd = "node /assets/scripts/prestart.mjs /assets/nginx.template.conf /nginx.conf && (php artisan inertia:start-ssr &) && (php-fpm -y /assets/php-fpm.conf &) && nginx -c /nginx.conf"
Basically, the above file configures build (npm run build:ssr) and also the start command (SSR + PHP-FPM + Nginx). And then it was perfectly working.
Starting SSR server on port 13714...
Inertia SSR server started.
You can verify SSR by looking at the runtime logs, if above lines are present then SSR is working as expected. And I am noting this simple thing down here because I'm sure that I'll be needing this soon. Again.
Some links on this page are affiliate links. If you buy through them, I may earn a small commission at no extra cost to you. However, this does not affect my opinions.
Comment via email