Stu Mason
Stu Mason

Activity

Issue Opened

Issue #36 opened: Generated Dockerfile fails npm build when using Laravel Wayfinder

Problem

When deploying an application that uses @laravel/vite-plugin-wayfinder, the generated Dockerfile fails at the npm run build step.

Error

2026-Jan-16 12:05:24.257158
#21 ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
2026-Jan-16 12:05:24.257158
2026-Jan-16 12:05:24.257158
#17 [production  3/25] RUN docker-php-ext-configure gd --with-freetype --with-jpeg     && docker-php-ext-install -j$(nproc)         pdo zip gd mbstring xml bcmath intl opcache pcntl pdo_pgsql pgsql     && pecl install redis     && docker-php-ext-enable redis
2026-Jan-16 12:05:24.257158
#17 5.015 checking for dlfcn.h... yes
2026-Jan-16 12:05:24.257158
#17 5.064 checking the maximum length of command line arguments... 1572864
...
--------------------
2026-Jan-16 12:05:24.257158
130 |     # Add to vite.config: const isCI = process.env.DOCKER_BUILD === 'true'; !isCI && wayfinder()
2026-Jan-16 12:05:24.257158
131 |     ENV DOCKER_BUILD=true
2026-Jan-16 12:05:24.257158
132 | >>> RUN npm run build
2026-Jan-16 12:05:24.257158
133 |
2026-Jan-16 12:05:24.257158
134 |     # ============================================
2026-Jan-16 12:05:24.257158
--------------------
2026-Jan-16 12:05:24.257158
ERROR: failed to build: failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
2026-Jan-16 12:05:24.257158
exit status 1
2026-Jan-16 12:05:24.522773
========================================
2026-Jan-16 12:05:24.544599
Deployment failed. Removing the new version of your application.
2026-Jan-16 12:05:25.709242
Gracefully shutting down build container: yk8048gs8g4k84ss4scgk04k
...

Cause

The Wayfinder Vite plugin attempts to communicate with Laravel to generate route types during the build. During a Docker build, there's no running Laravel application, so Wayfinder fails.

Current State

The generated Dockerfile includes:

  • A comment suggesting how to modify vite.config to conditionally disable Wayfinder
  • An ENV DOCKER_BUILD=true environment variable

However, this requires manual intervention from the user to modify their vite.config.

Impact

Applications using Laravel Wayfinder cannot deploy without manually modifying their vite configuration first.