aitm-api, aitm-mcp, and gitnexus now build and run healthy in the same docker-compose stack as gitgram Postgres+Redis. - NEW aitimemachine/mcp/Dockerfile — multi-stage; builds gitnexus-shared, gitnexus (native tree-sitter), the root @gitgram/timemachine lib (rewritten to file:.. + --install-links so file: engine deps are copied, not symlinked), then the mcp server; runtime starts HTTP transport (node dist/index.js --transport http). - NEW aitimemachine/gitnexus/Dockerfile — multi-stage (python3/make/g++ for tree-sitter); builds gitnexus-shared then gitnexus; serve on 0.0.0.0:3010. - compose: fix build contexts to the aitimemachine root for aitm-api, aitm-mcp, gitnexus (so file:../ engine siblings resolve); gitnexus host port 3010->13010 (stray host process owned :3010; internal port unchanged). - scripts/build-engines.sh: npm install before TS engine build when node_modules absent. - api-server: regenerate stale package-lock; declare ioredis as optionalDependency and drop the @ts-ignore in providerHealthService (typed dynamic import, tsc clean). Verified: aitm-api :3001/health, aitm-mcp :3003/health, gitnexus :13010/api/health all 200 healthy. aitm-website needs a Clerk key; context7 service def is pre-existing-broken. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
90 lines
4.0 KiB
Docker
90 lines
4.0 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
#
|
|
# GitNexus — code intelligence HTTP/MCP server (production image).
|
|
#
|
|
# Build context MUST be the aitimemachine root, because gitnexus' build.js
|
|
# compiles and inlines the sibling `gitnexus-shared` package resolved via
|
|
# `file:../gitnexus-shared`:
|
|
#
|
|
# docker build -f gitnexus/Dockerfile -t gitnexus .
|
|
#
|
|
# Stage 1 (builder) compiles the native tree-sitter grammars + the TS library.
|
|
# Stage 2 (runtime) runs the CLI `serve` command over HTTP on port 3010.
|
|
|
|
# ──────────────────────────────────────────────────────────────────────────
|
|
# Stage 1: builder
|
|
# node:22 (gitnexus requires node >=22) + python3 / make / g++ for the native
|
|
# tree-sitter grammar builds (node-gyp). Mirrors gitnexus/Dockerfile.test.
|
|
# ──────────────────────────────────────────────────────────────────────────
|
|
FROM node:22-bookworm-slim AS builder
|
|
|
|
RUN set -eux; \
|
|
apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update; \
|
|
apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
python3 \
|
|
make \
|
|
g++; \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# gitnexus' build.js runs tsc with cwd=gitnexus-shared, so the shared package
|
|
# needs its own node_modules/.bin/tsc. Copy both engine sources.
|
|
COPY gitnexus-shared ./gitnexus-shared
|
|
COPY gitnexus ./gitnexus
|
|
|
|
# 1. gitnexus-shared deps (provides tsc for build.js step 1).
|
|
RUN set -eux; \
|
|
cd /app/gitnexus-shared; \
|
|
npm install --no-audit --no-fund
|
|
|
|
# 2. gitnexus deps — native tree-sitter grammars compile during install via
|
|
# node-gyp; rebuild any that need an explicit pass (see Dockerfile.test).
|
|
RUN set -eux; \
|
|
cd /app/gitnexus; \
|
|
npm install --no-audit --no-fund --ignore-scripts; \
|
|
npm rebuild 2>&1 || true; \
|
|
npm rebuild tree-sitter-swift 2>&1 || true; \
|
|
if [ -d node_modules/tree-sitter-kotlin ]; then \
|
|
(cd node_modules/tree-sitter-kotlin && npx --yes node-gyp rebuild 2>&1 || true); \
|
|
fi
|
|
|
|
# 3. Build the TS library (compiles gitnexus-shared + gitnexus, inlines the
|
|
# shared dist). gitnexus-web is absent from the context → that step is
|
|
# skipped by build.js, and run the grammar postinstall builder explicitly.
|
|
RUN set -eux; \
|
|
cd /app/gitnexus; \
|
|
node scripts/build-tree-sitter-grammars.cjs 2>&1 || true; \
|
|
node scripts/build.js
|
|
|
|
# ──────────────────────────────────────────────────────────────────────────
|
|
# Stage 2: runtime
|
|
# ──────────────────────────────────────────────────────────────────────────
|
|
FROM node:22-bookworm-slim AS runtime
|
|
|
|
ENV NODE_ENV=production \
|
|
PORT=3010
|
|
|
|
WORKDIR /app
|
|
|
|
# The runtime serves via `tsx src/cli/index.ts serve`, so ship the full source
|
|
# tree + node_modules (tsx + native grammars) from the builder.
|
|
COPY --from=builder /app/gitnexus ./gitnexus
|
|
COPY --from=builder /app/gitnexus-shared ./gitnexus-shared
|
|
|
|
RUN chown -R node:node /app
|
|
USER node
|
|
|
|
WORKDIR /app/gitnexus
|
|
|
|
EXPOSE 3010
|
|
|
|
# gitnexus exposes /api/health; the compose healthcheck tolerates other paths.
|
|
HEALTHCHECK --interval=20s --timeout=5s --start-period=20s --retries=5 \
|
|
CMD node -e "require('http').get('http://127.0.0.1:'+(process.env.PORT||3010)+'/api/health',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"
|
|
|
|
# serve defaults to port 4747 / host localhost; bind 0.0.0.0 on PORT for the
|
|
# container so the published port and healthcheck reach it.
|
|
CMD ["sh", "-c", "npx tsx src/cli/index.ts serve --port ${PORT:-3010} --host 0.0.0.0"]
|