scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

dockerImageRegistry config is not considered

Open yadavan88 opened this issue 10 months ago • 1 comments

Version(s) 1.5.4

Describe the bug We have a scala-cli app that is packaged and used as docker image. We are using a proxy(Nexus) for the docker registry where the images are pulled from first. However, the script always pulls the images from the docker public registry. This is causing a problem due to the rate limiting.

To Reproduce

  • Create a base docker image into the local corp registry(e.g. Nexus) You can create a new tag with a valid image. For example:
docker pull openjdk:20
docker tag openjdk:20 mycompany/openjdkyadu:20
docker push mycompany/openjdkyadu:20
  • Now create a scala-cli script (docker.scala) that uses this newly created image
//> using packaging.dockerImageRegistry mycompany
//> using packaging.dockerFrom openjdkyadu:20
@main
def main() = {

	println("Hello from docker app")
}

  • Run the command
scala-cli --power package --docker docker.scala  --docker-image-repository test-repo-docker

This generates the error:

Compiling project (Scala 3.5.2, JVM (11))
Compiled project (Scala 3.5.2, JVM (11))
Started building docker image with your application, it might take some time
Error: com.google.cloud.tools.jib.api.RegistryUnauthorizedException: Unauthorized for registry-1.docker.io/library/openjdkyadu
For more details, please see '/Users/yadu/temp/docker-test/.scala-build/stacktraces/1740994400-10899676711844464561.log'

Here is the log:

com.google.cloud.tools.jib.api.RegistryUnauthorizedException: Unauthorized for registry-1.docker.io/library/openjdkyadu
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:163)
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
  com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
  com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
  com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
  com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
  [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  [email protected]/java.lang.Thread.run(Thread.java:833)
  com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
  com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
com.google.cloud.tools.jib.http.ResponseException: 401 Unauthorized
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdkyadu","Action":"pull"}]}]}

  com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:355)
  com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
  com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
  com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
  com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
  com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
  [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  [email protected]/java.lang.Thread.run(Thread.java:833)
  com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
  com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
com.google.api.client.http.HttpResponseException: 401 Unauthorized
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/openjdkyadu","Action":"pull"}]}]}

  com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1113)
  com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:349)
  com.google.cloud.tools.jib.http.FailoverHttpClient.call(FailoverHttpClient.java:266)
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:138)
  com.google.cloud.tools.jib.registry.RegistryEndpointCaller.call(RegistryEndpointCaller.java:114)
  com.google.cloud.tools.jib.registry.RegistryClient.callRegistryEndpoint(RegistryClient.java:623)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:434)
  com.google.cloud.tools.jib.registry.RegistryClient.pullManifest(RegistryClient.java:439)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.pullBaseImages(PullBaseImageStep.java:294)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:181)
  com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.call(PullBaseImageStep.java:71)
  com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
  com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:76)
  com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
  [email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  [email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  [email protected]/java.lang.Thread.run(Thread.java:833)

Expected behaviour It should use the image from the local registry and don't go to public docker registry if its available in internal registry

yadavan88 avatar Mar 03 '25 09:03 yadavan88

+1 for this error.

There is currently no way to add custom packages to a Docker image unless you build a new "base image", push it to the registry, and then Scala CLI will pull it.

At the moment, this is a show-stopper for wider Scala CLI adoption within our organisation. Could you please provide some help in terms of where and what needs to be changed or amended to support <something> and make this work?

Regards

otobrglez avatar Sep 10 '25 09:09 otobrglez