Build a Dockerfile and return the local Docker tag. Package-managed local gateways use the same Docker daemon that the CLI builds into, so the tag is passed through directly and the active compute driver resolves it.
(
dockerfile: &Path,
context: &Path,
gateway_name: &str,
)
| 2500 | /// builds into, so the tag is passed through directly and the active compute |
| 2501 | /// driver resolves it. |
| 2502 | async fn build_from_dockerfile( |
| 2503 | dockerfile: &Path, |
| 2504 | context: &Path, |
| 2505 | gateway_name: &str, |
| 2506 | ) -> Result<String> { |
| 2507 | let metadata = get_gateway_metadata(gateway_name); |
| 2508 | if !dockerfile_sources_supported_for_gateway(metadata.as_ref()) { |
| 2509 | return Err(miette!( |
| 2510 | "local Dockerfile sources are only supported for local gateways; gateway '{}' is remote", |
| 2511 | gateway_name |
| 2512 | )); |
| 2513 | } |
| 2514 | |
| 2515 | let timestamp = std::time::SystemTime::now() |
| 2516 | .duration_since(std::time::UNIX_EPOCH) |
| 2517 | .unwrap_or_default() |
| 2518 | .as_secs(); |
| 2519 | let tag = format!("openshell/sandbox-from:{timestamp}"); |
| 2520 | |
| 2521 | eprintln!( |
| 2522 | "Building image {} from {}", |
| 2523 | tag.cyan(), |
| 2524 | dockerfile.display() |
| 2525 | ); |
| 2526 | eprintln!(" {} {}", "Context:".dimmed(), context.display()); |
| 2527 | eprintln!(" {} {}", "Gateway:".dimmed(), gateway_name); |
| 2528 | eprintln!(); |
| 2529 | |
| 2530 | let mut on_log = |msg: String| { |
| 2531 | eprintln!(" {msg}"); |
| 2532 | }; |
| 2533 | |
| 2534 | openshell_bootstrap::build::build_local_image( |
| 2535 | dockerfile, |
| 2536 | &tag, |
| 2537 | context, |
| 2538 | &HashMap::new(), |
| 2539 | &mut on_log, |
| 2540 | ) |
| 2541 | .await?; |
| 2542 | |
| 2543 | eprintln!(); |
| 2544 | eprintln!( |
| 2545 | "{} Image {} is available in the local Docker daemon for gateway '{}'.", |
| 2546 | "✓".green().bold(), |
| 2547 | tag.cyan(), |
| 2548 | gateway_name, |
| 2549 | ); |
| 2550 | eprintln!(); |
| 2551 | |
| 2552 | Ok(tag) |
| 2553 | } |
| 2554 | |
| 2555 | /// Load sandbox policy YAML. |
| 2556 | /// |
no test coverage detected