Skip to content

Commit 666f68e

Browse files
committed
Document configuration for building images with Colima
Closes gh-34522
1 parent 9a23e13 commit 666f68e

File tree

6 files changed

+107
-1
lines changed

6 files changed

+107
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,26 @@ include::../gradle/packaging/boot-build-image-docker-host-podman.gradle.kts[tags
463463

464464
TIP: With the `podman` CLI installed, the command `podman info --format='{{.Host.RemoteSocket.Path}}'` can be used to get the value for the `docker.host` configuration property shown in this example.
465465

466+
[[build-image.examples.docker.colima]]
467+
==== Docker Configuration for Colima
468+
469+
The plugin can communicate with the Docker daemon provided by https://github.com/abiosoft/colima[Colima].
470+
The `DOCKER_HOST` environment variable can be set by using the command `export DOCKER_HOST=$(docker context inspect colima -f '{{.Endpoints.docker.Host}}').`
471+
472+
The plugin can also be configured to use Colima daemon by providing connection details similar to those shown in the following example:
473+
474+
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
475+
.Groovy
476+
----
477+
include::../gradle/packaging/boot-build-image-docker-host-colima.gradle[tags=docker-host]
478+
----
479+
480+
[source,kotlin,indent=0,subs="verbatim,attributes",role="secondary"]
481+
.Kotlin
482+
----
483+
include::../gradle/packaging/boot-build-image-docker-host-colima.gradle.kts[tags=docker-host]
484+
----
485+
466486
[[build-image.examples.docker.auth]]
467487
==== Docker Configuration for Authentication
468488

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
plugins {
2+
id 'java'
3+
id 'org.springframework.boot' version '{gradle-project-version}'
4+
}
5+
6+
tasks.named("bootJar") {
7+
mainClass = 'com.example.ExampleApplication'
8+
}
9+
10+
// tag::docker-host[]
11+
tasks.named("bootBuildImage") {
12+
docker {
13+
host = "unix://${System.properties['user.home']}/.colima/docker.sock"
14+
}
15+
}
16+
// end::docker-host[]
17+
18+
tasks.register("bootBuildImageDocker") {
19+
doFirst {
20+
println("host=${tasks.bootBuildImage.docker.host}")
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootJar
2+
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
3+
4+
plugins {
5+
java
6+
id("org.springframework.boot") version "{gradle-project-version}"
7+
}
8+
9+
tasks.named<BootJar>("bootJar") {
10+
mainClass.set("com.example.ExampleApplication")
11+
}
12+
13+
// tag::docker-host[]
14+
tasks.named<BootBuildImage>("bootBuildImage") {
15+
docker {
16+
host = "unix://${System.getProperty("user.home")}/.colima/docker.sock"
17+
}
18+
}
19+
// end::docker-host[]
20+
21+
tasks.register("bootBuildImageDocker") {
22+
doFirst {
23+
println("host=${tasks.getByName<BootBuildImage>("bootBuildImage").docker.host}")
24+
}
25+
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/PackagingDocumentationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ void bootBuildImageWithDockerHostPodman() {
299299
.contains("bindHostToBuilder=true");
300300
}
301301

302+
@TestTemplate
303+
void bootBuildImageWithDockerHostColima() {
304+
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-host-colima")
305+
.build("bootBuildImageDocker");
306+
assertThat(result.getOutput())
307+
.contains("host=unix://" + System.getProperty("user.home") + "/.colima/docker.sock");
308+
}
309+
302310
@TestTemplate
303311
void bootBuildImageWithDockerUserAuth() {
304312
BuildResult result = this.gradleBuild.script("src/docs/gradle/packaging/boot-build-image-docker-auth-user")

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,20 @@ The plugin can be configured to use podman local connection by providing connect
415415
include::../maven/packaging-oci-image/docker-podman-pom.xml[tags=docker-podman]
416416
----
417417

418-
TIP: With the `podman` CLI installed, the command `podman info --format='{{.Host.RemoteSocket.Path}}'` can be used to get the value for the `docker.host` configuration property shown in this example.
418+
TIP: With the `colima` CLI installed, the command `podman info --format='{{.Host.RemoteSocket.Path}}'` can be used to get the value for the `docker.host` configuration property shown in this example.
419+
420+
[[build-image.examples.docker.colima]]
421+
==== Docker Configuration for Colima
422+
423+
The plugin can communicate with the Docker daemon provided by https://github.com/abiosoft/colima[Colima].
424+
The `DOCKER_HOST` environment variable can be set by using the command `export DOCKER_HOST=$(docker context inspect colima -f '{{.Endpoints.docker.Host}}').`
425+
426+
The plugin can also be configured to use Colima daemon by providing connection details similar to those shown in the following example:
427+
428+
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]
429+
----
430+
include::../maven/packaging-oci-image/docker-colima-pom.xml[tags=docker-colima]
431+
----
419432

420433
[[build-image.examples.docker.auth]]
421434
==== Docker Configuration for Authentication
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- tag::docker-colima[] -->
3+
<project>
4+
<build>
5+
<plugins>
6+
<plugin>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-maven-plugin</artifactId>
9+
<configuration>
10+
<docker>
11+
<host>unix:///${user.home}/.colima/docker.sock</host>
12+
</docker>
13+
</configuration>
14+
</plugin>
15+
</plugins>
16+
</build>
17+
</project>
18+
<!-- end::docker-colima[] -->

0 commit comments

Comments
 (0)