anchor 0.1.3

A Rust library for managing Docker container clusters through declarative JSON manifests
Documentation
use anchor::prelude::{Client, ResourceStatus, get_ecr_credentials};
use std::error::Error;

const IMAGE_REF: &str = "939027885851.dkr.ecr.eu-west-2.amazonaws.com/uncertainty-engine-add-node:latest";
const CONTAINER_NAME: &str = "node-add";

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let credentials = get_ecr_credentials().await?;
    let client = Client::new(credentials).await?;

    let status = client.get_resource_status(IMAGE_REF, CONTAINER_NAME).await?;
    match status {
        ResourceStatus::Running => {
            client.stop_container(CONTAINER_NAME).await?;
            println!("Container {CONTAINER_NAME} stopped successfully.");
        }
        _ => {
            println!("Container is not running.");
        }
    }

    Ok(())
}