# syntax=docker/dockerfile:1 FROM docker.io/library/node:22-alpine AS builder WORKDIR /src COPY . ./ RUN apk add --no-cache python3 py3-setuptools make g++ git # Install the pnpm version pinned in package.json `packageManager`, verifying # the tarball against the pin's sha512 digest as corepack did (corepack was # removed from Node 25+ and cannot install pnpm >= 12). RUN pnpm_version=$(node -p "require('./package.json').packageManager.split('@')[1].split('+')[0]") && \ pnpm_sha=$(node -p "require('./package.json').packageManager.split('+sha512.')[1]") && \ npm pack pnpm@$pnpm_version && \ echo "$pnpm_sha pnpm-$pnpm_version.tgz" | sha512sum -c - && \ npm install --global ./pnpm-$pnpm_version.tgz && \ rm ./pnpm-$pnpm_version.tgz && \ pnpm install --frozen-lockfile && \ pnpm run build && \ # Commit lint CLI packages npm pack @commitlint/cli && \ npm pack @commitlint/config-validator && \ npm pack @commitlint/config-pnpm-scopes && \ npm pack @commitlint/config-nx-scopes && \ npm pack @commitlint/ensure && \ npm pack @commitlint/execute-rule && \ npm pack @commitlint/format && \ npm pack @commitlint/is-ignored && \ npm pack @commitlint/lint && \ npm pack @commitlint/load && \ npm pack @commitlint/message && \ npm pack @commitlint/parse && \ npm pack @commitlint/read && \ npm pack @commitlint/resolve-extends && \ npm pack @commitlint/rules && \ npm pack @commitlint/to-lines && \ npm pack @commitlint/top-level && \ npm pack @commitlint/types && \ # Default commitlint config npm pack @commitlint/config-conventional FROM docker.io/library/node:22-alpine ENV NODE_PATH=/usr/local/lib/node_modules RUN apk add --no-cache git COPY --from=builder /src/*.tgz ./ RUN npm config set fetch-retry-mintimeout 20000 && \ npm config set fetch-retry-maxtimeout 120000 && \ npm install --no-audit -g *.tgz && \ rm -rf *.tgz RUN <<'EOF' set -eu cat >/tmp/commitlint.config.ts <<'CONFIG' import { RuleConfigSeverity } from "@commitlint/types"; import type { UserConfig } from "@commitlint/types"; export default { extends: ["@commitlint/config-conventional"], rules: { "header-max-length": [RuleConfigSeverity.Error, "always", 50], }, } satisfies UserConfig; CONFIG echo "fix: load TypeScript config" | commitlint --config /tmp/commitlint.config.ts if echo "fix: reject a header that exceeds the custom configured limit" | commitlint --config /tmp/commitlint.config.ts; then exit 1 fi rm -rf /tmp/jiti /tmp/node-compile-cache /tmp/commitlint.config.ts EOF ENTRYPOINT ["commitlint"]