Compare commits
3 Commits
ee8dfa4a93
...
d95e84d6fc
Author | SHA1 | Date | |
---|---|---|---|
d95e84d6fc | |||
a47be890de | |||
|
f7625f0484 |
@ -158,7 +158,7 @@ impl<
|
||||
let helm_chart = self.application.build_push_helm_package(&image).await?;
|
||||
info!("Pushed new helm chart {helm_chart}");
|
||||
|
||||
error!("TODO Make building image configurable/skippable");
|
||||
error!("TODO Make building image configurable/skippable if image already exists (prompt)");
|
||||
let image = self.application.build_push_oci_image().await?;
|
||||
info!("Pushed new docker image {image}");
|
||||
|
||||
|
@ -109,24 +109,20 @@ impl OCICompliant for RustWebapp {
|
||||
// It's async to match the trait definition, though the underlying docker commands are blocking.
|
||||
info!("Starting OCI image build and push for '{}'", self.name);
|
||||
|
||||
// 1. Build the local image by calling the synchronous helper function.
|
||||
let local_image_name = self.local_image_name();
|
||||
self.build_docker_image(&local_image_name)
|
||||
// 1. Build the image by calling the synchronous helper function.
|
||||
let image_tag = self.image_name();
|
||||
self.build_docker_image(&image_tag)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to build Docker image: {}", e))?;
|
||||
info!(
|
||||
"Successfully built local Docker image: {}",
|
||||
local_image_name
|
||||
);
|
||||
info!("Successfully built Docker image: {}", image_tag);
|
||||
|
||||
let remote_image_name = self.image_name();
|
||||
// 2. Push the image to the registry.
|
||||
self.push_docker_image(&local_image_name, &remote_image_name)
|
||||
self.push_docker_image(&image_tag)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to push Docker image: {}", e))?;
|
||||
info!("Successfully pushed Docker image to: {}", remote_image_name);
|
||||
info!("Successfully pushed Docker image to: {}", image_tag);
|
||||
|
||||
Ok(remote_image_name)
|
||||
Ok(image_tag)
|
||||
}
|
||||
|
||||
fn local_image_name(&self) -> String {
|
||||
@ -206,23 +202,25 @@ impl RustWebapp {
|
||||
/// Tags and pushes a Docker image to the configured remote registry.
|
||||
async fn push_docker_image(
|
||||
&self,
|
||||
image_name: &str,
|
||||
full_tag: &str,
|
||||
image_tag: &str,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
info!("Pushing docker image {full_tag}");
|
||||
info!("Pushing docker image {image_tag}");
|
||||
|
||||
let docker = Docker::connect_with_socket_defaults().unwrap();
|
||||
|
||||
// let push_options = PushImageOptionsBuilder::new().tag(tag);
|
||||
|
||||
let mut push_image_stream =
|
||||
docker.push_image(full_tag, Some(PushImageOptionsBuilder::new().build()), None);
|
||||
let mut push_image_stream = docker.push_image(
|
||||
image_tag,
|
||||
Some(PushImageOptionsBuilder::new().build()),
|
||||
None,
|
||||
);
|
||||
|
||||
while let Some(msg) = push_image_stream.next().await {
|
||||
println!("Message: {msg:?}");
|
||||
}
|
||||
|
||||
Ok(full_tag.to_string())
|
||||
Ok(image_tag.to_string())
|
||||
}
|
||||
|
||||
/// Checks the output of a process command for success.
|
||||
|
Loading…
Reference in New Issue
Block a user