This commit is contained in:
2025-04-04 21:51:31 +02:00
parent 5b006ff328
commit 9f33c94020
19 changed files with 1221 additions and 88 deletions

View File

@@ -20,13 +20,13 @@ pub fn run_buildah_example() -> Result<(), BuildahError> {
// Step 2: Run a command in the container
println!("\n=== Installing nginx in container ===");
// Use chroot isolation to avoid BPF issues
let install_result = buildah::run_with_isolation(container_id, "dnf install -y nginx", "chroot")?;
let install_result = buildah::bah_run_with_isolation(container_id, "dnf install -y nginx", "chroot")?;
println!("{:#?}", install_result);
println!("Installation output: {}", install_result.stdout);
// Step 3: Copy a file into the container
println!("\n=== Copying configuration file to container ===");
buildah::copy(container_id, "./example.conf", "/etc/example.conf").unwrap();
buildah::bah_copy(container_id, "./example.conf", "/etc/example.conf").unwrap();
// Step 4: Configure container metadata
println!("\n=== Configuring container metadata ===");
@@ -34,7 +34,7 @@ pub fn run_buildah_example() -> Result<(), BuildahError> {
config_options.insert("port".to_string(), "80".to_string());
config_options.insert("label".to_string(), "maintainer=example@example.com".to_string());
config_options.insert("entrypoint".to_string(), "/usr/sbin/nginx".to_string());
buildah::bah_config(container_id, config_options)?;
buildah::config(container_id, config_options)?;
println!("Container configured");
@@ -69,7 +69,7 @@ pub fn build_image_example() -> Result<(), BuildahError> {
println!("Building an image from a Containerfile...");
// Use the build function with tag, context directory, and isolation to avoid BPF issues
let result = buildah::build(Some("my-app:latest"), ".", "example_Dockerfile", Some("chroot"))?;
let result = buildah::bah_build(Some("my-app:latest"), ".", "example_Dockerfile", Some("chroot"))?;
println!("Build output: {}", result.stdout);
println!("Image built successfully!");

View File

@@ -2,8 +2,6 @@
//!
//! This example demonstrates how to use the Rhai scripting language
//! with the System Abstraction Layer (SAL) library.
use rhai::Engine;
use sal::rhai;
use sal::rhai::{self, Engine};
use std::fs;