mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
@@ -1,11 +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',
|
||||
},
|
||||
distDir: 'dist',
|
||||
images: {
|
||||
unoptimized: true, // Required for static export
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -51,29 +51,36 @@ RUN if [ ! -d "/app/${APP_PATH}/.next" ] && [ ! -d "/app/${APP_PATH}/dist" ]; th
|
||||
|
||||
FROM nginx:alpine AS runner
|
||||
ARG APP_PATH
|
||||
|
||||
# Copy nginx configuration
|
||||
COPY infrastructure/nginx/spa.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# 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
|
||||
# Remove default nginx files
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# Copy public directory (should always exist for Next.js)
|
||||
COPY --from=builder /app/${APP_PATH}/public /usr/share/nginx/html/public
|
||||
|
||||
# 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..."; \
|
||||
# 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 --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..."; \
|
||||
# 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
|
||||
|
||||
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