【问题标题】:kubernetes-maven-plugin - Dockerfile Build Fails with .git issuekubernetes-maven-plugin - Dockerfile 构建失败并出现 .git 问题
【发布时间】:2022-01-13 20:53:43
【问题描述】:

我正在 Maven 中测试从带有 Fabric8 的 Spotify dockerfile 插件到仅使用 Eclipse 的 JKube 插件的一些迁移。我一直在使用 Dockerfile 构建一个我认为足够简单的错误。

POM 配置如下:

            <plugin>
                <groupId>org.eclipse.jkube</groupId>
                <artifactId>kubernetes-maven-plugin</artifactId>
                <version>1.5.1</version>
                <configuration>
                    <images>
                        <image>
                            <name>${docker.image.prefix}/${docker.image.name}</name>
                            <build>
                                <dockerFile>${project.basedir}/Dockerfile</dockerFile>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>

Dockerfile(根据上面的配置)位于项目的根目录中。很简单

FROM adoptopenjdk/openjdk11-openj9:x86_64-ubi-jre-11.0.12_7_openj9-0.27.0
ARG JAR_FILE
ADD target/${JAR_FILE} microservice.jar
ENTRYPOINT ["java", "-jar", "microservice.jar"]

运行mvn clean install k8s:build 以以下错误消息结束:

[INFO] --- kubernetes-maven-plugin:1.5.1:build (default-cli) @ persistence-svc ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[ERROR] k8s: Failed to execute the build [Error while trying to build the image:<PROJ>\target\docker\<PREFIX>\<IMAGE>\build\maven\.git\objects\pack\pack-c35818936460f0bb0c1b903466f7bf1a17f22cc8.idx]

我不确定我错过了什么。我尝试添加一个 jKube 忽略文件,但没有任何区别。

任何指针将不胜感激。

【问题讨论】:

    标签: java maven dockerfile fabric8 jkube


    【解决方案1】:

    看起来我在忽略文件的正确轨道上。 我的语法不正确。我只有.git/,需要.git/**

    .git/**
    src/**
    target/classes/**
    target/persistence-svc.jar
    target/persistence-svc-sources.jar
    

    这会引起问题似乎有点疯狂。无论如何,我确信总体上有一个更好的解决方案,但这让我无需更改插件以外的任何内容。

    编辑
    确实,我的用例有更好的方法。请改用.jkube-dockerinclude。示例here

    【讨论】:

    • 是的,.jkube-xxx 文件具有特定的语法Wildcards are also supported, patterns will be matched using FileSystem#getPathMatcher glob syntax. 很高兴听到您能够轻松地从一个插件切换到另一个插件。 \o/
    猜你喜欢
    • 2010-11-26
    • 1970-01-01
    • 2017-09-01
    • 2020-07-23
    • 2014-05-13
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多