import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import { test } from 'node:test' const dockerfile = readFileSync(new URL('../Dockerfile', import.meta.url), 'utf8') test('Dockerfile 使用锁文件、多阶段和非 root 运行', () => { assert.match(dockerfile, /^FROM node:24\.18\.0-alpine AS dependencies$/m) assert.match(dockerfile, /COPY package\.json package-lock\.json \.\//) assert.equal(/\bRUN npm install\b/.test(dockerfile), false) assert.ok((dockerfile.match(/\bRUN npm ci\b/g) || []).length >= 2) assert.match(dockerfile, /^USER node$/m) assert.match(dockerfile, /^HEALTHCHECK /m) assert.match(dockerfile, /^CMD \["node", "dist\/index\.js"\]$/m) })