Search in sources :

Example 51 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.

the class BuildService method tagImage.

public void tagImage(ImageConfiguration imageConfig) throws DockerAccessException {
    List<String> tags = imageConfig.getBuildConfiguration().getTags();
    if (!tags.isEmpty()) {
        String imageName = imageConfig.getName();
        log.info("%s: Tag with %s", imageConfig.getDescription(), EnvUtil.stringJoin(tags, ","));
        BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
        for (String tag : tags) {
            tagImage(imageName, tag, null, buildConfig.cleanupMode());
        }
    }
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Example 52 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project docker-maven-plugin by fabric8io.

the class RegistryService method pushImages.

/**
 * Push a set of images to a registry
 *
 * @param imageConfigs images to push (but only if they have a build configuration)
 * @param retries how often to retry
 * @param registryConfig a global registry configuration
 * @param skipTag flag to skip pushing tagged images
 * @throws DockerAccessException
 * @throws MojoExecutionException
 */
public void pushImages(Collection<ImageConfiguration> imageConfigs, int retries, RegistryConfig registryConfig, boolean skipTag) throws DockerAccessException, MojoExecutionException {
    for (ImageConfiguration imageConfig : imageConfigs) {
        BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
        String name = imageConfig.getName();
        if (buildConfig != null) {
            if (buildConfig.skipPush()) {
                log.info("%s : Skipped pushing", imageConfig.getDescription());
                continue;
            }
            String configuredRegistry = EnvUtil.firstRegistryOf(new ImageName(imageConfig.getName()).getRegistry(), imageConfig.getRegistry(), registryConfig.getRegistry());
            AuthConfig authConfig = createAuthConfig(true, new ImageName(name).getUser(), configuredRegistry, registryConfig);
            long start = System.currentTimeMillis();
            docker.pushImage(name, authConfig, configuredRegistry, retries);
            log.info("Pushed %s in %s", name, EnvUtil.formatDurationTill(start));
            if (!skipTag) {
                for (String tag : imageConfig.getBuildConfiguration().getTags()) {
                    if (tag != null) {
                        docker.pushImage(new ImageName(name, tag).getFullName(), authConfig, configuredRegistry, retries);
                    }
                }
            }
        }
    }
}
Also used : ImageName(io.fabric8.maven.docker.util.ImageName) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration)

Example 53 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project ballerina by ballerina-lang.

the class DefaultBallerinaDockerClient method getImage.

/**
 * {@inheritDoc}
 */
@Override
public String getImage(String imageName, String dockerEnv) {
    DockerClient client = getDockerClient(dockerEnv);
    List<Image> images = client.image().list().filter(imageName).endImages();
    // No images found?
    if (images == null || images.size() < 1) {
        return null;
    }
    for (Image image : images) {
        // Invalid tags found?
        if (image.getRepoTags() == null) {
            continue;
        }
        String currentImageName = image.getRepoTags().get(0);
        if (currentImageName.equals(imageName + ":" + Constants.IMAGE_VERSION_LATEST) || currentImageName.equals(imageName)) {
            return currentImageName;
        }
    }
    return null;
}
Also used : DockerClient(io.fabric8.docker.client.DockerClient) BallerinaDockerClient(org.ballerinalang.containers.docker.BallerinaDockerClient) Image(io.fabric8.docker.api.model.Image)

Aggregations

ImageName (io.fabric8.maven.docker.util.ImageName)20 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 File (java.io.File)9 IOException (java.io.IOException)7 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)7 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)6 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 CopyConfiguration (io.fabric8.maven.docker.config.CopyConfiguration)4 Container (io.fabric8.maven.docker.model.Container)4 Test (org.junit.Test)4 DockerClient (io.fabric8.docker.client.DockerClient)3 Container (io.fabric8.kubernetes.api.model.Container)3 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)3 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)3 ArrayList (java.util.ArrayList)3 Controller (io.fabric8.kubernetes.api.Controller)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)2 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)2