Fixed the Docker build stage that runs npm run build

This commit is contained in:
2026-05-19 18:58:14 +03:30
parent c06e237cd1
commit 34a683b614
2 changed files with 23 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ Only publish HTTP and RTMP by default. Keep MediaMTX HLS behind Apache and keep
- When changing MediaMTX ports, update Compose environment, published ports, entrypoint defaults, and the template together. - When changing MediaMTX ports, update Compose environment, published ports, entrypoint defaults, and the template together.
- When changing Laravel runtime behavior, update the shared `x-app-environment` block unless the value belongs to one role only. - When changing Laravel runtime behavior, update the shared `x-app-environment` block unless the value belongs to one role only.
- When changing queue behavior, prefer env-driven options on the `queue` service and `docker/app/entrypoint.sh`. - When changing queue behavior, prefer env-driven options on the `queue` service and `docker/app/entrypoint.sh`.
- Keep `npm run build` after PHP setup and Composer install in `docker/app/Dockerfile`; the Wayfinder Vite plugin invokes `php artisan wayfinder:generate` during the build. - Keep `npm run build` after PHP setup and Composer install in `docker/app/Dockerfile`; the Wayfinder Vite plugin invokes `php artisan wayfinder:generate` during the build. The asset stage must also provide safe build-time Laravel env values and should run `php artisan wayfinder:generate --with-form --no-interaction` before `npm run build` so failures are visible in Docker logs.
- Keep deploy script behavior idempotent: repeat runs should update the Git checkout, rebuild, migrate, and restart services without deleting volumes. - Keep deploy script behavior idempotent: repeat runs should update the Git checkout, rebuild, migrate, and restart services without deleting volumes.
- Keep generated secrets in `.env`; do not bake secrets into images or templates. - Keep generated secrets in `.env`; do not bake secrets into images or templates.

View File

@@ -16,6 +16,7 @@ RUN apt-get update \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libonig-dev \ libonig-dev \
libpq-dev \ libpq-dev \
libsqlite3-dev \
libzip-dev \ libzip-dev \
netcat-openbsd \ netcat-openbsd \
unzip \ unzip \
@@ -27,7 +28,9 @@ RUN apt-get update \
opcache \ opcache \
pcntl \ pcntl \
pdo_pgsql \ pdo_pgsql \
pdo_sqlite \
pgsql \ pgsql \
sqlite3 \
zip \ zip \
&& pecl install redis \ && pecl install redis \
&& docker-php-ext-enable redis \ && docker-php-ext-enable redis \
@@ -45,6 +48,24 @@ RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoload
FROM php-base AS assets FROM php-base AS assets
ENV APP_NAME=Nyone \
APP_ENV=production \
APP_DEBUG=false \
APP_KEY=base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA \
APP_URL=http://localhost \
LOG_CHANNEL=stderr \
DB_CONNECTION=sqlite \
DB_DATABASE=:memory: \
CACHE_STORE=array \
SESSION_DRIVER=array \
QUEUE_CONNECTION=sync \
MAIL_MAILER=log \
BROADCAST_CONNECTION=log \
FILESYSTEM_DISK=local \
VITE_APP_NAME=Nyone \
STREAMING_VIEWER_COUNT_CACHE_STORE=array \
MEDIAMTX_SHARED_SECRET=build-time-secret
COPY --from=node:22-bookworm-slim /usr/local/bin/node /usr/local/bin/node COPY --from=node:22-bookworm-slim /usr/local/bin/node /usr/local/bin/node
COPY --from=node:22-bookworm-slim /usr/local/lib/node_modules /usr/local/lib/node_modules COPY --from=node:22-bookworm-slim /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
@@ -60,6 +81,7 @@ COPY runtime/source/ ./
RUN composer dump-autoload --optimize --no-dev \ RUN composer dump-autoload --optimize --no-dev \
&& php artisan package:discover --ansi \ && php artisan package:discover --ansi \
&& php artisan route:clear \ && php artisan route:clear \
&& php artisan wayfinder:generate --with-form --no-interaction \
&& npm run build && npm run build
FROM php-base AS app FROM php-base AS app