mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 12:05:34 +08:00
fix(docker): pass RUNTIME_HOME=/root for root bake targets
The root image variants (runtime, runtime-code, runtime-slim, runtime-code-slim) set RUNTIME_USER=root but left RUNTIME_HOME at the Dockerfile default of /home/nonroot, so VOLUME and WORKDIR pointed at /home/nonroot while the process ran with HOME=/root and ~/.headroom landed in the container layer instead of the volume. Fixes #4443
This commit is contained in:
@@ -21,6 +21,7 @@ target "runtime" {
|
||||
args = {
|
||||
HEADROOM_EXTRAS = "proxy,bedrock"
|
||||
RUNTIME_USER = "root"
|
||||
RUNTIME_HOME = "/root"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +40,7 @@ target "runtime-code" {
|
||||
args = {
|
||||
HEADROOM_EXTRAS = "proxy,code,bedrock"
|
||||
RUNTIME_USER = "root"
|
||||
RUNTIME_HOME = "/root"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +59,7 @@ target "runtime-slim" {
|
||||
args = {
|
||||
HEADROOM_EXTRAS = "proxy,bedrock"
|
||||
RUNTIME_USER = "root"
|
||||
RUNTIME_HOME = "/root"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +78,7 @@ target "runtime-code-slim" {
|
||||
args = {
|
||||
HEADROOM_EXTRAS = "proxy,code,bedrock"
|
||||
RUNTIME_USER = "root"
|
||||
RUNTIME_HOME = "/root"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,31 @@ def test_every_published_docker_variant_includes_bedrock_auth_dependencies() ->
|
||||
assert {"boto3", "botocore"} <= bedrock_names
|
||||
|
||||
|
||||
def test_root_docker_bake_targets_pass_runtime_home_root() -> None:
|
||||
"""Root image variants must declare the volume/workdir under ``/root`` (#4443).
|
||||
|
||||
``RUNTIME_HOME`` defaults to ``/home/nonroot`` in the Dockerfile, so a bake
|
||||
target with ``RUNTIME_USER = "root"`` that omits it ships an image whose
|
||||
VOLUME and WORKDIR are ``/home/nonroot`` while the process runs with
|
||||
``HOME=/root``; ``~/.headroom`` then lands in the container layer.
|
||||
"""
|
||||
bake = (ROOT / "docker-bake.hcl").read_text(encoding="utf-8")
|
||||
blocks = re.findall(r'^target "([^"]+)" \{\n(.*?)^\}', bake, flags=re.S | re.M)
|
||||
root_targets = {
|
||||
name: body for name, body in blocks if re.search(r'RUNTIME_USER\s*=\s*"root"', body)
|
||||
}
|
||||
assert set(root_targets) == {"runtime", "runtime-code", "runtime-slim", "runtime-code-slim"}
|
||||
missing = [
|
||||
name
|
||||
for name, body in root_targets.items()
|
||||
if not re.search(r'RUNTIME_HOME\s*=\s*"/root"', body)
|
||||
]
|
||||
assert not missing, f"root bake targets without RUNTIME_HOME=/root: {missing}"
|
||||
for name, body in blocks:
|
||||
if re.search(r'RUNTIME_USER\s*=\s*"nonroot"', body):
|
||||
assert "RUNTIME_HOME" not in body or "/home/nonroot" in body, name
|
||||
|
||||
|
||||
def test_public_docker_instructions_use_the_current_organization_package() -> None:
|
||||
"""Do not send users back to the personal GHCR package frozen at 0.27.0."""
|
||||
public_docs = (
|
||||
|
||||
Reference in New Issue
Block a user