Skip to content

Commit be745dc

Browse files
committed
Add a second README example to demonstrate outputs
Authored-by: Leonhardt Koepsell <[email protected]>
1 parent fa149c5 commit be745dc

File tree

1 file changed

+59
-2
lines changed

1 file changed

+59
-2
lines changed

README.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Container Gradle Plugin
22

3-
Container is a Gradle plugin that enhances build portability, reproducibility, and flexibility by integrating containers into Gradle tasks. It provides a declarative and familiar way to run task operations inside containers and declare containers as task inputs and outputs.
3+
Container is a Gradle plugin that enhances build portability, reproducibility, and flexibility by integrating containers
4+
into Gradle tasks. It provides a declarative and familiar way to run task operations inside containers and declare
5+
containers as task inputs and outputs.
46

57
## Status
68

7-
⚠️ **Experimental**: This project is currently in its early stages (version `0.x.x`). The API and features may change as we refine and improve the plugin. We're actively seeking feedback from early adopters to help shape its development.
9+
⚠️ **Experimental**: This project is currently in its early stages (version `0.x.x`). The API and features may change as
10+
we refine and improve the plugin. We're actively seeking feedback from early adopters to help shape its development.
811

912
## Features
1013

@@ -44,6 +47,60 @@ tasks {
4447
}
4548
```
4649

50+
Create tasks that produce images:
51+
52+
```kotlin
53+
import dev.codebandits.container.gradle.container
54+
import dev.codebandits.container.gradle.tasks.ContainerTask
55+
56+
tasks {
57+
register<ContainerTask>("buildWithDocker") {
58+
inputs.file("Dockerfile")
59+
container.outputs.localImage("docker-build-image:latest")
60+
dockerPull {
61+
image = "docker:dind"
62+
}
63+
dockerRun {
64+
image = "docker:dind"
65+
entrypoint = "docker"
66+
args = arrayOf("build", "-t", "docker-build-image:latest", ".")
67+
workdir = "/workdir"
68+
volumes = arrayOf(
69+
"${layout.projectDirectory}:/workdir",
70+
"/var/run/docker.sock:/var/run/docker.sock:ro",
71+
)
72+
}
73+
doLast {
74+
container.outputs.captureLocalImage("docker-build-image:latest")
75+
}
76+
}
77+
78+
register<ContainerTask>("buildImageWithPack") {
79+
inputs.file("index.html")
80+
inputs.file("project.toml")
81+
container.outputs.localImage("pack-build-image:latest")
82+
dockerPull {
83+
image = "buildpacksio/pack:latest"
84+
}
85+
dockerRun {
86+
image = "buildpacksio/pack:latest"
87+
args = arrayOf(
88+
"build", "pack-build-image:latest",
89+
"--builder", "paketobuildpacks/builder-jammy-base:latest",
90+
)
91+
workdir = "/workdir"
92+
volumes = arrayOf(
93+
"${layout.projectDirectory}:/workdir",
94+
"/var/run/docker.sock:/var/run/docker.sock:ro",
95+
)
96+
}
97+
doLast {
98+
container.outputs.captureLocalImage("pack-build-image:latest")
99+
}
100+
}
101+
}
102+
```
103+
47104
To see more ways to use this plugin see the [examples folder](examples/).
48105

49106
## Contributing

0 commit comments

Comments
 (0)