docker-devkit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,302 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import platform
6
+ import re
7
+ from pathlib import Path
8
+ from typing import Any, Literal
9
+
10
+ import typer
11
+ import yaml
12
+ from bashrun import bash, bash_output
13
+ from .detect_gpu import GPU_TYPES, Gpu, detect_gpu
14
+ from pydantic_settings import BaseSettings
15
+
16
+ from .context_sha import compute_service_shas
17
+ from .image_refs import bake_base_image_refs, compose_service_refs, resolve_remote_digest
18
+
19
+
20
+ class Settings(BaseSettings):
21
+ wsl_distro_name: str | None = None
22
+
23
+
24
+ settings = Settings.model_validate({})
25
+
26
+ LOCK_FILE = Path(".env.lock")
27
+ ENV_SHAS_FILE = Path(".env.shas")
28
+ COMPOSE_FILE = Path("compose.yml")
29
+ DEFAULT_BAKE_FILE = Path("compose.bake.yml")
30
+ METADATA_PATH = Path("metadata.json")
31
+
32
+ Mode = Literal["local", "ci"]
33
+
34
+
35
+ app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
36
+
37
+
38
+ def _load_lock_file(path: Path):
39
+ return {
40
+ (p := line.split("=", 1))[0].strip(): p[1].strip()
41
+ for line in path.read_text(encoding="utf-8").splitlines()
42
+ if "=" in line and not line.startswith("#")
43
+ }
44
+
45
+
46
+ def _write_lock_file(path: Path, variables: dict[str, str]):
47
+ path.write_text(
48
+ "# Generated by lock.py\n" + "\n".join(f"{k}={v}" for k, v in sorted(variables.items())) + "\n",
49
+ encoding="utf-8",
50
+ )
51
+
52
+
53
+ # Vibe code - Gemini 3
54
+ def _check_gc_limits(min_gb: int = 60):
55
+ candidates = [Path("/etc/docker/daemon.json"), Path(os.path.expanduser("~/.docker/daemon.json"))]
56
+ if settings.wsl_distro_name is not None:
57
+ try:
58
+ win_home = bash_output('wslpath $(cmd.exe /c "echo %UserProfile%" 2>/dev/null)').strip()
59
+ candidates.append(Path(win_home) / ".docker" / "daemon.json")
60
+ except Exception:
61
+ pass
62
+
63
+ config = next((p for p in candidates if p.exists() and os.access(p, os.R_OK)), None)
64
+ if not config:
65
+ print(f" [WARN] No readable daemon.json found. Ensure defaultKeepStorage > {min_gb}GB.")
66
+ return
67
+
68
+ data = json.loads(config.read_text())
69
+ raw = data.get("builder", {}).get("gc", {}).get("defaultKeepStorage")
70
+ if not raw:
71
+ sample = json.dumps({"builder": {"gc": {"defaultKeepStorage": f"{min_gb}GB"}}}, indent=2)
72
+ raise RuntimeError(
73
+ f"Missing 'builder.gc.defaultKeepStorage' in {config}; Docker's default is too low for GPU builds "
74
+ f"(need >= {min_gb}GB). Add the following (merging into any existing keys) and restart Docker:\n\n{sample}"
75
+ )
76
+
77
+ m = re.match(r"^(\d+(?:\.\d+)?)\s*([TGMK]i?B)?$", str(raw), re.IGNORECASE)
78
+ if not m:
79
+ raise RuntimeError(f"Could not parse 'defaultKeepStorage' value: {raw}")
80
+
81
+ mult = {"T": 1024, "G": 1, "M": 1 / 1024, "K": 1 / 1024**2, "B": 1 / 1024**3}
82
+ unit = (m.group(2) or "B")[0].upper()
83
+ val = float(m.group(1)) * mult.get(unit, 1 / 1024**3)
84
+
85
+ if val < min_gb:
86
+ raise RuntimeError(
87
+ f"UNSAFE GC LIMIT: {val:.1f}GB in {config} (Required: {min_gb}GB). RESTART DOCKER AFTER FIXING."
88
+ )
89
+
90
+ print(f" [OK] Docker GC Limit verified: {val:.1f}GB")
91
+
92
+
93
+ def _load_compose(path: Path) -> dict[str, Any]:
94
+ data: dict[str, Any] = yaml.safe_load(path.read_text(encoding="utf-8"))
95
+ for include in data.pop("include", []):
96
+ include_path = path.parent / (include if isinstance(include, str) else include["path"])
97
+ included: dict[str, Any] = yaml.safe_load(include_path.read_text(encoding="utf-8"))
98
+ data.setdefault("services", {}).update(included.get("services", {}))
99
+ return data
100
+
101
+
102
+ @app.command()
103
+ def build(
104
+ upgrade: bool = typer.Option(False, "--upgrade", "-u", help="Re-resolve and rewrite base digests."),
105
+ lock_only: bool = typer.Option(False, "--lock-only", help="Update lock file without building images."),
106
+ mode: Mode = typer.Option("local", "--mode", help="local: --load images; ci: --push images + registry caches."),
107
+ gpu: Gpu = typer.Option("auto", "--gpu", help="auto|cuda|rocm|none"),
108
+ gpu_only: bool = typer.Option(
109
+ False, "--gpu-only", help="Build only the services suffixed for this gpu (requires a concrete --gpu)."
110
+ ),
111
+ no_cache: bool = typer.Option(False, "--no-cache", help="Force rebuild by disabling cache usage."),
112
+ targets_opt: list[str] | None = typer.Option(
113
+ None, "--targets", "-t", help="Build only these services (from the selected bake file)."
114
+ ),
115
+ bake_file: Path = typer.Option(
116
+ DEFAULT_BAKE_FILE, "--bake-file", help="Bake file to load (e.g. compose.bake.yml or compose.zed.bake.yml)."
117
+ ),
118
+ ) -> None:
119
+ run_build(
120
+ upgrade=upgrade,
121
+ lock_only=lock_only,
122
+ mode=mode,
123
+ gpu=gpu,
124
+ gpu_only=gpu_only,
125
+ no_cache=no_cache,
126
+ targets_opt=targets_opt,
127
+ bake_file=bake_file,
128
+ )
129
+
130
+
131
+ def run_build(
132
+ *,
133
+ upgrade: bool = False,
134
+ lock_only: bool = False,
135
+ mode: Mode = "local",
136
+ gpu: Gpu = "auto",
137
+ gpu_only: bool = False,
138
+ no_cache: bool = False,
139
+ targets_opt: list[str] | None = None,
140
+ bake_file: Path = DEFAULT_BAKE_FILE,
141
+ ) -> None:
142
+ service_shas = compute_service_shas(Path.cwd(), bake_file)
143
+ os.environ.update(service_shas)
144
+
145
+ # Tags of the images built this run — the local analog of .env.lock's pulled
146
+ # digests — so raw `docker compose` can resolve the compose graph's ${*_SHA} holes.
147
+ ENV_SHAS_FILE.write_text(
148
+ "".join(f"{key}={value}\n" for key, value in sorted(service_shas.items())), encoding="utf-8"
149
+ )
150
+
151
+ # Read bake, compose, and lock files
152
+ bake_data: dict[str, Any] = yaml.safe_load(bake_file.read_text(encoding="utf-8"))
153
+ compose_data: dict[str, Any] = _load_compose(COMPOSE_FILE)
154
+ lock_data = _load_lock_file(LOCK_FILE) if LOCK_FILE.exists() else {}
155
+
156
+ # TOOD: Create separate commands for ci and local modes so typer can do this validation instead of us
157
+ if mode == "ci" and gpu == "auto":
158
+ raise typer.BadParameter("In CI mode, --gpu cannot be 'auto'; specify 'cuda' or 'rocm'.")
159
+
160
+ if gpu_only and gpu not in GPU_TYPES:
161
+ raise typer.BadParameter("--gpu-only requires a concrete gpu (cuda or rocm), not 'auto' or 'none'.")
162
+
163
+ # For local builds, ensure Docker GC limits are high enough that GPU builds don't cause cache evictions
164
+ if mode == "local" and not lock_only and not targets_opt:
165
+ _check_gc_limits(min_gb=60)
166
+
167
+ # Resolve gpu
168
+ if gpu == "auto" and not lock_only:
169
+ gpu = detect_gpu()
170
+
171
+ # Resolve base image external dependencies
172
+ for occurrence in [ref for ref in bake_base_image_refs(bake_data) if upgrade or ref.name not in lock_data]:
173
+ lock_data[occurrence.name] = (
174
+ f"@{'' if '$' in occurrence.reference else resolve_remote_digest(occurrence.reference)}"
175
+ )
176
+
177
+ # Resolve third-party image external dependencies. x-image-ref marks services whose image
178
+ # is sourced externally (vs. built from a bake file), so it's the right discriminator
179
+ # regardless of how many bake files exist.
180
+ third_party_images: dict[str, str] = {
181
+ occurrence.name.upper().replace("-", "_") + "_IMAGE": occurrence.reference
182
+ for occurrence in compose_service_refs(compose_data)
183
+ }
184
+
185
+ def _needs_resolve(image: str, ref: str) -> bool:
186
+ if upgrade or image not in lock_data:
187
+ return True
188
+ # Re-resolve if the image name in compose.yml changed from what's in the lock file
189
+ # (e.g. postgres:16-alpine → postgis/postgis:16-3.4-alpine)
190
+ return not lock_data[image].startswith(ref + "@")
191
+
192
+ for image, ref in {image: ref for image, ref in third_party_images.items() if _needs_resolve(image, ref)}.items():
193
+ lock_data[image] = f"{ref}@{'' if '$' in ref else resolve_remote_digest(ref)}"
194
+
195
+ # Update main lock file
196
+ _write_lock_file(LOCK_FILE, lock_data)
197
+
198
+ if lock_only:
199
+ return
200
+
201
+ # Update environment with external dependency image digests
202
+ os.environ.update(lock_data)
203
+
204
+ # Build command arguments
205
+ command_arguments: list[str] = []
206
+
207
+ # Determine bake targets
208
+ if targets_opt:
209
+ unknown = set(targets_opt) - set(bake_data["services"])
210
+ if unknown:
211
+ raise typer.BadParameter(f"Unknown targets: {unknown}. Available: {sorted(bake_data['services'])}")
212
+ targets = [t for t in bake_data["services"] if t in set(targets_opt)]
213
+ else:
214
+ targets = compute_default_targets(bake_data, gpu, gpu_only)
215
+
216
+ # Configure registry caches in CI mode
217
+ if mode == "ci":
218
+ for target in targets:
219
+ target_cache = f"{bake_data['x-registry-cache']}:{target}"
220
+ command_arguments.append(
221
+ f"--set {target}.cache-to+=type=registry,ref={target_cache},mode=max,image-manifest=true,oci-mediatypes=true"
222
+ )
223
+ command_arguments.append(f"--set {target}.cache-from+=type=registry,ref={target_cache}")
224
+
225
+ # `docker buildx --load` only writes a single arch to the host image store,
226
+ # so bake targets declared multi-platform get overridden to host arch in
227
+ # local builds. CI uses `--push` and produces the full manifest list.
228
+ # Override key is `platform` (singular) even though the bake field is plural.
229
+ if mode == "local":
230
+ machine = platform.machine().lower()
231
+ if machine in ("x86_64", "amd64"):
232
+ host_platform = "linux/amd64"
233
+ elif machine in ("aarch64", "arm64"):
234
+ host_platform = "linux/arm64"
235
+ else:
236
+ raise RuntimeError(f"Unsupported host architecture: {machine}")
237
+ for target in targets:
238
+ target_platforms = bake_data["services"][target].get("build", {}).get("platforms", [])
239
+ if len(target_platforms) > 1:
240
+ command_arguments.append(f"--set {target}.platform={host_platform}")
241
+
242
+ # Load or push images based on mode
243
+ command_arguments.append("--load" if mode == "local" else "--push")
244
+
245
+ # Handle no-cache option
246
+ if no_cache:
247
+ command_arguments.append("--no-cache")
248
+
249
+ # Append targets
250
+ command_arguments.extend(targets)
251
+
252
+ # Clean up any existing metadata file
253
+ METADATA_PATH.unlink(missing_ok=True)
254
+
255
+ # Bake images
256
+ command = [
257
+ "docker buildx bake",
258
+ f"-f {bake_file}",
259
+ f"--metadata-file {METADATA_PATH}",
260
+ "--progress auto",
261
+ "--provenance=false",
262
+ "--sbom=false",
263
+ ] + command_arguments
264
+ bash(" ".join(command))
265
+
266
+ # Sanity check
267
+ baked_images: dict[str, Any] = json.loads(METADATA_PATH.read_text()) if METADATA_PATH.exists() else {}
268
+ if not set(targets) <= baked_images.keys():
269
+ raise RuntimeError("Baked images do not match target images; something went wrong during the bake.")
270
+
271
+
272
+ # x-cross-compile-targets: services declared here are excluded from the default
273
+ # target list because they need special (usually per-arch) treatment; an operator
274
+ # can still opt them in explicitly via --targets. The field is a top-level bake key.
275
+ # Services without build.tags (e.g. neural-networks-base-*) stay out too: they are
276
+ # build-only dependencies pulled in via additional_contexts, and bake rejects a
277
+ # tagless target under --push.
278
+ def compute_default_targets(bake_data: dict[str, Any], gpu: Gpu, gpu_only: bool = False) -> list[str]:
279
+ cross_compile_targets: set[str] = set(bake_data.get("x-cross-compile-targets", []))
280
+ tagged_services = [
281
+ service for service, config in bake_data["services"].items() if config.get("build", {}).get("tags")
282
+ ]
283
+ if gpu_only:
284
+ return [
285
+ service
286
+ for service in tagged_services
287
+ if service.endswith(f"-{gpu}") and service not in cross_compile_targets
288
+ ]
289
+ return [
290
+ service
291
+ for service in tagged_services
292
+ if (not any(service.endswith(f"-{g}") for g in GPU_TYPES) or service.endswith(f"-{gpu}"))
293
+ and service not in cross_compile_targets
294
+ ]
295
+
296
+
297
+ def main() -> None:
298
+ app()
299
+
300
+
301
+ if __name__ == "__main__":
302
+ main()
@@ -0,0 +1,86 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import subprocess
5
+ from pathlib import Path, PurePosixPath
6
+ from tempfile import TemporaryDirectory
7
+
8
+ from typing import Any
9
+
10
+ import pathspec
11
+ import yaml
12
+
13
+
14
+ def _env_var_name(dockerfile_dir: str) -> str:
15
+ return PurePosixPath(dockerfile_dir).name.upper().replace("-", "_") + "_SHA"
16
+
17
+
18
+ def _extract_service_dirs(bake_data: dict[str, Any]) -> set[str]:
19
+ service_dirs: set[str] = set()
20
+ services: dict[str, Any] = bake_data["services"]
21
+ for config in services.values():
22
+ build: dict[str, Any] = config.get("build", {})
23
+ if not build.get("tags"):
24
+ continue
25
+ dockerfile: str = build.get("dockerfile", "")
26
+ service_dirs.add(str(PurePosixPath(dockerfile).parent))
27
+ return service_dirs
28
+
29
+
30
+ def compute_service_shas(repo_root: Path, bake_file: Path) -> dict[str, str]:
31
+ repo_root = repo_root.resolve()
32
+
33
+ bake_data: dict[str, Any] = yaml.safe_load(bake_file.read_text(encoding="utf-8"))
34
+ service_dirs = _extract_service_dirs(bake_data)
35
+
36
+ tree_entries = subprocess.run(
37
+ ["git", "ls-tree", "-r", "HEAD"], cwd=str(repo_root), capture_output=True, text=True, check=True
38
+ ).stdout.splitlines()
39
+
40
+ dockerignore = repo_root / ".dockerignore"
41
+ spec = pathspec.PathSpec.from_lines("gitignore", dockerignore.read_text().splitlines())
42
+
43
+ allowed_entries: list[tuple[str, str, str]] = []
44
+ for entry in tree_entries:
45
+ meta, path = entry.split("\t", 1)
46
+ if spec.match_file(path):
47
+ continue
48
+ mode, _type, obj_hash = meta.split()
49
+ allowed_entries.append((mode, obj_hash, path))
50
+
51
+ docker_prefix = "docker/"
52
+ shared_entries: list[tuple[str, str, str]] = []
53
+ per_service: dict[str, list[tuple[str, str, str]]] = {d: [] for d in service_dirs}
54
+
55
+ for mode, obj_hash, path in allowed_entries:
56
+ if path.startswith(docker_prefix):
57
+ for service_dir in service_dirs:
58
+ if path.startswith(service_dir + "/"):
59
+ per_service[service_dir].append((mode, obj_hash, path))
60
+ break
61
+ else:
62
+ shared_entries.append((mode, obj_hash, path))
63
+
64
+ result: dict[str, str] = {}
65
+ for service_dir in sorted(service_dirs):
66
+ entries = shared_entries + per_service[service_dir]
67
+ index_input = "\n".join(f"{mode} {obj_hash}\t{path}" for mode, obj_hash, path in entries) + "\n"
68
+
69
+ with TemporaryDirectory() as tmpdir:
70
+ env = {**os.environ, "GIT_INDEX_FILE": str(Path(tmpdir) / "index")}
71
+ subprocess.run(
72
+ ["git", "update-index", "--index-info"],
73
+ cwd=str(repo_root),
74
+ env=env,
75
+ input=index_input.encode(),
76
+ capture_output=True,
77
+ check=True,
78
+ )
79
+ tree_hash = subprocess.run(
80
+ ["git", "write-tree"], cwd=str(repo_root), env=env, capture_output=True, text=True, check=True
81
+ ).stdout.strip()
82
+
83
+ var_name = _env_var_name(service_dir)
84
+ result[var_name] = f"tree-{tree_hash}"
85
+
86
+ return result
@@ -0,0 +1,15 @@
1
+ import shutil
2
+ from typing import Literal, get_args
3
+
4
+ from bashrun import bash_check
5
+
6
+ Gpu = Literal["auto", "cuda", "rocm", "none"]
7
+ GPU_TYPES = tuple(g for g in get_args(Gpu) if g not in ("auto", "none"))
8
+
9
+
10
+ def detect_gpu() -> Gpu:
11
+ if shutil.which("nvidia-smi") and bash_check("nvidia-smi"):
12
+ return "cuda"
13
+ if shutil.which("rocminfo") and bash_check("rocminfo"):
14
+ return "rocm"
15
+ raise RuntimeError("Could not detect GPU type.")
docker_devkit/down.py ADDED
@@ -0,0 +1,88 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import typer
5
+ from bashrun import bash_handoff
6
+ from .detect_gpu import Gpu, detect_gpu
7
+
8
+ from .context_sha import compute_service_shas
9
+ from .modes import resolve_auth_mode
10
+
11
+ ENV_FILE = Path(".env")
12
+ LOCK_FILE = Path(".env.lock")
13
+ BAKE_FILE = Path("compose.bake.yml")
14
+
15
+
16
+ def _resolve_service_shas() -> None:
17
+ os.environ.update(compute_service_shas(Path.cwd(), BAKE_FILE))
18
+
19
+
20
+ app = typer.Typer(add_completion=False)
21
+
22
+
23
+ @app.command()
24
+ def down(
25
+ volumes: bool = typer.Option(False, "--volumes", "-v", help="Remove named volumes."),
26
+ gpu: Gpu = typer.Option("auto", "--gpu", help="auto|cuda|rocm|none"),
27
+ compose_file: Path = typer.Option(
28
+ Path("compose.yml"),
29
+ "--compose-file",
30
+ help=(
31
+ "Base compose file. In a repo that authors its own stack (where compose.bake.yml lives) the default "
32
+ "compose.yml tears down the native multi-file stack. A consumer stack is torn down as the single graph "
33
+ "it was brought up as."
34
+ ),
35
+ ),
36
+ ) -> None:
37
+ # Mirror up: native multi-file teardown only when compose.bake.yml is present and the
38
+ # default compose.yml was requested. A consumer stack tears down its single graph.
39
+ native = compose_file == Path("compose.yml") and BAKE_FILE.exists()
40
+
41
+ if not ENV_FILE.exists():
42
+ raise RuntimeError("No .env file found")
43
+
44
+ if native and not LOCK_FILE.exists():
45
+ raise RuntimeError("No lock file found; run 'uv run build --lock-only' first")
46
+
47
+ if gpu == "auto":
48
+ gpu = detect_gpu()
49
+
50
+ resolve_auth_mode(ENV_FILE)
51
+
52
+ if BAKE_FILE.exists():
53
+ _resolve_service_shas()
54
+
55
+ if native:
56
+ compose_files = (
57
+ "-f compose.yml "
58
+ "-f compose.postgres.yml "
59
+ f"{f'-f compose.{gpu}.yml ' if gpu != 'none' else ''}"
60
+ "-f compose.dev.yml " # Include so containers from a prior dev bring-up get torn down even with --no-dev later
61
+ )
62
+ else:
63
+ compose_files = f"-f {compose_file} "
64
+
65
+ # .env.lock keeps compose from erroring on missing stack-internal vars; it only
66
+ # exists in the native repo, so a consumer stack tears down with .env alone.
67
+ lock_flag = f"--env-file {LOCK_FILE} " if LOCK_FILE.exists() else ""
68
+ command = (
69
+ "docker compose "
70
+ f"{compose_files}"
71
+ "--profile keycloak " # Always include so any keycloak containers from a previous AUTH_MODE=keycloak run get torn down
72
+ "--env-file .env "
73
+ f"{lock_flag}"
74
+ "down --remove-orphans"
75
+ )
76
+
77
+ if volumes:
78
+ command += " -v"
79
+
80
+ bash_handoff(command)
81
+
82
+
83
+ def main():
84
+ app()
85
+
86
+
87
+ if __name__ == "__main__":
88
+ main()
@@ -0,0 +1,207 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ import re
5
+ import shlex
6
+ import tomllib
7
+ from dataclasses import dataclass
8
+ from itertools import starmap
9
+ from pathlib import Path
10
+
11
+ import yaml
12
+ from bashrun import bash_output
13
+ from pydantic import BaseModel, ConfigDict, Field, RootModel
14
+
15
+ BUILD_ARG_PATTERN = re.compile(r"\$\{[A-Za-z0-9_]+\}")
16
+ FROM_PATTERN = re.compile(r"^FROM\s+(?:--platform=\S+\s+)?(\S+)", re.MULTILINE)
17
+ COPY_FROM_PATTERN = re.compile(r"^COPY\s+--from=(\S+)", re.MULTILINE)
18
+ IMAGE_LINE_PATTERN = re.compile(r"^\s*image:\s*[\"']?([^\s\"']+)", re.MULTILINE)
19
+ DIGEST_PATTERN = re.compile(r"^Digest:\s+(sha256:[a-f0-9]+)", re.MULTILINE)
20
+ MISSING_VERSION = "<missing>"
21
+
22
+
23
+ class ComposeService(BaseModel):
24
+ model_config = ConfigDict(extra="ignore")
25
+
26
+ image_ref: str | None = Field(default=None, alias="x-image-ref")
27
+
28
+
29
+ class ComposeDocument(BaseModel):
30
+ model_config = ConfigDict(extra="ignore")
31
+
32
+ services: dict[str, ComposeService] = Field(default_factory=dict)
33
+
34
+
35
+ class BakeDocument(BaseModel):
36
+ model_config = ConfigDict(extra="ignore")
37
+
38
+ base_images: dict[str, str] = Field(default_factory=dict, alias="x-base-images")
39
+
40
+
41
+ type TomlValue = (
42
+ str
43
+ | int
44
+ | float
45
+ | bool
46
+ | datetime.datetime
47
+ | datetime.date
48
+ | datetime.time
49
+ | list[TomlValue]
50
+ | dict[str, TomlValue]
51
+ )
52
+
53
+
54
+ class TomlDocument(RootModel[TomlValue]):
55
+ pass
56
+
57
+
58
+ @dataclass(frozen=True)
59
+ class ImageReference:
60
+ name: str
61
+ reference: str
62
+
63
+
64
+ @dataclass(frozen=True)
65
+ class VersionSite:
66
+ description: str
67
+ glob: str
68
+ pattern: str
69
+ base_image: str | None = None
70
+
71
+
72
+ @dataclass(frozen=True)
73
+ class VersionCoupling:
74
+ name: str
75
+ pyproject_key: str
76
+ sites: tuple[VersionSite, ...]
77
+
78
+
79
+ def collect_repo_references(
80
+ root: Path,
81
+ compose_glob: str = "compose*.yml",
82
+ bake_glob: str = "compose*.bake.yml",
83
+ dockerfile_glob: str | None = "docker/*/Dockerfile*",
84
+ image_glob: str | None = "score/*.yaml",
85
+ ) -> list[ImageReference]:
86
+ return (
87
+ [
88
+ reference
89
+ for path in sorted(root.glob(compose_glob))
90
+ for reference in compose_service_refs(_load_yaml_document(path))
91
+ ]
92
+ + [
93
+ reference
94
+ for path in sorted(root.glob(bake_glob))
95
+ for reference in bake_base_image_refs(_load_yaml_document(path))
96
+ ]
97
+ + (
98
+ [
99
+ ImageReference("", match.group(1))
100
+ for path in sorted(root.glob(dockerfile_glob))
101
+ for match in FROM_PATTERN.finditer(path.read_text(encoding="utf-8"))
102
+ ]
103
+ + [
104
+ ImageReference("", match.group(1))
105
+ for path in sorted(root.glob(dockerfile_glob))
106
+ for match in COPY_FROM_PATTERN.finditer(path.read_text(encoding="utf-8"))
107
+ if "/" in match.group(1)
108
+ ]
109
+ if dockerfile_glob
110
+ else []
111
+ )
112
+ + (
113
+ [
114
+ ImageReference("", match.group(1))
115
+ for path in sorted(root.glob(image_glob))
116
+ for match in IMAGE_LINE_PATTERN.finditer(path.read_text(encoding="utf-8"))
117
+ ]
118
+ if image_glob
119
+ else []
120
+ )
121
+ )
122
+
123
+
124
+ def compose_service_refs(document: object) -> list[ImageReference]:
125
+ return [
126
+ ImageReference(service_name, service.image_ref)
127
+ for service_name, service in ComposeDocument.model_validate(document).services.items()
128
+ if service.image_ref is not None
129
+ ]
130
+
131
+
132
+ def bake_base_image_refs(document: object) -> list[ImageReference]:
133
+ return list(starmap(ImageReference, BakeDocument.model_validate(document).base_images.items()))
134
+
135
+
136
+ def _load_yaml_document(path: Path) -> object:
137
+ return yaml.safe_load(path.read_text(encoding="utf-8"))
138
+
139
+
140
+ def strip_build_args(reference: str) -> str:
141
+ return BUILD_ARG_PATTERN.sub("", reference).strip()
142
+
143
+
144
+ def unpinned_references(root: Path) -> list[str]:
145
+ return [
146
+ occurrence.reference
147
+ for occurrence in collect_repo_references(root)
148
+ if "/" in (reference := strip_build_args(occurrence.reference))
149
+ and not BUILD_ARG_PATTERN.search(occurrence.reference)
150
+ and ":" not in (tail := reference[reference.rfind("/") + 1 :])
151
+ and "@" not in tail
152
+ ]
153
+
154
+
155
+ def version_coupling_violations(root: Path, couplings: list[VersionCoupling]) -> list[str]:
156
+ return [
157
+ f"{coupling.name}: {site.description} at {path}: expected {expected}, found {found}"
158
+ for coupling in couplings
159
+ for expected in [_declared_version(_pyproject_value(root, coupling.pyproject_key))]
160
+ for site in coupling.sites
161
+ for path in _site_paths(root, site)
162
+ for found in [_site_version(path, site)]
163
+ if found != expected
164
+ ]
165
+
166
+
167
+ def _pyproject_value(root: Path, dotted_key: str) -> str:
168
+ value = TomlDocument.model_validate(tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))).root
169
+ for component in dotted_key.split("."):
170
+ if not isinstance(value, dict) or component not in value:
171
+ raise RuntimeError(f"pyproject key {dotted_key} is missing or non-table at {component}")
172
+ value = value[component]
173
+ if not isinstance(value, str):
174
+ raise TypeError(f"pyproject key {dotted_key} is not a string")
175
+ return value
176
+
177
+
178
+ def _declared_version(specifier: str) -> str:
179
+ return re.sub(r"^[^0-9]+", "", specifier).split(",")[0].strip()
180
+
181
+
182
+ def _site_paths(root: Path, site: VersionSite) -> list[Path]:
183
+ return sorted(root.glob(site.glob)) or [Path(site.glob)]
184
+
185
+
186
+ def _site_version(path: Path, site: VersionSite) -> str:
187
+ if not path.exists():
188
+ return MISSING_VERSION
189
+ haystack = _bake_base_image(path, site.base_image) if site.base_image else path.read_text(encoding="utf-8")
190
+ match = re.search(site.pattern, haystack)
191
+ return match.group(1) if match else MISSING_VERSION
192
+
193
+
194
+ def _bake_base_image(path: Path, key: str) -> str:
195
+ return next(
196
+ (reference.reference for reference in bake_base_image_refs(_load_yaml_document(path)) if reference.name == key),
197
+ "",
198
+ )
199
+
200
+
201
+ def resolve_remote_digest(reference: str) -> str:
202
+ print(f"Resolving digest for: {reference}")
203
+ output = bash_output(f"docker buildx imagetools inspect {shlex.quote(reference)}")
204
+ match = DIGEST_PATTERN.search(output)
205
+ if match is None:
206
+ raise RuntimeError(f"Could not parse digest for image reference: {reference}")
207
+ return match.group(1)
docker_devkit/modes.py ADDED
@@ -0,0 +1,39 @@
1
+ from os import environ
2
+ from pathlib import Path
3
+ from urllib.parse import urlparse
4
+
5
+ VALID_AUTH_MODES = ("keycloak", "disabled")
6
+ DEFAULT_AUTH_MODE = "keycloak"
7
+
8
+
9
+ def parse_env_file(path: Path) -> dict[str, str]:
10
+ result: dict[str, str] = {}
11
+ for raw_line in path.read_text().splitlines():
12
+ line = raw_line.strip()
13
+ if not line or line.startswith("#") or "=" not in line:
14
+ continue
15
+ key, _, value = line.partition("=")
16
+ result[key.strip()] = value.strip().strip("'\"")
17
+ return result
18
+
19
+
20
+ def resolve_auth_mode(env_file: Path) -> str:
21
+ file_values = parse_env_file(env_file)
22
+ public_url = environ.get("PUBLIC_URL") or file_values.get("PUBLIC_URL")
23
+ auth_mode = environ.get("AUTH_MODE") or file_values.get("AUTH_MODE", DEFAULT_AUTH_MODE)
24
+
25
+ if not public_url:
26
+ raise RuntimeError("PUBLIC_URL is required; set it in .env")
27
+ if auth_mode not in VALID_AUTH_MODES:
28
+ raise RuntimeError(f"AUTH_MODE={auth_mode!r} is invalid; expected one of {list(VALID_AUTH_MODES)}")
29
+
30
+ scheme = urlparse(public_url).scheme
31
+ if scheme not in ("http", "https"):
32
+ raise RuntimeError(f"PUBLIC_URL={public_url!r} must use http:// or https://")
33
+ if scheme == "http" and auth_mode == "keycloak":
34
+ raise RuntimeError(
35
+ f"AUTH_MODE=keycloak with PUBLIC_URL={public_url!r} is rejected: OAuth credentials must "
36
+ f"not flow in cleartext. Use https:// (e.g. via ngrok), or set AUTH_MODE=disabled."
37
+ )
38
+
39
+ return auth_mode
docker_devkit/py.typed ADDED
File without changes
docker_devkit/up.py ADDED
@@ -0,0 +1,111 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import typer
5
+ from bashrun import bash_handoff
6
+ from .detect_gpu import Gpu, detect_gpu
7
+
8
+ from .build_docker import run_build
9
+ from .context_sha import compute_service_shas
10
+ from .modes import resolve_auth_mode
11
+
12
+ ENV_FILE = Path(".env")
13
+ LOCK_FILE = Path(".env.lock")
14
+ BAKE_FILE = Path("compose.bake.yml")
15
+
16
+
17
+ def _resolve_service_shas() -> None:
18
+ os.environ.update(compute_service_shas(Path.cwd(), BAKE_FILE))
19
+
20
+
21
+ app = typer.Typer(add_completion=False)
22
+
23
+
24
+ @app.command()
25
+ def up(
26
+ attached: bool = typer.Option(False, "--attached", "-a", help="Run in foreground (not detached)"),
27
+ quiet_pull: bool = typer.Option(
28
+ False,
29
+ "--quiet-pull",
30
+ "-q",
31
+ help="Suppress per-layer pull progress (still shows pull/push totals).",
32
+ ),
33
+ build: bool = typer.Option(
34
+ False, "--build", help="Build all images locally before bringing the stack up; skips pulling"
35
+ ),
36
+ gpu: Gpu = typer.Option("auto", "--gpu", help="auto|cuda|rocm|none"),
37
+ no_dev: bool = typer.Option(False, "--no-dev", help="Skip layering compose.dev.yml (production-shape bring-up)"),
38
+ compose_file: Path = typer.Option(
39
+ Path("compose.yml"),
40
+ "--compose-file",
41
+ help=(
42
+ "Base compose file. In a repo that authors its own images (where compose.bake.yml lives) the default "
43
+ "compose.yml triggers the native multi-file assembly. A consumer stack — a repo whose compose.yml "
44
+ "OCI-pulls an already-baked upstream artifact and layers on top — is run as the complete graph with "
45
+ "only --env-file .env."
46
+ ),
47
+ ),
48
+ ) -> None:
49
+ # A repo that authors its own stack carries compose.bake.yml and builds its own images,
50
+ # so the default compose.yml means the native multi-file stack (postgres + gpu + dev layers,
51
+ # per-service SHA injection, .env.lock). A consumer repo has no bake file: its
52
+ # --compose-file is the whole graph (the upstream stack arrives baked via OCI include or a
53
+ # sibling-checkout include), so SHA resolution and .env.lock don't apply.
54
+ native = compose_file == Path("compose.yml") and BAKE_FILE.exists()
55
+
56
+ if not ENV_FILE.exists():
57
+ raise RuntimeError("No .env file found; create one first (e.g., copy .env.example)")
58
+
59
+ if native and not LOCK_FILE.exists():
60
+ raise RuntimeError("No lock file found; run 'uv run build --lock-only' first")
61
+
62
+ if build and not native:
63
+ raise typer.BadParameter(
64
+ "--build is only supported for the native stack (compose.bake.yml present); a consumer stack "
65
+ "consumes images from an OCI-included upstream artifact and has no local build graph."
66
+ )
67
+
68
+ if gpu == "auto":
69
+ gpu = detect_gpu()
70
+
71
+ auth_mode = resolve_auth_mode(ENV_FILE)
72
+
73
+ if build:
74
+ run_build(gpu=gpu)
75
+
76
+ if BAKE_FILE.exists():
77
+ _resolve_service_shas()
78
+
79
+ profile_flag = "--profile keycloak " if auth_mode == "keycloak" else ""
80
+ if native:
81
+ gpu_file = f"-f compose.{gpu}.yml " if gpu != "none" else ""
82
+ dev_file = "" if no_dev else "-f compose.dev.yml "
83
+ compose_args = (
84
+ f"-f compose.yml -f compose.postgres.yml {gpu_file}{dev_file}{profile_flag}"
85
+ f"--env-file .env --env-file {LOCK_FILE}"
86
+ )
87
+ else:
88
+ lock_flag = f"--env-file {LOCK_FILE} " if LOCK_FILE.exists() else ""
89
+ compose_args = f"-f {compose_file} {profile_flag}--env-file .env {lock_flag}".rstrip()
90
+
91
+ up_command = f"docker compose {compose_args} up"
92
+ if not build:
93
+ # tree-<sha> tags are immutable (derived from dockerignore-allowlisted
94
+ # context), so a local hit is byte-identical to what the registry would
95
+ # serve. --pull missing skips locally-present tags, avoiding hard errors
96
+ # on images built locally but not yet pushed.
97
+ up_command += " --pull missing"
98
+ if quiet_pull:
99
+ up_command += " --quiet-pull"
100
+ if not attached:
101
+ up_command += " -d"
102
+
103
+ bash_handoff(up_command)
104
+
105
+
106
+ def main():
107
+ app()
108
+
109
+
110
+ if __name__ == "__main__":
111
+ main()
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.5
2
+ Name: docker-devkit
3
+ Version: 0.1.0
4
+ Summary: Docker-stack lifecycle commands (up/down/build) with a native/consumer split
5
+ License-File: LICENSE
6
+ License-File: NOTICE
7
+ Requires-Python: >=3.13
8
+ Requires-Dist: bashrun>=0.1.0
9
+ Requires-Dist: pathspec>=1.0.4
10
+ Requires-Dist: pydantic-settings>=2.9.1
11
+ Requires-Dist: pydantic>=2.11.7
12
+ Requires-Dist: pyyaml>=6.0
13
+ Requires-Dist: typer>=0.17.4
@@ -0,0 +1,15 @@
1
+ docker_devkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ docker_devkit/build_docker.py,sha256=DHv2hbnUPENyZVbmyjW5AZoVmoL-VMNPakAD37CMS_g,11857
3
+ docker_devkit/context_sha.py,sha256=KWwJtIKfgKkogYoPL7_KEcKX8XG3i-P6_ReIOkB5wE4,3085
4
+ docker_devkit/detect_gpu.py,sha256=V7X-eu-q0HrJo_rFmviOor62tm1yKjR2PX2RLnv7JBw,451
5
+ docker_devkit/down.py,sha256=IMl-sjsLfa53sETcss6mEiAGEUhNIo3jYvKHg-t3xqA,2669
6
+ docker_devkit/image_refs.py,sha256=PxYDVLkP43Gmc2Qh-R5AnpwYqkaZFD-uvAE-hWpJlho,6436
7
+ docker_devkit/modes.py,sha256=-6mNyvu3G97PzJ2vsfnXr5LwQhjvhlDfd11u6rkhN6M,1510
8
+ docker_devkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ docker_devkit/up.py,sha256=_8oZY0DBCC4mroWPjFC6wPIW0raPPwUXFMRoCFU57Cs,4082
10
+ docker_devkit-0.1.0.dist-info/METADATA,sha256=q6uY1zs7LxQJ-BK72wvJGxsdMmiAhdaE-PBHPTyZHww,399
11
+ docker_devkit-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
12
+ docker_devkit-0.1.0.dist-info/entry_points.txt,sha256=0AJlYxdEuQ7w21s1y-07MJ4AU_aJBUfkVWrwrxCqaMI,113
13
+ docker_devkit-0.1.0.dist-info/licenses/LICENSE,sha256=RFhQPdSOiMTguUX7JSoIuTxA7HVzCbj_p8WU36HjUQQ,10947
14
+ docker_devkit-0.1.0.dist-info/licenses/NOTICE,sha256=jvglZza3GCdN7v4_TLuXUqX9C_uABlwAKUkcIeKwk_8,26
15
+ docker_devkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ build = docker_devkit.build_docker:app
3
+ down = docker_devkit.down:app
4
+ up = docker_devkit.up:app
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ Copyright 2026 Tyler Hatch