Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jib {
- from {
- // picks up the previously created layer.
- // using tar lets us avoid communicating with docker
- image = "tar://$buildDir/image.tar"
- }
- to {
- image = "finalimage"
- }
- }
- // todo: file bug to make aditional image building easier
- val javaBase = tasks.register("javaBase") {
- // todo: figure out a better way to handle this instead of having to list out all subdirs
- // had to because it would just copy basetest-linux-x64 the folder instead of its subdirs
- val all = listOf(
- ///Paths.get("$buildDir", "jre/basetest-linux-x64/bin"),
- Paths.get("$buildDir", "jre/basetest-linux-x64/conf"),
- Paths.get("$buildDir", "jre/basetest-linux-x64/legal"),
- Paths.get("$buildDir", "jre/basetest-linux-x64/lib"),
- Paths.get("$buildDir", "jre/basetest-linux-x64/release")
- )
- val root = listOf(
- Paths.get("$buildDir", "jre/basetest-linux-x64/")
- )
- val bin = listOf(
- Paths.get("$buildDir", "jre/basetest-linux-x64/bin")
- )
- doLast {
- val binaries = listOf(AbsoluteUnixPath.get("/usr/lib/jdk-14.0.1/bin/java"), AbsoluteUnixPath.get("/usr/lib/jdk-14.0.1/bin/keytool"))
- Jib.from("gcr.io/distroless/java-debian10:base-debug")
- .setCreationTime(Instant.EPOCH) // make layer reproducible
- .addFileEntriesLayer(
- FileEntriesLayer.builder()
- // todo: replace this with a recursive addition, checking java permissions on host platform first
- .apply {
- val context = AbsoluteUnixPath.get("/usr/lib/jdk-14.0.1")
- all.forEach {
- addEntryRecursive(it, context.resolve(it.fileName))
- }
- }
- // dumb, doesn't inherit permissions from files in directory, have to manually specify executable bit
- .addEntryRecursive(bin.first(), AbsoluteUnixPath.get("/usr/lib/jdk-14.0.1/bin/")) { _, u ->
- if (u in binaries) {
- FilePermissions.fromOctalString("755")
- } else {
- FilePermissions.fromOctalString("644")
- }
- }
- .build()
- )
- // todo: replace this with a symlink when possible
- // dumb, can't append to pre-existing env variable
- .addEnvironmentVariable("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/busybox:/usr/lib/jdk-14.0.1/bin")
- .containerize(
- Containerizer.to(
- TarImage.at(File(buildDir, "image.tar").toPath()).named("myimage")
- //DockerDaemonImage.named("myimage")
- )
- )
- }
- //dependsOn
- //dependsOn(tasks.jre, createSymlink)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement