build: add hardened Compose contract

This commit is contained in:
BirSite Automation
2026-07-19 17:31:45 +00:00
parent f94407e587
commit aadf17dc13
2 changed files with 31 additions and 1 deletions

30
compose.yaml Normal file
View File

@@ -0,0 +1,30 @@
services:
site:
build:
context: .
dockerfile: Dockerfile
user: "101:101"
read_only: true
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
expose:
- "8080"
tmpfs:
- /tmp:rw,noexec,nosuid,size=16m
- /var/cache/nginx:rw,noexec,nosuid,size=16m
- /var/run:rw,noexec,nosuid,size=16m
healthcheck:
test:
- CMD-SHELL
- wget -qO- http://127.0.0.1:8080/health.json || exit 1
interval: 10s
timeout: 2s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
cpus: "0.50"
memory: 64MiB

View File

@@ -81,7 +81,7 @@ class ComposeContract(unittest.TestCase):
if not COMPOSE_FILE.is_file(): if not COMPOSE_FILE.is_file():
raise AssertionError(f"RED: required Compose file is missing: {COMPOSE_FILE}") raise AssertionError(f"RED: required Compose file is missing: {COMPOSE_FILE}")
rendered = run( rendered = run(
[COMPOSE_BIN, "compose", "-f", str(COMPOSE_FILE), "config", "--format", "json"] [COMPOSE_BIN, "-f", str(COMPOSE_FILE), "config", "--format", "json"]
) )
if rendered.returncode != 0: if rendered.returncode != 0:
raise AssertionError(f"Compose config rendering failed:\n{rendered.stderr}") raise AssertionError(f"Compose config rendering failed:\n{rendered.stderr}")