Skip to content

Commit ee60995

Browse files
committed
fix: Fix build errors and optimize Docker build
- Fix TypeScript build error in workItems.ts by reordering type declarations - Fix WidgetAvailability imports to use both type and constant exports - Update README with comprehensive tool documentation (81 tools) - Optimize Dockerfile with multi-stage build for production - Remove unnecessary build dependencies (python, make, g++, git) - Add proper production dependency separation - Configure ESM support with Node.js flags - Reduce layers and improve caching strategy - Add scripts/ to .gitignore for local development tools - Add .yarnrc.yml for Yarn 4 configuration - Ensure tests work correctly with/without .env.test file
1 parent b9737ef commit ee60995

File tree

7 files changed

+257
-226
lines changed

7 files changed

+257
-226
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ coverage/
2121
.opencode*
2222
.aider*
2323

24+
# Scripts directory (local tools and utilities)
25+
scripts/
26+
2427
# Keep assets
2528
!assets/

.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enableGlobalCache: false
2+
3+
enableMirror: false
4+
5+
nodeLinker: node-modules

Dockerfile

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,70 @@
22
# Multi-stage build for optimal image size and security
33

44
# ============================================================================
5-
# BUILD STAGE
5+
# DEPENDENCIES STAGE - Install all dependencies
66
# ============================================================================
7-
FROM node:22-alpine AS builder
8-
9-
# Install build dependencies
10-
RUN apk add --no-cache \
11-
python3 \
12-
make \
13-
g++ \
14-
git
7+
FROM node:22-alpine AS dependencies
158

169
# Enable Corepack for Yarn 4
1710
RUN corepack enable
1811

1912
# Set working directory
2013
WORKDIR /app
2114

22-
# Copy package management files
15+
# Copy only package files for better caching
2316
COPY package.json yarn.lock .yarnrc.yml ./
24-
COPY .yarn ./.yarn
17+
# Copy .yarn directory if it exists (Yarn 4 cache)
18+
COPY .yarn/ ./.yarn/
2519

26-
# Install dependencies with cache mount
27-
RUN --mount=type=cache,target=/app/.yarn/cache \
20+
# Install ALL dependencies (including dev) for building
21+
RUN --mount=type=cache,target=/root/.yarn/berry/cache \
22+
--mount=type=cache,target=/app/.yarn/cache \
2823
yarn install --immutable
2924

30-
# Copy source code
31-
COPY . .
25+
# ============================================================================
26+
# BUILD STAGE - Build the application
27+
# ============================================================================
28+
FROM node:22-alpine AS builder
29+
30+
# Enable Corepack for Yarn 4
31+
RUN corepack enable
32+
33+
# Set working directory
34+
WORKDIR /app
35+
36+
# Copy dependencies from previous stage
37+
COPY --from=dependencies /app/node_modules ./node_modules
38+
COPY --from=dependencies /app/.yarn ./.yarn
39+
COPY --from=dependencies /app/package.json ./package.json
40+
COPY --from=dependencies /app/yarn.lock ./yarn.lock
41+
COPY --from=dependencies /app/.yarnrc.yml ./.yarnrc.yml
42+
43+
# Copy source code and config files
44+
COPY tsconfig*.json ./
45+
COPY src ./src
3246

3347
# Build the application
3448
RUN yarn build
3549

36-
# Remove dev dependencies and rebuild for production
37-
RUN --mount=type=cache,target=/app/.yarn/cache \
50+
# ============================================================================
51+
# PRODUCTION DEPENDENCIES STAGE - Install only production dependencies
52+
# ============================================================================
53+
FROM node:22-alpine AS production-deps
54+
55+
# Enable Corepack for Yarn 4
56+
RUN corepack enable
57+
58+
# Set working directory
59+
WORKDIR /app
60+
61+
# Copy package files
62+
COPY package.json yarn.lock .yarnrc.yml ./
63+
COPY .yarn/ ./.yarn/
64+
65+
# Install only production dependencies
66+
ENV NODE_ENV=production
67+
RUN --mount=type=cache,target=/root/.yarn/berry/cache \
68+
--mount=type=cache,target=/app/.yarn/cache \
3869
yarn workspaces focus --production
3970

4071
# ============================================================================
@@ -55,9 +86,13 @@ RUN addgroup -g 1001 -S gitlab-mcp && \
5586
# Set working directory
5687
WORKDIR /app
5788

58-
# Copy built application and dependencies from builder
89+
# Copy built application from builder
5990
COPY --from=builder --chown=gitlab-mcp:gitlab-mcp /app/dist ./dist
60-
COPY --from=builder --chown=gitlab-mcp:gitlab-mcp /app/node_modules ./node_modules
91+
92+
# Copy production dependencies from production-deps stage
93+
COPY --from=production-deps --chown=gitlab-mcp:gitlab-mcp /app/node_modules ./node_modules
94+
95+
# Copy package.json for reference
6196
COPY --from=builder --chown=gitlab-mcp:gitlab-mcp /app/package.json ./package.json
6297

6398
# ============================================================================
@@ -96,8 +131,8 @@ ENV HTTP_PROXY=""
96131
ENV HTTPS_PROXY=""
97132
ENV NO_PROXY=""
98133

99-
# Performance and resource limits
100-
ENV NODE_OPTIONS="--max-old-space-size=512"
134+
# Performance and resource limits with ESM support
135+
ENV NODE_OPTIONS="--max-old-space-size=512 --experimental-specifier-resolution=node --no-warnings"
101136

102137
# Health check endpoint
103138
ENV HEALTH_CHECK_ENABLED=true

0 commit comments

Comments
 (0)