无需卷挂载,Spring Boot Maven插件绑定添加证书失败排查
问题:GitLab环境下Spring Boot构建镜像嵌入CA证书失败
背景
- 参考多篇相关解决方案,但均依赖卷挂载,而GitLab构建环境因政策限制无法使用卷挂载,且存在未解决的相关问题。
- 按照Spring Boot官方文档配置Maven插件,本地构建正常,但GitLab环境中构建失败。
配置细节
Spring Boot Maven插件配置
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> <verboseLogging>true</verboseLogging> <env> <BP_DEBUG>true</BP_DEBUG> <BP_EMBED_CERTS>true</BP_EMBED_CERTS> <BP_RUNTIME_CERT_BINDING_DISABLED>true</BP_RUNTIME_CERT_BINDING_DISABLED> </env> <bindings> <binding>${project.basedir}/bindings/certificates:/platform/bindings/ca-certificates</binding> </bindings> </image> </configuration> </plugin>
项目目录结构
spring-boot-project ├── src ├── pom.xml └── bindings └── certificates ├── type └── private-ca.pem
GitLab构建错误日志
56035 [[1;34mINFO[m] [creator] Platform contents: [. bindings bindings/ca-certificates env env/BP_DEBUG env/BP_EMBED_CERTS env/BP_RUNTIME_CERT_BINDING_DISABLED] 56035 [[1;34mINFO[m] [creator] Platform Bindings: [{Name: ca-certificates Path: /platform/bindings/ca-certifi 56035 [[1;34mINFO[m] [creator] cates Type: Provider: Secret: []}] 56035 [[1;34mINFO[m] [creator] Platform Environment: map[BP_DEBUG:true BP_EMBED_CERTS:true BP_RUNTIME_CERT_BINDING_DISABLED:true] 56035 [[1;34mINFO[m] [creator] Stack: io.buildpacks.stacks.jammy 56035 [[1;34mINFO[m] [creator] Result: {Pass:true Plans:[{Provides:[{Name:watchexec}] Requires:[]}]}] 56035 [[1;34mINFO[m] [creator] Writing build plans: /tmp/plan.2470190612/plan.toml <= {BuildPlan:{Provides:[{Name:watchexec}] Requires:[]} Or:[]}] 56035 [[1;34mINFO[m] [creator] ======== Output: paketo-buildpacks/git@1.0.8 ======== 56035 [[1;34mINFO[m] [creator] failed to load bindings from '/platform/bindings': failed to read binding 'ca-certificates': missing 'type' 56035 [[1;34mINFO[m] [creator] ======== Output: paketo-buildpacks/go-mod-vendor@1.0.29 ======== 56035 [[1;34mINFO[m] [creator] go.mod file is not present 56035 [[1;34mINFO[m] [creator] ======== Output: paketo-buildpacks/go-build@2.2.1 ======== 56035 [[1;34mINFO[m] [creator] failed to parse build configuration: no *.go files could be found 56035 [[1;34mINFO[m] [creator] ======== Output: paketo-buildpacks/procfile@5.6.9 ========
已验证信息
- 执行命令
mvn help:evaluate -Dexpression=project.basedir -q -DforceStdout确认,bindings/certificates路径解析正确 - 本地构建完全正常,但GitLab环境下构建失败,且
BP_EMBED_CERTS选项未生效
疑问
请问我遗漏了什么?
内容的提问来源于stack exchange,提问作者ielkhalloufi
相关产品推荐
相关产品推荐

