From e91005ac90d978c9b3baea32a8aeed72465a9c96 Mon Sep 17 00:00:00 2001 From: Stephanos A Date: Wed, 3 Jun 2026 07:38:27 +0300 Subject: [PATCH] Passenger web apps deployment issues resolution 1 --- .../backoffice/next.config.js | 4 +++ apps/edr-passenger-web/portal/next.config.js | 4 +++ infrastructure/docker/Dockerfile.web | 31 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/edr-passenger-web/backoffice/next.config.js b/apps/edr-passenger-web/backoffice/next.config.js index dcde34d31..a286d1a26 100644 --- a/apps/edr-passenger-web/backoffice/next.config.js +++ b/apps/edr-passenger-web/backoffice/next.config.js @@ -1,10 +1,14 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'export', reactStrictMode: true, transpilePackages: ['@edr/types', '@edr/ui-common'], env: { NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000', }, + images: { + unoptimized: true, // Required for static export + }, }; module.exports = nextConfig; diff --git a/apps/edr-passenger-web/portal/next.config.js b/apps/edr-passenger-web/portal/next.config.js index 9d962888f..198341969 100644 --- a/apps/edr-passenger-web/portal/next.config.js +++ b/apps/edr-passenger-web/portal/next.config.js @@ -1,7 +1,11 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'export', reactStrictMode: true, transpilePackages: ['@edr/types', '@edr/ui-common'], + images: { + unoptimized: true, // Required for static export + }, }; export default nextConfig; diff --git a/infrastructure/docker/Dockerfile.web b/infrastructure/docker/Dockerfile.web index 38e863b86..7a9aeab5d 100644 --- a/infrastructure/docker/Dockerfile.web +++ b/infrastructure/docker/Dockerfile.web @@ -32,7 +32,36 @@ RUN pnpm turbo build --filter="${TURBO_FILTER}..." FROM nginx:alpine AS runner ARG APP_PATH + +# Copy nginx configuration COPY infrastructure/nginx/spa.conf /etc/nginx/conf.d/default.conf -COPY --from=builder /app/${APP_PATH}/dist /usr/share/nginx/html + +# Remove default nginx files +RUN rm -rf /usr/share/nginx/html/* + +# Copy build output - check for Next.js 'out' or Vite 'dist' directory +# Use shell to handle conditional copy +RUN --mount=type=bind,from=builder,source=/app,target=/build \ + if [ -d "/build/${APP_PATH}/out" ]; then \ + cp -r /build/${APP_PATH}/out/* /usr/share/nginx/html/; \ + echo "Copied from Next.js 'out' directory"; \ + elif [ -d "/build/${APP_PATH}/dist" ]; then \ + cp -r /build/${APP_PATH}/dist/* /usr/share/nginx/html/; \ + echo "Copied from Vite 'dist' directory"; \ + else \ + echo "Error: No build output found in 'out' or 'dist' directory"; \ + exit 1; \ + fi + +# Copy public directory if it exists (for static assets) +RUN --mount=type=bind,from=builder,source=/app,target=/build \ + if [ -d "/build/${APP_PATH}/public" ]; then \ + mkdir -p /usr/share/nginx/html/public && \ + cp -r /build/${APP_PATH}/public/* /usr/share/nginx/html/public/ && \ + echo "Copied public directory"; \ + else \ + echo "No public directory found, skipping"; \ + fi + EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]