diff --git a/.github/actions/setup-gitnexus-web/action.yml b/.github/actions/setup-gitnexus-web/action.yml index 86331e36d..8f895423a 100644 --- a/.github/actions/setup-gitnexus-web/action.yml +++ b/.github/actions/setup-gitnexus-web/action.yml @@ -1,5 +1,5 @@ name: Setup GitNexus Web -description: Setup Node.js 20.19+ (vite 7 floor), build gitnexus-shared, install web dependencies +description: Setup Node.js 22, build gitnexus-shared, install web dependencies runs: using: composite @@ -7,9 +7,7 @@ runs: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: # Vite 7 requires Node ^20.19.0 || >=22.12.0 (require(esm) support). - # Pin explicitly so we don't depend on the floating "20" alias resolving - # to a high enough patch version on every runner image. - node-version: '20.19.0' + node-version: 22 cache: npm cache-dependency-path: gitnexus-web/package-lock.json diff --git a/.github/actions/setup-gitnexus/action.yml b/.github/actions/setup-gitnexus/action.yml index e946f1040..b9b4acb7e 100644 --- a/.github/actions/setup-gitnexus/action.yml +++ b/.github/actions/setup-gitnexus/action.yml @@ -1,5 +1,5 @@ name: Setup GitNexus -description: Setup Node.js 20, install dependencies, and optionally build +description: Setup Node.js 22, install dependencies, and optionally build inputs: build: @@ -12,7 +12,7 @@ runs: steps: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 22 cache: npm cache-dependency-path: gitnexus/package-lock.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f3530e4d3..c99b666eb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,8 @@ updates: directory: / schedule: interval: weekly + cooldown: + default-days: 7 open-pull-requests-limit: 5 commit-message: prefix: chore @@ -15,6 +17,36 @@ updates: - dependencies - ci + # Keep pinned Docker base-image digests current for the root Dockerfiles. + - package-ecosystem: docker + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + open-pull-requests-limit: 5 + commit-message: + prefix: chore(deps) + include: scope + labels: + - dependencies + - ci + + # Keep the nested test-image Docker base digest current as well. + - package-ecosystem: docker + directory: /gitnexus + schedule: + interval: weekly + cooldown: + default-days: 7 + open-pull-requests-limit: 5 + commit-message: + prefix: chore(deps) + include: scope + labels: + - dependencies + - ci + # Gitnexus npm deps — tree-sitter grammars checked daily so we catch # new releases that unblock the tree-sitter 0.25 upgrade ASAP. Grammars # are grouped so lockstep bumps produce a single PR. The tree-sitter @@ -25,6 +57,11 @@ updates: directory: /gitnexus schedule: interval: daily + cooldown: + default-days: 7 + semver-major-days: 30 + semver-minor-days: 7 + semver-patch-days: 3 open-pull-requests-limit: 10 commit-message: prefix: chore(deps) @@ -54,6 +91,11 @@ updates: directory: /gitnexus-web schedule: interval: weekly + cooldown: + default-days: 7 + semver-major-days: 30 + semver-minor-days: 7 + semver-patch-days: 3 open-pull-requests-limit: 5 commit-message: prefix: chore(deps) @@ -67,6 +109,11 @@ updates: directory: /gitnexus-shared schedule: interval: weekly + cooldown: + default-days: 7 + semver-major-days: 30 + semver-minor-days: 7 + semver-patch-days: 3 open-pull-requests-limit: 5 commit-message: prefix: chore(deps) diff --git a/.github/workflows/ci-quality.yml b/.github/workflows/ci-quality.yml index 36a936c82..cc334fcaa 100644 --- a/.github/workflows/ci-quality.yml +++ b/.github/workflows/ci-quality.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: 20 + node-version: 22 cache: npm cache-dependency-path: package-lock.json - run: npm ci @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: 20 + node-version: 22 cache: npm cache-dependency-path: package-lock.json - run: npm ci diff --git a/.github/workflows/pr-autofix.yml b/.github/workflows/pr-autofix.yml index dd4a3849a..04eb2468d 100644 --- a/.github/workflows/pr-autofix.yml +++ b/.github/workflows/pr-autofix.yml @@ -61,7 +61,7 @@ jobs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: 20 + node-version: 22 cache: npm cache-dependency-path: package-lock.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d372c163a..d5af63205 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: 20 + node-version: 22 registry-url: https://registry.npmjs.org # Hermetic install for the published artifact — no cache carry-over # from non-tag contexts. setup-node v5+ caches by default when a diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 36f37b5c6..ff75bca26 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -149,7 +149,7 @@ jobs: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: - node-version: 20 + node-version: 22 registry-url: https://registry.npmjs.org # Hermetic install — release-candidate produces shipped artifacts. # setup-node v5+ caches by default when a packageManager field is diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index f476ee7bc..f7fba75e9 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -1,13 +1,19 @@ name: Trivy Image Scan # Builds Dockerfile.cli and Dockerfile.web, then scans the resulting images -# for OS-package and language-package CVEs at HIGH/CRITICAL severity. +# for OS-package and language-package CVEs at MEDIUM+ severity. # Findings upload to the Security tab; record-only (does not block merges). # -# NOT triggered on PRs — image builds are slow and base-image CVE churn -# shouldn't gate feature delivery. +# Trigger on Dockerfile changes in PRs so base-image/npm-layer remediation can +# be verified before merge without running image scans on every PR. on: + pull_request: + paths: + - 'Dockerfile.cli' + - 'Dockerfile.web' + - 'gitnexus/Dockerfile.test' + - '.github/workflows/trivy.yml' push: branches: [main] schedule: @@ -61,7 +67,7 @@ jobs: image-ref: scan-target:${{ matrix.image.name }} format: sarif output: trivy-${{ matrix.image.name }}.sarif - severity: HIGH,CRITICAL + severity: MEDIUM,HIGH,CRITICAL # Hides CVEs with no available fix in the base image. ignore-unfixed: true exit-code: '0' diff --git a/Dockerfile.cli b/Dockerfile.cli index c45292e06..925f295f0 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -1,24 +1,32 @@ 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 ──────────────────────────────────────────────────────────── +# -- Builder ----------------------------------------------------------- # Native modules (tree-sitter-*, onnxruntime-node, node-gyp builds for # tree-sitter-proto / tree-sitter-swift) require python3 + a C/C++ toolchain. -FROM node:22-trixie-slim AS builder +# 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. +# 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 +# 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. @@ -28,11 +36,15 @@ RUN npm ci --prefix gitnexus # Drop dev dependencies for a smaller runtime layer. RUN npm prune --omit=dev --prefix gitnexus -# ── Runtime ──────────────────────────────────────────────────────────── -FROM node:22-trixie-slim AS runtime +# -- Runtime ----------------------------------------------------------- +# node:22-bookworm-slim +FROM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e AS runtime # curl for the healthcheck; git so `gitnexus` can clone repos at runtime. -RUN apt-get update && apt-get install -y --no-install-recommends curl git && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends curl git && 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 @@ -47,7 +59,7 @@ COPY --from=builder --chown=node:node /app/gitnexus/vendor ./gitnexus/vendor USER node -# The web UI defaults to http://localhost:4747 — keep that contract. +# The web UI defaults to http://localhost:4747 - keep that contract. ENV GITNEXUS_HOME=/data/gitnexus \ NODE_ENV=production \ PORT=4747 diff --git a/Dockerfile.web b/Dockerfile.web index 7d20e09ce..b102a700e 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -1,10 +1,17 @@ ARG BUILDPLATFORM ARG TARGETPLATFORM +# Pinned npm version — keep in sync with Dockerfile.cli and +# gitnexus/Dockerfile.test. +ARG NPM_VERSION=11.14.1 -FROM --platform=$BUILDPLATFORM node:22-alpine AS builder +# node:22-bookworm-slim +FROM --platform=$BUILDPLATFORM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e AS builder +ARG NPM_VERSION WORKDIR /app +RUN npx --yes npm@${NPM_VERSION} install -g npm@${NPM_VERSION} + COPY gitnexus-shared/package.json gitnexus-shared/package-lock.json ./gitnexus-shared/ RUN npm ci --prefix gitnexus-shared @@ -19,9 +26,13 @@ RUN npm ci --prefix gitnexus-web COPY gitnexus-web ./gitnexus-web RUN npm run build --prefix gitnexus-web -FROM node:22-alpine AS runtime +# node:22-bookworm-slim +FROM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e AS runtime -RUN apk add --no-cache curl +RUN apt-get update && apt-get install -y --no-install-recommends curl && 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 diff --git a/gitnexus/Dockerfile.test b/gitnexus/Dockerfile.test index 0282129ff..37374a5f5 100644 --- a/gitnexus/Dockerfile.test +++ b/gitnexus/Dockerfile.test @@ -1,6 +1,15 @@ -FROM node:20-bookworm +# Pinned npm version — keep in sync with the root Dockerfile.cli and +# Dockerfile.web. +ARG NPM_VERSION=11.14.1 + +# node:22-bookworm-slim +FROM node:22-bookworm-slim@sha256:9f6d5975c7dca860947d3915877f85607946403fc55349f39b4bc3688448bb6e +ARG NPM_VERSION WORKDIR /app -RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/* +RUN npx --yes npm@${NPM_VERSION} install -g npm@${NPM_VERSION} \ + && apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update \ + && apt-get install -y python3 make g++ \ + && rm -rf /var/lib/apt/lists/* COPY . . RUN npm ci --ignore-scripts \ && npm rebuild tree-sitter-swift 2>&1 \ diff --git a/gitnexus/package.json b/gitnexus/package.json index 84f702762..810052502 100644 --- a/gitnexus/package.json +++ b/gitnexus/package.json @@ -116,6 +116,6 @@ } }, "engines": { - "node": ">=20.0.0" + "node": ">=22.0.0" } }