fix: Allow docker driver to properly use cache (#126)

This fix involves creating a new function for the `BuildDriver` trait
called `build_tag_push`. In order to get the proper logic in place to
make use of `docker buildx`, I had to create a separate function that
would construct the build command to include all of the tags necessary
for pushing. A default implementation of `build_tag_push` will be used
for `podman` and `buildah` which was originally from the build command's
functions. Now that we have custom logic for docker builds, we can take
advantage of using the GitHub cache features without having the `--load`
arg which had a big negative effect on build times. We can now also use
docker for creating local `oci-archive` tarballs for local rebasing.
Making use of the `oci-archive` will require the user to create a
`docker-container` builder as it is not supported on the standard
`docker` builder.

https://docs.docker.com/build/exporters/oci-docker/
This commit is contained in:
Gerald Pinder 2024-03-19 16:51:09 -04:00 committed by GitHub
parent 5fc4096f0f
commit 7c34d0c5a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 304 additions and 193 deletions

View file

@ -6,7 +6,7 @@ use log::{debug, info, trace};
use semver::Version;
use serde::Deserialize;
use crate::image_inspection::ImageInspection;
use crate::image_metadata::ImageMetadata;
use super::{credentials, BuildDriver, DriverVersion, InspectDriver};
@ -107,14 +107,14 @@ impl BuildDriver for PodmanDriver {
if !output.status.success() {
let err_out = String::from_utf8_lossy(&output.stderr);
bail!("Failed to login for buildah: {err_out}");
bail!("Failed to login for podman: {err_out}");
}
Ok(())
}
}
impl InspectDriver for PodmanDriver {
fn get_labels(&self, image_name: &str, tag: &str) -> Result<ImageInspection> {
fn get_metadata(&self, image_name: &str, tag: &str) -> Result<ImageMetadata> {
let url = format!("docker://{image_name}:{tag}");
trace!("podman run {SKOPEO_IMAGE} inspect {url}");