import test from "node:test"; import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; test("Docker Configuration: Dockerfile enforces Node runtime and excludes Nginx", () => { const dockerfilePath = path.resolve(process.cwd(), "Dockerfile"); assert.ok(fs.existsSync(dockerfilePath), "Dockerfile must exist"); const content = fs.readFileSync(dockerfilePath, "utf-8"); // Must use Node 22 alpine assert.match(content, /FROM\s+node:22-alpine/i, "Dockerfile must use node:22-alpine base image"); // Must NOT contain nginx base images or references assert.doesNotMatch(content, /FROM\s+nginx/i, "Dockerfile must not use nginx base image"); assert.doesNotMatch(content, /nginx/i, "Dockerfile must not contain nginx directives"); // Must build static site and serve with npm assert.match(content, /RUN\s+npm\s+run\s+build/, "Dockerfile must run npm build"); assert.match(content, /EXPOSE\s+8080/, "Dockerfile must expose port 8080"); assert.match(content, /CMD\s*\[\s*["']npm["']\s*,\s*["']start["']\s*\]/, "Dockerfile must start via npm start"); }); test("Docker Configuration: docker-compose.yml configures Node service correctly", () => { const composePath = path.resolve(process.cwd(), "docker-compose.yml"); assert.ok(fs.existsSync(composePath), "docker-compose.yml must exist"); const content = fs.readFileSync(composePath, "utf-8"); // Verifies port mapping to 8080 assert.match(content, /8080:8080/, "docker-compose.yml must map port 8080 to container 8080"); // Verifies healthcheck targets 8080 assert.match(content, /localhost:8080/, "Healthcheck must probe port 8080"); // Verifies domain argument enforcement assert.match(content, /SITE_DOMAIN/, "docker-compose.yml must require SITE_DOMAIN"); });