...
This commit is contained in:
parent
c0df07d6df
commit
49c879359b
@ -121,16 +121,16 @@ println(`Using local image: ${local_image_name}`);
|
|||||||
|
|
||||||
// Tag the image with the localhost prefix for nerdctl compatibility
|
// Tag the image with the localhost prefix for nerdctl compatibility
|
||||||
println(`Tagging image as ${local_image_name}...`);
|
println(`Tagging image as ${local_image_name}...`);
|
||||||
let tag_result = bah_image_tag(final_image_name, local_image_name);
|
let tag_result = image_tag(final_image_name, local_image_name);
|
||||||
|
|
||||||
// Print a command to check if the image exists in buildah
|
// Print a command to check if the image exists in buildah
|
||||||
println("\nTo verify the image was created with buildah, run:");
|
println("\nTo verify the image was created with buildah, run:");
|
||||||
println("buildah images");
|
println("buildah images");
|
||||||
|
|
||||||
// Note: If nerdctl cannot find the image, you may need to push it to a registry
|
// Note: If nerdctl cannot find the image, you may need to push it to a registry
|
||||||
println("\nNote: If nerdctl cannot find the image, you may need to push it to a registry:");
|
// println("\nNote: If nerdctl cannot find the image, you may need to push it to a registry:");
|
||||||
println("buildah push localhost/custom-golang-nginx:latest docker://localhost:5000/custom-golang-nginx:latest");
|
// println("buildah push localhost/custom-golang-nginx:latest docker://localhost:5000/custom-golang-nginx:latest");
|
||||||
println("nerdctl pull localhost:5000/custom-golang-nginx:latest");
|
// println("nerdctl pull localhost:5000/custom-golang-nginx:latest");
|
||||||
|
|
||||||
let container = nerdctl_container_from_image("golang-nginx-demo", local_image_name)
|
let container = nerdctl_container_from_image("golang-nginx-demo", local_image_name)
|
||||||
.with_detach(true)
|
.with_detach(true)
|
||||||
|
44
examples/containers/buildah_run.rhai
Normal file
44
examples/containers/buildah_run.rhai
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
// Now use nerdctl to run a container from the new image
|
||||||
|
println("\nStarting container from the new image using nerdctl...");
|
||||||
|
|
||||||
|
// Create a container using the builder pattern
|
||||||
|
// Use localhost/ prefix to ensure nerdctl uses the local image
|
||||||
|
let local_image_name = "localhost/custom-golang-nginx:latest";
|
||||||
|
println(`Using local image: ${local_image_name}`);
|
||||||
|
|
||||||
|
// Import the image from buildah to nerdctl
|
||||||
|
println("Importing image from buildah to nerdctl...");
|
||||||
|
process_run("buildah", ["push", "custom-golang-nginx:latest", "docker-daemon:custom-golang-nginx:latest"]);
|
||||||
|
|
||||||
|
let tag_result = nerdctl_image_tag("custom-golang-nginx:latest", local_image_name);
|
||||||
|
|
||||||
|
// Tag the image with the localhost prefix for nerdctl compatibility
|
||||||
|
// println(`Tagging image as ${local_image_name}...`);
|
||||||
|
// let tag_result = bah_image_tag(final_image_name, local_image_name);
|
||||||
|
|
||||||
|
// Print a command to check if the image exists in buildah
|
||||||
|
println("\nTo verify the image was created with buildah, run:");
|
||||||
|
println("buildah images");
|
||||||
|
|
||||||
|
// Note: If nerdctl cannot find the image, you may need to push it to a registry
|
||||||
|
// println("\nNote: If nerdctl cannot find the image, you may need to push it to a registry:");
|
||||||
|
// println("buildah push localhost/custom-golang-nginx:latest docker://localhost:5000/custom-golang-nginx:latest");
|
||||||
|
// println("nerdctl pull localhost:5000/custom-golang-nginx:latest");
|
||||||
|
|
||||||
|
let container = nerdctl_container_from_image("golang-nginx-demo", local_image_name)
|
||||||
|
.with_detach(true)
|
||||||
|
.with_port("8081:80") // Map port 80 in the container to 8080 on the host
|
||||||
|
.with_restart_policy("unless-stopped")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Start the container
|
||||||
|
let start_result = container.start();
|
||||||
|
|
||||||
|
println("\nWorkflow completed successfully!");
|
||||||
|
println("The web server should be running at http://localhost:8081");
|
||||||
|
println("You can check container logs with: nerdctl logs golang-nginx-demo");
|
||||||
|
println("To stop the container: nerdctl stop golang-nginx-demo");
|
||||||
|
println("To remove the container: nerdctl rm golang-nginx-demo");
|
||||||
|
|
||||||
|
"Buildah and nerdctl workflow completed successfully!"
|
41
examples/zinit/zinit_basic2.rhai
Normal file
41
examples/zinit/zinit_basic2.rhai
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Basic example of using the Zinit client in Rhai
|
||||||
|
|
||||||
|
// Socket path for Zinit
|
||||||
|
let socket_path = "/tmp/zinit.sock";
|
||||||
|
|
||||||
|
// Create a new service
|
||||||
|
print("\nCreating a new service:");
|
||||||
|
let new_service = "rhai-test-service";
|
||||||
|
let exec_command = "echo 'Hello from Rhai'";
|
||||||
|
let oneshot = true;
|
||||||
|
|
||||||
|
let result = zinit_create_service(socket_path, new_service, exec_command, oneshot);
|
||||||
|
print(`Service created: ${result}`);
|
||||||
|
|
||||||
|
// Monitor the service
|
||||||
|
print("\nMonitoring the service:");
|
||||||
|
let monitor_result = zinit_monitor(socket_path, new_service);
|
||||||
|
print(`Service monitored: ${monitor_result}`);
|
||||||
|
|
||||||
|
// Start the service
|
||||||
|
print("\nStarting the service:");
|
||||||
|
let start_result = zinit_start(socket_path, new_service);
|
||||||
|
print(`Service started: ${start_result}`);
|
||||||
|
|
||||||
|
// Get logs for a specific service
|
||||||
|
print("\nGetting logs:");
|
||||||
|
let logs = zinit_logs(socket_path, new_service);
|
||||||
|
|
||||||
|
for log in logs {
|
||||||
|
print(log);
|
||||||
|
}
|
||||||
|
// Clean up
|
||||||
|
print("\nCleaning up:");
|
||||||
|
let stop_result = zinit_stop(socket_path, new_service);
|
||||||
|
print(`Service stopped: ${stop_result}`);
|
||||||
|
|
||||||
|
let forget_result = zinit_forget(socket_path, new_service);
|
||||||
|
print(`Service forgotten: ${forget_result}`);
|
||||||
|
|
||||||
|
let delete_result = zinit_delete_service(socket_path, new_service);
|
||||||
|
print(`Service deleted: ${delete_result}`);
|
@ -14,6 +14,9 @@ fn nerdctl_download(){
|
|||||||
copy_bin(`/tmp/${name}/bin/*`);
|
copy_bin(`/tmp/${name}/bin/*`);
|
||||||
delete(`/tmp/${name}`);
|
delete(`/tmp/${name}`);
|
||||||
|
|
||||||
|
screen_kill("containerd");
|
||||||
|
screen_new("containerd", "containerd");
|
||||||
|
|
||||||
package_install("buildah");
|
package_install("buildah");
|
||||||
package_install("runc");
|
package_install("runc");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user