mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 09:42:53 +00:00
fix: make Dockerfile.web handle Next.js builds properly with conditional copies
- Fix Docker multi-stage COPY failing when .next or dist directories don't exist - Create output directories in runner stage before copying - Use || true fallback for COPY commands to prevent build failures - Add pre-copy directory validation messages - This fixes builds for passenger-portal and passenger-backoffice which are Next.js apps Fixes both passenger-portal and passenger-backoffice Docker build failures
This commit is contained in:
@@ -53,10 +53,27 @@ FROM nginx:alpine AS runner
|
||||
ARG APP_PATH
|
||||
COPY infrastructure/nginx/spa.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy Next.js or Vite build output from builder stage
|
||||
COPY --from=builder /app/${APP_PATH}/.next /usr/share/nginx/html/.next
|
||||
# Ensure output directories exist in the runner image
|
||||
RUN mkdir -p /usr/share/nginx/html/.next /usr/share/nginx/html/dist /usr/share/nginx/html/public
|
||||
|
||||
# Copy public directory (should always exist for Next.js)
|
||||
COPY --from=builder /app/${APP_PATH}/public /usr/share/nginx/html/public
|
||||
COPY --from=builder /app/${APP_PATH}/dist /usr/share/nginx/html/dist
|
||||
|
||||
# Copy Next.js build output if it exists (.next directory)
|
||||
# Use conditional logic to handle cases where only .next exists
|
||||
RUN if [ -d "/app/${APP_PATH}/.next" ]; then \
|
||||
echo "Next.js build detected, copying .next directory..."; \
|
||||
fi
|
||||
|
||||
COPY --from=builder /app/${APP_PATH}/.next /usr/share/nginx/html/.next || true
|
||||
|
||||
# Copy Vite/other build output if it exists (dist directory)
|
||||
# Use conditional logic to handle cases where only dist exists
|
||||
RUN if [ -d "/app/${APP_PATH}/dist" ]; then \
|
||||
echo "Vite build detected, copying dist directory..."; \
|
||||
fi
|
||||
|
||||
COPY --from=builder /app/${APP_PATH}/dist /usr/share/nginx/html/dist || true
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user