我正在使用pack
cli 构建图像:
pack build fhir-mongo --builder paketobuildpacks/builder:base --path target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
这是我的项目结构:
.
├── hes-mpi-fhir-mongodb
│ ├── deployment.yaml
│ ├── pom.xml
│ ├── skaffold.yaml
│ └── src
└── hes-spring-boot-core <<< dependency requiered by hes-mpi-fhir-mongodb
├── pom.xml
└── src
如您所见,我管理着两个 Maven 项目。
我的主机构建步骤是:
$ hes-spring-boot-core > mvn clean install
$ hes-mpi-fhir-mongodb > mvn clean package
我的意思是,我首先安装hes-spring-boot-core
到本地存储库中,然后构建hes-mpi-fhir-mongodb
:
我的skaffold.yml
文件是:
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: pom-xml-image
buildpacks:
builder: paketobuildpacks/builder:base
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]
当我尝试构建图像时,我收到了这条消息:
...
[builder] Running "/layers/google.java.maven/maven/bin/mvn clean package --batch-mode -DskipTests -Dhttp.keepAlive=false --quiet"
[builder] [ERROR] Failed to execute goal on project hes-mpi-fhir-mongodb-service: Could not resolve dependencies for project cat.gencat.catsalut.hes.mpi.fhir:hes-mpi-fhir-mongodb-service:jar:0.0.1-SNAPSHOT: Could not find artifact cat.gencat.catsalut.hes:hes-spring-boot-core:jar:1.0.6 in central (https://repo.maven.apache.org/maven2)
这让我觉得 maven builder 无法找到 artifact cat.gencat.catsalut.hes:hes-spring-boot-core:jar:1.0.6
。
pack cli
执行上述命令时不会出现此错误!
如何将此项目添加为依赖项?
我已经查看了文档。有一些领域让我很困惑:
dependencies
: skaffold 应该监视此工件的重建和文件同步的文件依赖项。
工件依赖性:您可以使用 requires 关键字定义对其他工件的依赖性。这对于将另一个工件图像指定为 builder 或 runImage 很有用。
我正在使用 skaffold v1.35.1
。
信息
- 支架版本:1.35.1
- 操作系统:
- 通过安装:skaffold.dev
- skaffold.yaml 的内容:
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: pom-xml-image
context: target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
buildpacks:
builder: paketobuildpacks/builder:base
dependencies:
paths:
- "target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar"
# requires:
# - image: core
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]
我也尝试构建两个图像。但是问题就来了。
apiVersion: skaffold/v2beta26
kind: Config
metadata:
name: hes-mpi-fhir-mongodb
build:
artifacts:
- image: core
context: ../hes-spring-boot-core
buildpacks:
builder: paketobuildpacks/builder:base
env:
- "BP_MAVEN_BUILD_ARGUMENTS=install"
- image: pom-xml-image
# context: target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar
buildpacks:
builder: paketobuildpacks/builder:base
dependencies:
paths:
- "target/hes-mpi-fhir-mongodb-service-0.0.1-SNAPSHOT.jar"
requires:
- image: core
profiles:
- name: dev
deploy:
kustomize:
paths: ["kustomize/dev"]