I'm using Gradle bootBuildImage task,but my environment doesn't have access to github.
I built a local docker repository.
Then pushed paketobuildpacks/builder-jammy-full and paketobuildpacks/run-jammy-full to this local repository.
My local docker Images and repository:
Get http://127.0.0.1:5000/v2/_catalog
result:
{"repositories":["paketobuildpacks","paketobuildpacks-builder","paketobuildpacks-run"]}
My first config in build.gradle.kts:
tasks.bootBuildImage {
builder = "127.0.0.1:5000/paketobuildpacks-builder:latest"
runImage = "127.0.0.1:5000/paketobuildpacks-run:latest"
imageName = "127.0.0.1:5000/${project.name}:${project.version}"
environment.put("BP_JVM_VERSION", "21.0.1")
}
But when going this far, the build fails because I can't access github:
[creator] BellSoft Liberica JRE 21.0.1: Contributing to layer
[creator] Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.1+12/bellsoft-jre21.0.1+12-linux-amd64.tar.gz
[creator] unable to invoke layer creator
[creator] unable to get dependency jre
[creator] unable to download https://github.com/bell-sw/Liberica/releases/download/21.0.1+12/bellsoft-jre21.0.1+12-linux-amd64.tar.gz
[creator] unable to request https://github.com/bell-sw/Liberica/releases/download/21.0.1+12/bellsoft-jre21.0.1+12-linux-amd64.tar.gz
[creator] Get "https://objects.githubusercontent.com/github-production-release-asset-2e65be/115621629/2267524d-b682-4d10-a5c2-da871a4195bd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20231205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20231205T145915Z&X-Amz-Expires=300&X-Amz-Signature=7a00888e76cbfadc45f6dcf87e77fdcdb18329d946cb5d6ccfe3f8509b1b4fe2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=115621629&response-content-disposition=attachment%3B%20filename%3Dbellsoft-jre21.0.1%2B12-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream": dial tcp: lookup objects.githubusercontent.com: i/o timeout
[creator] ERROR: failed to build: exit status 1
So I thought of using bindings.
I downloaded bellsoft-jre21.0.1+12-linux-amd64.tar.gz from elsewhere and create binding files:
Since I actually needed to build the [base] module, I set the directory back one level.
New config in build.gradle.kts:
tasks.bootBuildImage {
builder = "127.0.0.1:5000/paketobuildpacks-builder:latest"
runImage = "127.0.0.1:5000/paketobuildpacks-run:latest"
imageName = "127.0.0.1:5000/${project.name}:${project.version}"
environment.put("BP_JVM_VERSION", "21.0.1")
bindings.add("./bindings/jre/:/tmp/jre/")
bindings.add("./bindings/bellsoft-jdk-config/:/platform/bindings/dependency-mapping/")
}
This time I got an error:
Execution failed for task ':base:bootBuildImage'.
> Docker API call to 'localhost/v1.24/containers/create' failed with status code 400 "Bad Request"
......
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':base:bootBuildImage'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:148)
......
Caused by: org.springframework.boot.buildpack.platform.docker.transport.DockerEngineException: Docker API call to 'localhost/v1.24/containers/create' failed with status code 400 "Bad Request"
......
I've changed the bindings configuration with reference to issues in the binding-tool project, but it still doesn't work.
Did I misconfigure something, or is my local docker repository corrupt?
Eventually I solved the problem.
I turned on a setting for docker desktop: Expose daemon on tcp://localhost:2375 without TLS. And restarted the computer. But it still gives me an 400 "Bad Request".
Then I traced the source code of bootBuildImage.I've noticed that when it requests createUri, it doesn't get the information returned by dockerApi.Maybe I have the wrong version of the dependency, but I don't know.So I breakpoint this line and used new String(entity.getgetContent().readAllBytes())
to get the information I was looking for:
{
"message": "create bindings/jre/ : \"bindings/jre/ \" includes invalid characters for a local volume name, only \"[a-zA-Z0-9][a-zA-Z0-9_.-]\" are allowed. If you intended to pass a host directory, use absolute path"
}