From 8f458e55e2b5287ce051c31e53c578b19e3d71be Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 28 Dec 2025 18:33:59 +0100 Subject: [PATCH] refactor: update Dockerfiles for server and UI to streamline dependency installation and build process - Modified Dockerfiles to copy package files for all workspaces, enhancing modularity. - Changed dependency installation to skip scripts, preventing unnecessary execution during builds. - Updated build commands to first build packages in dependency order before building the server and UI, ensuring proper build sequence. --- apps/server/Dockerfile | 20 ++++++++++++++------ apps/ui/Dockerfile | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile index 67ecedf0..981bcd10 100644 --- a/apps/server/Dockerfile +++ b/apps/server/Dockerfile @@ -9,19 +9,27 @@ RUN apk add --no-cache python3 make g++ WORKDIR /app -# Copy package files and scripts needed for postinstall +# Copy package files for all workspaces COPY package*.json ./ COPY apps/server/package*.json ./apps/server/ +COPY libs/types/package*.json ./libs/types/ +COPY libs/utils/package*.json ./libs/utils/ +COPY libs/prompts/package*.json ./libs/prompts/ +COPY libs/platform/package*.json ./libs/platform/ +COPY libs/model-resolver/package*.json ./libs/model-resolver/ +COPY libs/dependency-resolver/package*.json ./libs/dependency-resolver/ +COPY libs/git-utils/package*.json ./libs/git-utils/ COPY scripts ./scripts -# Install dependencies -RUN npm ci --workspace=apps/server +# Install dependencies (--ignore-scripts to skip husky and build:packages in prepare script) +RUN npm ci --ignore-scripts -# Copy source +# Copy all source files +COPY libs ./libs COPY apps/server ./apps/server -# Build TypeScript -RUN npm run build --workspace=apps/server +# Build packages in dependency order, then build server +RUN npm run build:packages && npm run build --workspace=apps/server # Production stage FROM node:20-alpine diff --git a/apps/ui/Dockerfile b/apps/ui/Dockerfile index 3ccd09c7..dbfd16d9 100644 --- a/apps/ui/Dockerfile +++ b/apps/ui/Dockerfile @@ -9,25 +9,33 @@ RUN apk add --no-cache python3 make g++ WORKDIR /app -# Copy package files +# Copy package files for all workspaces COPY package*.json ./ COPY apps/ui/package*.json ./apps/ui/ +COPY libs/types/package*.json ./libs/types/ +COPY libs/utils/package*.json ./libs/utils/ +COPY libs/prompts/package*.json ./libs/prompts/ +COPY libs/platform/package*.json ./libs/platform/ +COPY libs/model-resolver/package*.json ./libs/model-resolver/ +COPY libs/dependency-resolver/package*.json ./libs/dependency-resolver/ +COPY libs/git-utils/package*.json ./libs/git-utils/ COPY scripts ./scripts -# Install dependencies (skip electron postinstall) -RUN npm ci --workspace=apps/ui --ignore-scripts +# Install dependencies (--ignore-scripts to skip husky and build:packages in prepare script) +RUN npm ci --ignore-scripts -# Copy source +# Copy all source files +COPY libs ./libs COPY apps/ui ./apps/ui -# Build for web (skip electron) +# Build packages in dependency order, then build UI # VITE_SERVER_URL tells the UI where to find the API server # Using localhost:3008 since both containers expose ports to the host # Use ARG to allow overriding at build time: --build-arg VITE_SERVER_URL=http://api.example.com ARG VITE_SERVER_URL=http://localhost:3008 ENV VITE_SKIP_ELECTRON=true ENV VITE_SERVER_URL=${VITE_SERVER_URL} -RUN npm run build --workspace=apps/ui +RUN npm run build:packages && npm run build --workspace=apps/ui # Production stage - serve with nginx FROM nginx:alpine