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.
This commit is contained in:
Kacper
2025-12-28 18:33:59 +01:00
parent 61881d99e2
commit 8f458e55e2
2 changed files with 28 additions and 12 deletions

View File

@@ -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

View File

@@ -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