简体   繁体   English

将私有 buildpack 注册表与 spring-boot:build-image 一起使用的正确方法是什么?

[英]What is the correct way to use a private buildpack registry with spring-boot:build-image?

I created my own paketo buildpack and I am trying to use it with spring-boot-maven-plugin.我创建了自己的 paketo buildpack,并尝试将它与 spring-boot-maven-plugin 一起使用。

I wrote我写

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <image>
      <buildpacks>
        <buildpack>paketo-buildpacks/java</buildpack>
        <buildpack>gitlab.company.com:5000/my-buildpack</buildpack>
      </buildpacks>
    </image>
  </configuration>
</plugin>

If I use this configuration spring is downloading docker.io/paketobuildpacks/builder:base etc just fine, but of course it can not download the buildpack from the private registry.如果我使用这个配置 spring 正在下载 docker.io/paketobuildpacks/builder:base 等就好了,但它当然不能从私有注册表下载 buildpack。 As stated here I have to add credentials for the private registry.如此处所述,我必须为私有注册表添加凭据。

But when I add但是当我添加

<configuration>
  <docker>
    <builderRegistry>
      <url>gitlab.company.com:5000</url>
      <username>myuser</username>
      <password>mypassword</password>
    </builderRegistry>
  </docker>
...
<configuration>

I am suddenly getting this error我突然收到这个错误

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.957 s
[INFO] Finished at: 2022-06-23T14:39:27+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.8:build-image (default-cli) on project usermanagement: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.6.8:build-image failed:
Docker API call to 'localhost/v1.24/images/create?fromImage=docker.io%2Fpaketobuildpacks%2Fbuilder%3Abase' failed with status code 500 "Internal Server Error" 
and message "Head "https://registry-1.docker.io/v2/paketobuildpacks/builder/manifests/base": unauthorized: please use personal access token to login" -> [Help 1]

It seems as if the maven plugin is trying to apply my credentials for the private registry to docker.io, too.似乎 maven 插件也在尝试将我的私有注册表凭据应用到 docker.io。

Is this a bug in the plugin, or is it impossible to mix multiple private and public docker registries for buildpacks?这是插件中的错误,还是无法为 buildpack 混合多个私有和公共 docker 注册表?

At the moment, if you provide credentials as you are doing then the plugin expects to pull your builder and buildpack images all from the same registry, the one that you've indicated in the <url> block.目前,如果您在执行过程中提供凭据,则插件希望从同一个注册表中提取您的构建器和 buildpack 映像,即您在<url>块中指定的那个。

<configuration>
  <docker>
    <builderRegistry>
      <url>gitlab.company.com:5000</url>
      <username>myuser</username>
      <password>mypassword</password>
    </builderRegistry>
  </docker>
...
<configuration>

The reason it's failing is that you have a mix, you've got the builder in the Paketo public registry and your custom buildpack in the private registry.它失败的原因是你有一个混合体,你在 Paketo 公共注册表中有构建器,在私有注册表中有你的自定义 buildpack。

You can work around this in a few ways:您可以通过以下几种方式解决此问题:

  1. You can relocate the public builder into your private registry.您可以将公共构建器重新定位到您的私有注册表中。 Then pull from that registry.然后从该注册表中提取。 If you do this, you'll want to have some sort of automated job that fetches and relocates the builder when new builders are released through the Paketo public registry, that way you are getting updates.如果您这样做,您将需要某种自动化作业,当新构建器通过 Paketo 公共注册表发布时获取并重新定位构建器,这样您就可以获取更新。

  2. You can create your own builder and publish it to your private registry.您可以创建自己的构建器并将其发布到您的私有注册表。 This is a little more work, but ultimately requires a custom builder.toml and running pack builder create using that config.这需要做更多的工作,但最终需要自定义builder.toml并使用该配置运行pack builder create The nice thing is that you can streamline your builder and remove things you're not using which reduces the size of the builder and makes builds a little faster.好处是您可以简化构建器并删除不使用的东西,从而减小构建器的大小并使构建速度更快。 See instructions here and the Paketo base builder.toml file .请参阅此处的说明Paketo 基础 builder.toml 文件 Again, you'd want to automate this so you are generating new builders when buildpacks are updated.同样,您希望自动执行此操作,以便在更新 buildpack 时生成新的构建器。

  3. You could use the pack cli instead.您可以改用pack cli。 You can run pack build to generate your images.您可以运行pack build来生成图像。 The pack cli is capable of pulling from multiple registries. pack cli 能够从多个注册表中提取。

For future reference, you can also track this issue which is a discussion on the topic and potential changes to the Spring Boot plugin.为了将来参考,您还可以跟踪这个问题,这是关于 Spring Boot 插件的主题和潜在更改的讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 spring-boot:build-image 时如何发布 docker 图像 - How to publish a docker image when you use spring-boot:build-image spring-boot:在代理后面构建映像 - spring-boot:build-image behind a proxy spring-boot:build-image 与 jib 有什么区别? - What is the difference between spring-boot:build-image vs jib? 我未能在 win10 上使用 `mvn spring-boot:build-image` 和远程 docker 守护程序 - I failed to use `mvn spring-boot:build-image` and remote docker daemon on win10 Spring 使用 docker 启动构建 mvn spring-boot:build-image with Z6CE80D8EF01F5E3BAEEZB 参数 - Spring boot with docker build mvn spring-boot:build-image with jvm parametes 为什么“spring-boot:build-image”会运行 Spring Boot 应用程序? - Why does "spring-boot:build-image" run the Spring Boot application? 无法使用 mvn spring-boot:build-image 构建战争文件的映像 - Can't build image of war file using mvn spring-boot:build-image 在 Gitlab-ci.yaml 管道中使用 spring-boot:build-image 创建 docker 镜像 - Using spring-boot:build-image in Gitlab-ci.yaml Pipeline to create a docker image Spring spring-boot:build-image 给出 HTTP 500 错误 - Spring spring-boot:build-image gives HTTP 500 error mvn spring-boot:build-image 不会在 docker 中保存图像 - mvn spring-boot:build-image doesn't save image in docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM