Search in sources :

Example 1 with DockerConfiguration

use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.

the class BuildImageMojo method buildImage.

private void buildImage() throws MojoExecutionException {
    Libraries libraries = getLibraries(Collections.emptySet());
    try {
        DockerConfiguration dockerConfiguration = (this.docker != null) ? this.docker.asDockerConfiguration() : null;
        BuildRequest request = getBuildRequest(libraries);
        Builder builder = new Builder(new MojoBuildLog(this::getLog), dockerConfiguration);
        builder.build(request);
    } catch (IOException ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Builder(org.springframework.boot.buildpack.platform.build.Builder) Libraries(org.springframework.boot.loader.tools.Libraries) IOException(java.io.IOException) BuildRequest(org.springframework.boot.buildpack.platform.build.BuildRequest)

Example 2 with DockerConfiguration

use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.

the class Docker method asDockerConfiguration.

/**
 * Returns this configuration as a {@link DockerConfiguration} instance. This method
 * should only be called when the configuration is complete and will no longer be
 * changed.
 * @return the Docker configuration
 */
DockerConfiguration asDockerConfiguration() {
    DockerConfiguration dockerConfiguration = new DockerConfiguration();
    dockerConfiguration = customizeHost(dockerConfiguration);
    dockerConfiguration = customizeBuilderAuthentication(dockerConfiguration);
    dockerConfiguration = customizePublishAuthentication(dockerConfiguration);
    return dockerConfiguration;
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration)

Example 3 with DockerConfiguration

use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.

the class DockerSpecTests method asDockerConfigurationWithTokenAuth.

@Test
void asDockerConfigurationWithTokenAuth() {
    DockerSpec dockerSpec = new DockerSpec(new DockerSpec.DockerRegistrySpec("token1"), new DockerSpec.DockerRegistrySpec("token2"));
    DockerConfiguration dockerConfiguration = dockerSpec.asDockerConfiguration();
    assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())).contains("\"identitytoken\" : \"token1\"");
    assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader())).contains("\"identitytoken\" : \"token2\"");
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with DockerConfiguration

use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.

the class DockerSpecTests method asDockerConfigurationWithUserAuth.

@Test
void asDockerConfigurationWithUserAuth() {
    DockerSpec dockerSpec = new DockerSpec(new DockerSpec.DockerRegistrySpec("user1", "secret1", "https://docker1.example.com", "docker1@example.com"), new DockerSpec.DockerRegistrySpec("user2", "secret2", "https://docker2.example.com", "docker2@example.com"));
    DockerConfiguration dockerConfiguration = dockerSpec.asDockerConfiguration();
    assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())).contains("\"username\" : \"user1\"").contains("\"password\" : \"secret1\"").contains("\"email\" : \"docker1@example.com\"").contains("\"serveraddress\" : \"https://docker1.example.com\"");
    assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader())).contains("\"username\" : \"user2\"").contains("\"password\" : \"secret2\"").contains("\"email\" : \"docker2@example.com\"").contains("\"serveraddress\" : \"https://docker2.example.com\"");
    assertThat(dockerSpec.asDockerConfiguration().getHost()).isNull();
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) Test(org.junit.jupiter.api.Test)

Example 5 with DockerConfiguration

use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.

the class DockerSpecTests method asDockerConfigurationWithHostConfiguration.

@Test
void asDockerConfigurationWithHostConfiguration() {
    DockerSpec dockerSpec = new DockerSpec();
    dockerSpec.setHost("docker.example.com");
    dockerSpec.setTlsVerify(true);
    dockerSpec.setCertPath("/tmp/ca-cert");
    DockerConfiguration dockerConfiguration = dockerSpec.asDockerConfiguration();
    DockerHost host = dockerConfiguration.getHost();
    assertThat(host.getAddress()).isEqualTo("docker.example.com");
    assertThat(host.isSecure()).isEqualTo(true);
    assertThat(host.getCertificatePath()).isEqualTo("/tmp/ca-cert");
    assertThat(dockerSpec.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
    assertThat(dockerSpec.asDockerConfiguration().getPublishRegistryAuthentication()).isNull();
}
Also used : DockerConfiguration(org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration) DockerHost(org.springframework.boot.buildpack.platform.docker.configuration.DockerHost) Test(org.junit.jupiter.api.Test)

Aggregations

DockerConfiguration (org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration)14 Test (org.junit.jupiter.api.Test)11 DockerApi (org.springframework.boot.buildpack.platform.docker.DockerApi)4 Image (org.springframework.boot.buildpack.platform.docker.type.Image)4 DockerHost (org.springframework.boot.buildpack.platform.docker.configuration.DockerHost)3 ImageArchive (org.springframework.boot.buildpack.platform.docker.type.ImageArchive)2 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 BuildRequest (org.springframework.boot.buildpack.platform.build.BuildRequest)1 Builder (org.springframework.boot.buildpack.platform.build.Builder)1 Libraries (org.springframework.boot.loader.tools.Libraries)1