feat(docker): unify dynamic PORT across Dockerfile, compose, and dev server

This commit is contained in:
venus
2026-09-13 02:04:37 -05:00
parent 78b1e0b485
commit d3aefa343e
5 changed files with 23 additions and 11 deletions
+8 -5
View File
@@ -18,7 +18,9 @@ test("Docker Configuration: Dockerfile enforces Node runtime and excludes Nginx"
// 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, /ARG\s+PORT=8080/, "Dockerfile must define ARG PORT with default fallback");
assert.match(content, /ENV\s+PORT=\$\{?PORT\}?/, "Dockerfile must define ENV PORT using variable");
assert.match(content, /EXPOSE\s+\$\{?PORT\}?/, "Dockerfile must expose dynamic PORT variable");
assert.match(content, /CMD\s*\[\s*["']npm["']\s*,\s*["']start["']\s*\]/, "Dockerfile must start via npm start");
});
@@ -28,11 +30,12 @@ test("Docker Configuration: docker-compose.yml configures Node service correctly
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 dynamic port mapping and environment variables
assert.match(content, /PORT:\s*\$\{PORT:-8080\}/, "docker-compose.yml must pass dynamic PORT build arg and env");
assert.match(content, /:\$\{PORT:-8080\}/, "docker-compose.yml must map dynamic container PORT");
// Verifies healthcheck targets 8080
assert.match(content, /localhost:8080/, "Healthcheck must probe port 8080");
// Verifies healthcheck targets dynamic port
assert.match(content, /localhost:\$\{PORT:-8080\}\/healthz/, "Healthcheck must probe dynamic PORT on /healthz");
// Verifies domain argument enforcement
assert.match(content, /SITE_DOMAIN/, "docker-compose.yml must require SITE_DOMAIN");