mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-27 22:38:50 +00:00
* refactor(hooks): share package runtime
Load one package hook from setup and the Claude plugin to prevent drift.
Refs #3869
* fix(hooks): resolve recovery review (#3879)
Cache the validated package runtime and supervise cold recovery in a
helper so concurrent events survive caller exits without repeat installs.
Handle installed shims, npm shell quoting, private state, and cooldowns.
Publish setup files atomically, clarify migration and ownership hints,
and cover recovery on the cross-platform matrix.
Note: pre-existing failure in analysis-publication-flow.test.ts (FTS
unavailable with an empty extension home) not addressed by this PR.
* fix(hooks): handle quoting and hint races
Preserve quoted and escaped Bash queries as one CLI argument. Serialize
rolling hint checks across processes and recover abandoned claims while
protecting successor ownership.
Refs #3879
Note: pre-existing failure in analysis-publication-flow.test.ts (FTS
unavailable with an empty extension home) not addressed by this PR.
* fix(hooks): preserve Windows npx shim paths
Keep discovered executable and batch launchers when npx-cli.js is absent.
Pass batch paths through the quoted environment transport used by hooks.
Complete the remaining finding from the same PR review batch.
Refs #3879
Note: pre-existing failure in analysis-publication-flow.test.ts (FTS
unavailable with an empty extension home) not addressed by this PR.
* test(hooks): model Windows package execution
Replace obsolete direct .cmd targets with Node executables and the
packaged CLI path. Include paths with spaces and literal arguments.
Refs #3879
Note: pre-existing failure in analysis-publication-flow.test.ts (FTS
unavailable with an empty extension home) not addressed by this PR.
* fix(hooks): consume long search option values
Handle --max-count and long context aliases before choosing the query.
Cover rg/grep values, quoted searches, incomplete options, and both
package and plugin entrypoints.
Refs #3879
Note: pre-existing failure in analysis-publication-flow.test.ts (FTS
unavailable with an empty extension home) not addressed by this PR.
* fix(hooks): resolve cross-platform CI failures
Treat Windows access errors during hint-claim contention as a lost
claim, include the launcher source in rebuild fixtures, and resolve
temporary fixture paths before comparing them with runtime paths.
Include the Windows Codex quoting fixes from #3892
(2a3c3ca981).
Co-authored-by: b84330808 <b84330808@gmail.com>
* test(hooks): handle Windows stdin EOF
---------
Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: b84330808 <b84330808@gmail.com>
126 lines
6.8 KiB
Text
126 lines
6.8 KiB
Text
ARG BUILDPLATFORM
|
|
ARG TARGETPLATFORM
|
|
# Pinned npm version used to replace the bundled npm in the upstream Node
|
|
# image. Bumping requires a coordinated update in Dockerfile.web and
|
|
# gitnexus/Dockerfile.test so all images bootstrap the same npm.
|
|
ARG NPM_VERSION=11.14.1
|
|
|
|
# -- Builder -----------------------------------------------------------
|
|
# Native modules (tree-sitter-*, node-gyp builds for
|
|
# tree-sitter-proto / tree-sitter-swift) require python3 + a C/C++ toolchain.
|
|
# onnxruntime-node is not installed by `npm ci`; local embeddings need
|
|
# `gitnexus embeddings install` (or HTTP env / a bind-mounted prefix). The
|
|
# runtime stage strips npm, so this image cannot auto-heal the stack.
|
|
# node:22-bookworm-slim
|
|
FROM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e AS builder
|
|
ARG NPM_VERSION
|
|
|
|
WORKDIR /app
|
|
|
|
RUN npx --yes npm@${NPM_VERSION} install -g npm@${NPM_VERSION}
|
|
|
|
# Toolchain for node-gyp / native builds.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ git && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build gitnexus-shared first - gitnexus depends on it as a workspace.
|
|
COPY gitnexus-shared/package.json gitnexus-shared/package-lock.json ./gitnexus-shared/
|
|
RUN npm ci --prefix gitnexus-shared
|
|
COPY gitnexus-shared ./gitnexus-shared
|
|
RUN rm -f gitnexus-shared/tsconfig.tsbuildinfo
|
|
RUN npm run build --prefix gitnexus-shared
|
|
|
|
# Copy the full gitnexus package before installing - `npm ci` triggers
|
|
# `postinstall` (patches tree-sitter-swift, builds the vendored
|
|
# tree-sitter-proto) and `prepare` (compiles TypeScript via scripts/build.js),
|
|
# both of which need the source tree.
|
|
COPY gitnexus ./gitnexus
|
|
# setup packages the same small launcher the standalone Claude plugin uses.
|
|
COPY gitnexus-claude-plugin/hooks/gitnexus-hook.js ./gitnexus-claude-plugin/hooks/gitnexus-hook.js
|
|
RUN npm ci --prefix gitnexus
|
|
|
|
# Drop dev dependencies for a smaller runtime layer.
|
|
RUN npm prune --omit=dev --prefix gitnexus
|
|
|
|
# `npm prune` removes anything not in package.json's dependency tree — which
|
|
# includes the VENDORED tree-sitter grammars (materialized into node_modules/ by
|
|
# postinstall, but not declared as deps) and their freshly-built native bindings.
|
|
# The `serve` image analyzes/parses uploaded repos at runtime, so those grammars
|
|
# must survive into the runtime layer. Re-run the grammar postinstall here in the
|
|
# builder (which still has python3/make/g++ and the hoisted node-addon-api /
|
|
# node-gyp-build) to re-materialize + rebuild them after the prune. This is
|
|
# load-bearing for tree-sitter-c (a core, REQUIRED grammar now vendored, #2116):
|
|
# as a former `dependency` it used to survive prune; vendored, it would not.
|
|
RUN npm run postinstall --prefix gitnexus
|
|
|
|
# -- Runtime -----------------------------------------------------------
|
|
# node:22-bookworm-slim
|
|
FROM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e AS runtime
|
|
|
|
# curl for the healthcheck; git for cloning; procps for watch process identity;
|
|
# ca-certificates for TLS verification; openssh-client so auto-sync SSH remotes
|
|
# can clone (git invokes `ssh`; --no-install-recommends omits it from git).
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl git procps ca-certificates openssh-client && rm -rf /var/lib/apt/lists/* \
|
|
&& rm -rf /usr/local/lib/node_modules/npm \
|
|
&& rm -rf /usr/local/lib/node_modules/corepack \
|
|
&& rm -f /usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/corepack
|
|
|
|
WORKDIR /app
|
|
|
|
# Pre-create the data directory and hand it to the unprivileged `node` user
|
|
# so the bind-mounted volume is writable without root.
|
|
RUN mkdir -p /data/gitnexus && chown -R node:node /data
|
|
|
|
COPY --from=builder --chown=node:node /app/gitnexus/dist ./gitnexus/dist
|
|
COPY --from=builder --chown=node:node /app/gitnexus/node_modules ./gitnexus/node_modules
|
|
COPY --from=builder --chown=node:node /app/gitnexus/package.json ./gitnexus/package.json
|
|
COPY --from=builder --chown=node:node /app/gitnexus/scripts/install-duckdb-extension.mjs ./gitnexus/scripts/install-duckdb-extension.mjs
|
|
COPY --from=builder --chown=node:node /app/gitnexus/vendor ./gitnexus/vendor
|
|
|
|
# Expose the `gitnexus` binary on PATH so the documented Docker workflow
|
|
# (`docker compose exec gitnexus-server gitnexus index /workspace/<repo>`)
|
|
# works without users having to invoke `node /app/gitnexus/dist/cli/index.js`.
|
|
# `npm prune --omit=dev` in the builder stage strips `node_modules/.bin/`
|
|
# entries, so the `gitnexus` bin declared in package.json (`dist/cli/index.js`,
|
|
# which already carries `#!/usr/bin/env node` and 755 perms) is otherwise
|
|
# unreachable from $PATH.
|
|
RUN ln -s /app/gitnexus/dist/cli/index.js /usr/local/bin/gitnexus
|
|
|
|
# Verify the packaged FTS binary under the runtime user. ExtensionManager loads
|
|
# this same vendored path before trying HOME, including under load-only policy.
|
|
# The CDN can replace a versioned artifact with an ABI-incompatible rebuild;
|
|
# downloading it here would bypass the binary pinned and tested in this tree.
|
|
# A missing or unloadable packaged extension must still fail the build.
|
|
ENV HOME=/home/node \
|
|
GITNEXUS_LBUG_MAX_DB_SIZE=17179869184
|
|
RUN su node -s /bin/sh -c "HOME=/home/node node /app/gitnexus/scripts/install-duckdb-extension.mjs fts --verify-bundled"
|
|
|
|
# Published runtime assets (in package.json `files`). Placed AFTER the DuckDB
|
|
# FTS verification above so editing hook/skill content does not invalidate that
|
|
# cache layer; they have no input dependency on it.
|
|
# `hooks/`: dist/cli/resolve-invocation.js does
|
|
# `require('../../hooks/claude/resolve-analyze-cmd.cjs')` at module load — the
|
|
# single source of truth for the npm-11 npx-crash invocation decision (#1939).
|
|
# Without it, `gitnexus analyze` inside the image crashes with MODULE_NOT_FOUND
|
|
# before it does any work (#2130). `skills/`: the CLI reads the bundled SKILL.md
|
|
# templates from `<pkg>/skills/` for `gitnexus analyze --skills` and `gitnexus
|
|
# setup`/`uninstall`; absent, those degrade silently (placeholder content / zero
|
|
# skills installed). (The web UI bundle `web/`, also in `files`, is deliberately
|
|
# NOT shipped: this builder never builds gitnexus-web, so the image is API-only;
|
|
# the UI is the separate Dockerfile.web image / hosted app.)
|
|
COPY --from=builder --chown=node:node /app/gitnexus/hooks ./gitnexus/hooks
|
|
COPY --from=builder --chown=node:node /app/gitnexus/skills ./gitnexus/skills
|
|
|
|
USER node
|
|
|
|
# The web UI defaults to http://localhost:4747 - keep that contract.
|
|
ENV GITNEXUS_HOME=/data/gitnexus \
|
|
GITNEXUS_NO_UPDATE_NOTIFIER=1 \
|
|
NODE_ENV=production \
|
|
PORT=4747
|
|
|
|
EXPOSE 4747
|
|
|
|
# Bind 0.0.0.0 for the host's mapped port, honoring an injected $PORT (Render
|
|
# sets one). `sh -c` expands it; `exec` keeps the server PID 1 so SIGTERM still
|
|
# reaches it. Platforms can rely on this instead of a dockerCommand override.
|
|
CMD ["sh", "-c", "exec gitnexus serve --host 0.0.0.0 --port \"${PORT:-4747}\""]
|