From 04280c578cca1aac8b344e91a3a2123ee8b67816 Mon Sep 17 00:00:00 2001 From: Sulthan Zaki Date: Sat, 18 Jul 2026 13:31:03 +0700 Subject: [PATCH] fix: build Vite assets in app container, harden docker deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit App (PHP-FPM) container never got public/build/manifest.json, only the nginx container built it — blade's @vite runs server-side in PHP and threw "Vite manifest not found", causing 500 on every page. Also: - strip docker/ (incl. DB dump) from the shipped app image - pin npm installs to package-lock.json via npm ci in both build stages - fix .dockerignore case typo (Docker/Dockerfile -> docker/Dockerfile) - pass AWS_* env vars to app service, required since FILESYSTEM_DISK=s3 Co-Authored-By: Claude Sonnet 5 --- .dockerignore | 2 +- docker-compose.yml | 4 ++++ docker/Dockerfile | 10 ++++++++++ docker/nginx.Dockerfile | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index e599283..44255c7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,4 +5,4 @@ vendor storage/*.key .env .phpunit.result.cache -Docker/Dockerfile +docker/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 07ef504..54aea1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,10 @@ services: DB_PASSWORD: ${DB_PASSWORD} FILESYSTEM_DISK: s3 + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} + AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION:-us-east-1} + AWS_BUCKET: ${AWS_BUCKET} depends_on: - db diff --git a/docker/Dockerfile b/docker/Dockerfile index 2a70b87..66ef715 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,3 +1,10 @@ +FROM node:20-alpine AS node-builder +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --ignore-scripts +COPY . . +RUN npm run build:icons && npm run build + FROM composer:2.8 AS php-builder WORKDIR /app COPY composer*.json ./ @@ -28,6 +35,9 @@ RUN apk add --no-cache \ COPY docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini COPY --from=php-builder /app /var/www/html +COPY --from=node-builder /app/public/build /var/www/html/public/build + +RUN rm -rf /var/www/html/docker RUN ln -sf ../../storage/app/public /var/www/html/public/storage diff --git a/docker/nginx.Dockerfile b/docker/nginx.Dockerfile index a573ab9..97842a5 100644 --- a/docker/nginx.Dockerfile +++ b/docker/nginx.Dockerfile @@ -1,7 +1,7 @@ FROM node:20-alpine AS node-builder WORKDIR /app -COPY package.json ./ -RUN npm install --ignore-scripts +COPY package.json package-lock.json ./ +RUN npm ci --ignore-scripts COPY . . RUN npm run build:icons && npm run build