2

将 spring boot 升级到 2.4 后,我们无法运行通过此脚本创建的最终 docker 映像:

script:
    - echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
    - apk add openjdk11
    - ./gradlew bootBuildImage --imageName=$DOCKER_IMAGE_INTERMEDIATE
    - docker build -f ./docker/Dockerfile --build-arg base_image=$DOCKER_IMAGE_INTERMEDIATE -t $DOCKER_IMAGE_TAGGED .
    - docker push $DOCKER_IMAGE_TAGGED
    - docker tag $DOCKER_IMAGE_TAGGED $DOCKER_IMAGE_LATEST
    - docker push $DOCKER_IMAGE_LATEST

我们Dockerfile只是创建一个文件夹并将chown其发送给CNB用户:

# The base_image holds a reference to the image created by ./gradlew bootBuildImage
ARG base_image
FROM ${base_image}

ENV SOME_PATH /var/lib/some/files

USER root

RUN mkdir -p ${SOME_PATH}

RUN chown ${CNB_USER_ID}:${CNB_GROUP_ID} ${SOME_PATH}

USER ${CNB_USER_ID}:${CNB_GROUP_ID}

ENTRYPOINT /cnb/lifecycle/launcher

虽然这在 Spring Boot 2.3 中运行良好,但在升级到 Spring Boot 2.4 后尝试运行映像时出现此错误:

ERROR: failed to launch: determine start command: when there is no default process a command is required

编辑:

CI 日志输出在命令末尾显示此行bootBuildImage

[creator]     Setting default process type 'web'

编辑2:

通过进一步检查bootBuildImage使用 spring-boot 2.3 和 2.4 创建的图像的差异,我发现默认ENTRYPOINT不再是/cnb/lifecycle/launcherbut的提示/cnb/process/web

更新 Dockerfile 的最后一行以选择这个入口点:

ENTRYPOINT /cnb/process/web

使我们能够启动图像!耶!:)

但是,我把这个问题留了下来,因为我仍然想知道为什么生命周期启动器不再使用默认进程?!

4

0 回答 0