Examples of DockerClient


Examples of com.kpelykh.docker.client.DockerClient

    final Properties properties = properties();

    getLog().info("properties filtering supported for " + properties.keySet());

    try {
      final DockerClient docker = dockerClient();
      getLog().info("Docker version " + docker.version().getVersion());
      doExecute(new DockerOrchestrator(docker, src(), workDir(), prefix, credentials(),
          TextFileFilter.INSTANCE, properties));
    } catch (Exception e) {
      throw new MojoExecutionException(e.getMessage(), e);
    }
View Full Code Here

Examples of com.kpelykh.docker.client.DockerClient

    }
  }

  private DockerClient dockerClient() throws DockerException {
    return version != null
        ? new DockerClient(host.toString(), version)
        : new DockerClient(host.toString());
  }
View Full Code Here

Examples of com.kpelykh.docker.client.DockerClient

    this(docker, new Repo(docker, prefix, src), new FileOrchestrator(workDir, rootDir, filter, properties), credentials, buildFlags);
  }

  private static DockerClient defaultDockerClient() {
        try {
            return new DockerClient();
        } catch (DockerException e) {
            throw new OrchestrationException(e);
        }
    }
View Full Code Here

Examples of com.kpelykh.docker.client.DockerClient

        final Properties properties = properties();

        getLog().info("properties filtering supported for " + properties.keySet());

        try {
            final DockerClient docker = dockerClient();
            getLog().info("Docker version " + docker.version().getVersion());
            doExecute(new DockerOrchestrator(docker, src(), workDir(), projDir(), prefix, credentials(),
                    TextFileFilter.INSTANCE, properties, buildFlags()));
        } catch (Exception e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
View Full Code Here

Examples of com.kpelykh.docker.client.DockerClient

    return removeIntermediateImages ? EnumSet.of(BuildFlag.REMOVE_INTERMEDIATE_IMAGES) : EnumSet.noneOf(BuildFlag.class);
  }

  private DockerClient dockerClient() throws DockerException {
        return version != null
                ? new DockerClient(host.toString(), version)
                : new DockerClient(host.toString());
    }
View Full Code Here

Examples of com.kpelykh.docker.client.DockerClient

    this(defaultDockerClient(), src, workDir, prefix, credentials);
  }

  private static DockerClient defaultDockerClient() {
    try {
      return new DockerClient(DEFAULT_HOST);
    } catch (DockerException e) {
      throw new OrchestrationException(e);
    }
  }
View Full Code Here

Examples of com.nirima.docker.client.DockerClient

    }

    @Override
    public void execute(AbstractBuild<?, ?> build) throws DockerException {
        LOGGER.info("Stopping container " + containerId);
        DockerClient client = getClient(build);
        client.container(containerId).stop();
        getLaunchAction(build).stopped(client, containerId);
        if( remove )
            client.container(containerId).remove();
    }
View Full Code Here

Examples of com.nirima.docker.client.DockerClient

        DockerTemplate template = getCloud(build).getTemplate(templateId);

        String containerId = template.provisionNew().getId();

        LOGGER.info("Starting container " + containerId);
        DockerClient client = getClient(build);
        client.container(containerId).start();
        getLaunchAction(build).started(client, containerId);
    }
View Full Code Here

Examples of com.nirima.docker.client.DockerClient

    @Override
    public void execute(AbstractBuild<?, ?> build) throws DockerException {

        LOGGER.info("Starting container " + containerId);
        DockerClient client = getClient(build);
        client.container(containerId).start();
        getLaunchAction(build).started(client, containerId);

    }
View Full Code Here

Examples of com.nirima.docker.client.DockerClient

        FilePath fpChild = new FilePath(build.getWorkspace(), dockerFileDirectory);

        final String tagToUse = getTag(build, launcher, listener);
        final String url = getUrl(build);
        // Marshal the builder across the wire.
        DockerClient client = getDockerClient(build);
        final DockerClient.Builder builder = DockerClient.builder().fromClient(client);

        BuildCommandResponse response = fpChild.act(new FilePath.FileCallable<BuildCommandResponse>() {
            public BuildCommandResponse invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
                try {
                    listener.getLogger().println("Docker Build : build with tag " + tagToUse + " at path " + f.getAbsolutePath());
                    DockerClient client = builder
                            .readTimeout(3600000).build();

                    File dockerFile;

                    // Be lenient and allow the user to just specify the path.
                    if( f.isFile() )
                        dockerFile = f;
                    else
                        dockerFile = new File(f, "Dockerfile");

                    return client.createBuildCommand()
                            .dockerFile(dockerFile)
                            .tag(tagToUse)
                            .execute();

                } catch (DockerException e) {
                    throw Throwables.propagate(e);
                }

            }
        });


        listener.getLogger().println("Docker Build Response : " + response);

        Optional<String> id = response.imageId();
        if( !id.isPresent() )
           return false;

        build.addAction( new DockerBuildImageAction(url, id.get(), tagToUse, cleanupWithJenkinsJobDelete, pushOnSuccess) );
        build.save();


        if( pushOnSuccess ) {

            listener.getLogger().println("Pushing " + tagToUse);
            if( !tagToUse.toLowerCase().equals(tagToUse) ) {
                listener.getLogger().println("ERROR: Docker will refuse to push tag name " + tagToUse + " because it uses upper case.");
            }

            Identifier identifier = Identifier.fromCompoundString(tagToUse);

            String repositoryName = identifier.repository.name;

            PushCommandResponse pushResponse = client.createPushCommand()
                    .name(repositoryName)
                    .execute();

            listener.getLogger().println("Docker Push Response : " + pushResponse);
        }

        if (cleanImages) {

            // For some reason, docker delete doesn't delete all tagged
            // versions, despite force = true.
            // So, do it multiple times (protect against infinite looping).
            listener.getLogger().println("Cleaning local images");

            int delete = 100;
            while (delete != 0) {
                int count = client.image(id.get()).removeCommand()
                        .force(true)
                        .execute().size();
                if (count == 0)
                    delete = 0;
                else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.