spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.91k stars 40.63k forks source link

Support registry mirrors when building images #30852

Open scottfrederick opened 2 years ago

scottfrederick commented 2 years ago

See https://github.com/buildpacks/pack/issues/821 and https://github.com/buildpacks/pack/pull/1210 for background.

Add the ability to configure one or more registry mirrors in the Spring Boot Maven spring-boot:build-image goal and Gradle bootBuildImage task. This configuration would provide a list of mappings from a registry to a registry mirror, such as:

When the Spring Boot plugins reference an image name that starts with one of the configured registries, the registry part of the image name would be replaced with the mirror before pulling or pushing the image.

suxu688 commented 2 years ago

what?

denon82 commented 2 years ago

I think this can be achieved by using profiles in maven.

On Wed, 4 May 2022, 06:45 小风残月, @.***> wrote:

what?

— Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-boot/issues/30852#issuecomment-1116950224, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL55TAAJQMTIEFWY7SRTNLVIIFH7ANCNFSM5U7QBFPA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

chandrasekharpanigrahy commented 1 year ago

I think this can be achieved by using profiles in maven. On Wed, 4 May 2022, 06:45 小风残月, @.> wrote: what? — Reply to this email directly, view it on GitHub <#30852 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL55TAAJQMTIEFWY7SRTNLVIIFH7ANCNFSM5U7QBFPA . You are receiving this because you are subscribed to this thread.Message ID: @.>

I have tried with maven profile but did not work with custom docker registry

dom54 commented 7 months ago

How are people using spring boot without this, given the docker registry rate limiting ?

nstuart-idexx commented 4 months ago

Any further ideas on this one?

We are going to be facing rate limits soon now that Google's IP addresses are no longer considered 'special' for docker hub. I can't seem to find any docs that would let us pull from our private repo (hosted in a google artifact registry) and also using the gcloud cred helper for auth to that registry.

I can configure the docker daemon itself, but that does't affect where buildpacks are pulled from.

I can also configure pack cli to pull from mirrors, but the plugin is obviously doing some extra work to do the building so I can't translate the bootBuildImage task to the appropriate pack build command.

dmikusa commented 4 months ago

Paketo images are sponsored OSS images on Docker Hub. You shouldn't be rate-limited.

Screenshot 2024-06-18 at 9 33 35 AM

@dom54 @nstuart-idexx Are you actually being rate-limited or just hypothesizing that this might be a problem?

@tjuchniewicz Docker Hub is the primary place where Paketo images get published. I think most, possibly all, of the buildpacks still get published to GCR, but I'm not 100% on that. GCR support is there for historical reasons. The images should be the same in both places though, Datadog included. Feel free to reach out to the Paketo project if you're not seeing that.

dom54 commented 4 months ago

We were actually getting rate limited, but the problem does not seem to have recurred since I posted. Maybe it was a one off.

dmikusa commented 4 months ago

Docker Hub had messed something up with our account a few months back. It's possible you got caught up in that. If you see rate limiting again, just reach out to the Paketo project and we'll complain to Docker and get it fixed :)

nstuart-idexx commented 4 months ago

Thank you for the information @dmikusa, thats comforting that, for now, the buildpacks used wont get limited. I still feel like this is a good option to have since others may not have an option to reach out to the internet for this to work.

We had not faced rate limiting yet, but got a notice from google that their IPs are being removed from special treatment from docker hub on July 15, 2024, and I was trying to be proactive and avoid issues in the future. We already publish and pull from private registries with docker/kubernetes , so we have the infrastructure in place.

Side note/Workaround;

After some groking of the docs, and the boot plugin, I realized I was making it to hard to build the application and was quite easy to get pack to work. It does require the cli be available, of course.

#Configure pack registry mirror. (Note, no HTTPS on here, that threw me off and it breaks things if you add it)
pack config registry-mirrors add "*" --mirror mirror.gcr.io
#Example task of using pack manually. 
tasks.register<Exec>("pack"){
    dependsOn("bootJar")
    commandLine = listOf("pack",
        "build",
        "-B",
        "paketobuildpacks/builder-jammy-base:latest",
        "--path",
        tasks.named<BootJar>("bootJar").get().archiveFile.get().asFile.absolutePath,
       "my-image"
    )
}