fix docker setup

This commit is contained in:
2025-12-25 15:24:54 +01:00
parent 3ceb837e15
commit f1c01b73ad
18 changed files with 419 additions and 132 deletions

View File

@@ -5,15 +5,16 @@ WORKDIR /app
# Install bash for better shell capabilities
RUN apk add --no-cache bash
# Copy root package.json and install dependencies
# Copy package manifests and install dependencies (incl. workspaces)
COPY package.json package-lock.json ./
RUN npm ci
COPY apps/website/package.json apps/website/package.json
RUN npm ci --workspaces --include-workspace-root
RUN find ./node_modules -name "next" -print || true # Debugging line
# Copy apps/website and packages for development
# Copy sources for development (monorepo)
COPY apps/website apps/website/
COPY packages core/
COPY apps/website/tsconfig.json apps/website/
COPY core core/
COPY adapters adapters/
COPY scripts scripts/
COPY tsconfig.base.json ./

View File

@@ -2,21 +2,21 @@ FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files and install dependencies
# Copy package manifests and install dependencies (incl. workspaces)
COPY package.json package-lock.json ./
RUN npm ci
COPY apps/website/package.json apps/website/package.json
RUN npm ci --workspaces --include-workspace-root
# Copy apps/website, packages, and config for building
# Copy sources and config for building (monorepo)
COPY apps/website apps/website/
COPY packages core/
COPY apps/website/tsconfig.json apps/website/
COPY core core/
COPY adapters adapters/
COPY scripts scripts/
COPY tsconfig.base.json ./
# Build the Next.js application
# Run from the root workspace context
RUN node ./node_modules/next/dist/bin/next build
# Build the Next.js application from the workspace
RUN npm run env:website:merge && npm run build --workspace=@gridpilot/website
# Production stage: slim image with only production dependencies and built files
@@ -28,10 +28,11 @@ WORKDIR /app
RUN apk add --no-cache wget
# Copy package files and install production dependencies only
# Copy package files and install production dependencies (incl. workspaces)
COPY --from=builder /app/package.json ./
COPY --from=builder /app/package-lock.json ./
RUN npm ci --omit=dev
COPY --from=builder /app/apps/website/package.json ./apps/website/package.json
RUN npm ci --omit=dev --workspaces --include-workspace-root
# Copy built Next.js application
COPY --from=builder /app/apps/website/.next ./apps/website/.next
@@ -39,10 +40,8 @@ COPY --from=builder /app/apps/website/public ./apps/website/public
COPY --from=builder /app/apps/website/package.json ./apps/website/package.json
COPY --from=builder /app/apps/website/next.config.mjs ./apps/website/next.config.mjs
# Copy packages (needed for runtime dependencies)
COPY --from=builder /app/packages ./packages
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Run Next.js in production mode from the root workspace context
CMD ["node", "./node_modules/next/dist/bin/next", "start"]
# Run Next.js in production mode (workspace context)
CMD ["npm", "run", "start", "--workspace=@gridpilot/website"]

View File

@@ -1,9 +1,14 @@
/** @type {import('next').NextConfig} */
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const nextConfig = {
reactStrictMode: true,
// Fix for Next.js 13+ Turbopack in monorepos to correctly identify the workspace root
outputFileTracingRoot: '/Users/marcmintel/Projects/gridpilot',
// Fix for monorepos: point tracing to repo root (portable across machines/containers)
outputFileTracingRoot: path.join(__dirname, '../..'),
images: {
remotePatterns: [
{