Jkube: k8s:build failed because .git folder is copied to target

Created on 28 Feb 2021  ยท  28Comments  ยท  Source: eclipse/jkube

Description

The k8s:build action copies the .git folder to target and then failed to build the docker image.

Info

  • Eclipse JKube version : 1.1.0
  • Maven version (mvn -v) :
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 11.0.9, vendor: AdoptOpenJDK
Java home: /usr/lib/jvm/adoptopenjdk-11-openj9
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.11.1.el7.x86_64", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version : 1.20

  • If it's a bug, how to reproduce :
    Clone a git repository. Then, execute the k8s:build action. The following error is shown:

[ERROR] k8s: Failed to execute the build [Error while trying to build the image: C:\dev\tmp\jkube-test\hello-world\target\docker\asms\hello-world\0.1.0\build\target\.git\objects\pack\pack-196b9336d55bf0c758ab92782f761f62fd0f95f4.idx]

To reproduce the issue, you can use the attached project. Then do:

  1. mvn clean install
  2. mvn k8s:build

jkube-test.zip

Waiting on feedback bug

Most helpful comment

@manusa I can confirm that this is working now. Great work!

All 28 comments

Will probably get fixed by #529 -> #567

Thanks @manusa . Any workaround you can recommend ? Because it makes it unusable for the moment ๐Ÿ˜Ÿ

Any workaround you can recommend ?

Don't use the simplified Dockerfile workflow. So probably your project looks like: https://github.com/eclipse/jkube/tree/master/quickstarts/maven/docker-file-simple

If you use any of the other approaches in any of the 4 profiles of https://github.com/eclipse/jkube/tree/master/quickstarts/maven/docker-file-provided you should be fine.

OK; just saw your reproducer project.
Just don't use the ${project.basedir} as the docker contextDir, make it all relative to the target dir

Thanks @manusa. Your tip works fine.

I have the same problem.
My plugin-config is the following:

<profile>
    <id>s2i-chained-local</id>
    <properties>
        <jkube.build.strategy>s2i</jkube.build.strategy>
        <jkube.resourceDir>${project.basedir}/src/main/jkube/s2i-chained-local</jkube.resourceDir>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jkube</groupId>
                <artifactId>openshift-maven-plugin</artifactId>
                <version>${openshift-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>s2i-chained-local</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resource</goal>
                            <goal>apply</goal>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <namespace>${os_project}</namespace>
                    <resources>
                        <labels>
                            <all>
                                <property>
                                    <name>app</name>
                                    <value>${os_app_name}</value>
                                </property>
                            </all>
                        </labels>
                        <!-- This section seems to be ignored -->
                        <openshiftBuildConfig>
                            <requests>
                                <cpu>${request_cpu_build}</cpu>
                                <memory>${request_memory_build}</memory>
                            </requests>
                            <limits>
                                <cpu>${limit_cpu_build}</cpu>
                                <memory>${limit_memory_build}</memory>
                            </limits>
                        </openshiftBuildConfig>
                    </resources>
                    <images>
                        <image>
                            <name>${os_app_name}-build</name>
                            <build>
                                <env>
                                    <MAVEN_COMMANDLINE>${maven_commandline}</MAVEN_COMMANDLINE>
                                </env>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/../../</directory><!-- Projects sources are 2 levels above openshift maven-module -->
                                                <excludes><!-- excludes are not working as expected, see edit below -->
                                                    <exclude>.git</exclude>
                                                    <exclude>target</exclude>
                                                </excludes>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <name>.</name>
                                </assembly>
                                <from>
                                    ${registry}/${namespace}/${builder}:${version}
                                </from>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

EDIT: I found out that the excludes are applied to late to avoid the .git folder error. Alle resources are copied first to the output directory and then the exclusions are deleted. But in between these two steps the error with the .git folder is thrown. To avoid that, the includes can be used. Unlike the exclude only the resources that are included are copied in the build step.

This issue should be fixed in the latest 1.2.0 release.

Could you please confirm?

I can't confirm. The problem persists with v1.2.0 in s2i local build with excludes like in my example above.

Failed to execute goal org.eclipse.jkube:openshift-maven-plugin:1.2.0:build (s2i-chained-local) on project springrest.openshift: Failed to execute the build: Unable to create the build archive: C:\springrest\openshift\target\docker\springrest-build\build\.\.git\objects\00\163521cb06fd599fa4f8d74b6c5b81fed9d98d

@ochstobi : Could you please try creating .jkube-dockerignore file and putting .git/** inside it?

@rohanKanojia I confirm that this is working. But only for .git/**. If I add other folders/files they are not ignored.

.git/**
.idea/**
.mvn/**
target/**
mvnw
mvnw.cmd
README.md

Are you sure about that? For me all specified folders seem to be getting ignored. I tested this on https://github.com/r0haaaan/jkube-dockerfile-test project which has this .jkube-dockerignore file:

target/classes/**
target/maven-status/**
src/**
pom.xml
docker-file-simple.iml
jkube-dockerinclude

I do k8s:build and check contents of target/docker directory:

jkube-dockerfile-test : $ tree target/docker -a
target/docker
โ”œโ”€โ”€ build.timestamp
โ””โ”€โ”€ jkube
    โ””โ”€โ”€ docker-file-simple
        โ””โ”€โ”€ 1.2.0
            โ”œโ”€โ”€ build
            โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
            โ”‚ย ย  โ””โ”€โ”€ maven
            โ”‚ย ย      โ”œโ”€โ”€ Dockerfile
            โ”‚ย ย      โ”œโ”€โ”€ docker-file-simple.jar
            โ”‚ย ย      โ”œโ”€โ”€ .git
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ branches
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ config
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ description
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ HEAD
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ hooks
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ applypatch-msg.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ commit-msg.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ fsmonitor-watchman.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ post-update.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-applypatch.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-commit.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-merge-commit.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ prepare-commit-msg.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-push.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-rebase.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pre-receive.sample
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ update.sample
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ index
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ info
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ exclude
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ logs
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ HEAD
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ refs
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ heads
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ master
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ remotes
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย          โ””โ”€โ”€ origin
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย              โ””โ”€โ”€ HEAD
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ objects
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 04
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ e212d7d69c3b4cbb8ab8ebe87610f38a1ee5c4
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 0b
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 47282267ecd59c4b666d891a8136d79145e013
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 0d
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 2b7261890fb77ce2dc933896015a0254b37b4c
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 24
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 473ac970f28c45b848fe5c6df21df2a92648ad
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 6c
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 9d9fcd0b634759b85c8728cdcf6144dafd55ca
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ 6d
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 35923d91d97ebdc571cdf3859cb31866f4ba84
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ a6
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 2354208b4d93375702b9c3c88bbbda0e1eb043
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ b8
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ e8510166e025756b176c3f1687c88cfcbc42c8
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ d4
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 0ccd4758e1b7602f6c100e13d8d832dfa4adf9
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ d5
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 12bf73487d02a9cfe2e52f34b2050916d07dd5
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ dc
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 328e61c482c6a9d0fe1510e6adc4101915e904
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ e1
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 5f6ec9f9c8862b31bf5c83655837133ff836f5
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ e9
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ac9da2611a23ea5231921ab18609d37fa89fac
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ee
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ c52115fe2a89c0ca00ce084fb9a7298c3300a5
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ f5
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 95fdf15af098e059810a2a8f24675c79bb3dd2
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ fb
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 566a928a13b6b79d22948044a13cc6ecf983bf
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ info
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ pack
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ packed-refs
            โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ refs
            โ”‚ย ย      โ”‚ย ย      โ”œโ”€โ”€ heads
            โ”‚ย ย      โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ master
            โ”‚ย ย      โ”‚ย ย      โ”œโ”€โ”€ remotes
            โ”‚ย ย      โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ origin
            โ”‚ย ย      โ”‚ย ย      โ”‚ย ย      โ””โ”€โ”€ HEAD
            โ”‚ย ย      โ”‚ย ย      โ””โ”€โ”€ tags
            โ”‚ย ย      โ”œโ”€โ”€ .gitignore
            โ”‚ย ย      โ”œโ”€โ”€ .idea
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ compiler.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ encodings.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ .gitignore
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ jarRepositories.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ libraries
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__ch_qos_logback_logback_classic_1_2_3.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__ch_qos_logback_logback_core_1_2_3.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_classmate_1_5_1.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_core_jackson_annotations_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_core_jackson_core_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_core_jackson_databind_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_10_4.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__io_micrometer_micrometer_core_1_3_8.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__jakarta_validation_jakarta_validation_api_2_0_2.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_apache_logging_log4j_log4j_api_2_12_1.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_apache_logging_log4j_log4j_to_slf4j_2_12_1.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_34.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_apache_tomcat_embed_tomcat_embed_el_9_0_34.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_34.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_hdrhistogram_HdrHistogram_2_1_11.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_hibernate_validator_hibernate_validator_6_0_19_Final.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_jboss_logging_jboss_logging_3_4_1_Final.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_latencyutils_LatencyUtils_2_0_3.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_slf4j_jul_to_slf4j_1_7_30.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_slf4j_slf4j_api_1_7_30.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_actuator_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_actuator_autoconfigure_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_autoconfigure_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_actuator_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_json_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_logging_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_tomcat_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_validation_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_boot_spring_boot_starter_web_2_2_7_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_aop_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_beans_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_context_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_core_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_expression_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_jcl_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_web_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Maven__org_springframework_spring_webmvc_5_2_6_RELEASE.xml
            โ”‚ย ย      โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Maven__org_yaml_snakeyaml_1_25.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ misc.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ modules.xml
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ .name
            โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ vcs.xml
            โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ workspace.xml
            โ”‚ย ย      โ”œโ”€โ”€ src
            โ”‚ย ย      โ””โ”€โ”€ target
            โ”‚ย ย          โ”œโ”€โ”€ classes
            โ”‚ย ย          โ”œโ”€โ”€ docker-file-simple.jar
            โ”‚ย ย          โ”œโ”€โ”€ docker-file-simple.jar.original
            โ”‚ย ย          โ”œโ”€โ”€ generated-sources
            โ”‚ย ย          โ”‚ย ย  โ””โ”€โ”€ annotations
            โ”‚ย ย          โ”œโ”€โ”€ maven-archiver
            โ”‚ย ย          โ”‚ย ย  โ””โ”€โ”€ pom.properties
            โ”‚ย ย          โ””โ”€โ”€ maven-status
            โ”œโ”€โ”€ tmp
            โ”‚ย ย  โ””โ”€โ”€ docker-build.tar
            โ””โ”€โ”€ work

49 directories, 100 files

I modify my .jkube-dockerignore file to ignore .git and .idea as well:

jkube-dockerfile-test : $ cat .jkube-dockerignore 
.git
.git/**
.idea
.idea/**
target/classes/**
target/maven-status/**
src/**
pom.xml
docker-file-simple.iml
jkube-dockerinclude

When I run mvn k8s:build, I was able to see both of them ignored:

jkube-dockerfile-test : $ tree target/docker -a
target/docker
โ”œโ”€โ”€ build.timestamp
โ””โ”€โ”€ jkube
    โ””โ”€โ”€ docker-file-simple
        โ””โ”€โ”€ 1.2.0
            โ”œโ”€โ”€ build
            โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
            โ”‚ย ย  โ””โ”€โ”€ maven
            โ”‚ย ย      โ”œโ”€โ”€ Dockerfile
            โ”‚ย ย      โ”œโ”€โ”€ docker-file-simple.jar
            โ”‚ย ย      โ”œโ”€โ”€ .gitignore
            โ”‚ย ย      โ”œโ”€โ”€ src
            โ”‚ย ย      โ””โ”€โ”€ target
            โ”‚ย ย          โ”œโ”€โ”€ classes
            โ”‚ย ย          โ”œโ”€โ”€ docker-file-simple.jar
            โ”‚ย ย          โ”œโ”€โ”€ docker-file-simple.jar.original
            โ”‚ย ย          โ”œโ”€โ”€ generated-sources
            โ”‚ย ย          โ”‚ย ย  โ””โ”€โ”€ annotations
            โ”‚ย ย          โ”œโ”€โ”€ maven-archiver
            โ”‚ย ย          โ”‚ย ย  โ””โ”€โ”€ pom.properties
            โ”‚ย ย          โ””โ”€โ”€ maven-status
            โ”œโ”€โ”€ tmp
            โ”‚ย ย  โ””โ”€โ”€ docker-build.tar
            โ””โ”€โ”€ work

14 directories, 9 files

Please also confirm your OS

I am working on Windows 10. Sorry I did a mistake before. In fact the .jkube-dockerignore isn't considered at all in my setup.

My .jkube-dockerignore is this:

.git/**
.idea/**
.mvn/**
target/**
mvnw
mvnw.cmd

and is located in /cicd/openshift/.jkube-dockerignore (same folder als the pom.xml which is executing the plugin).

I have the following structure:

C:/jkube-test/.
|   mvnw
|   mvnw.cmd
|   pom.xml <-- Parent pom for the spring applications modules
|   README.md
|   
+---.git
    | endless git folders/files...
+---.idea
|   |   endless intellij folders/files...
|   
+---.mvn
|   \---wrapper
|           maven-wrapper.jar
|           maven-wrapper.properties
|           
+---cicd
|   \---openshift
|       |   .gitignore
|       |   .jkube-dockerignore
|       |   pom.xml <-- Submodule which is triggering the openshift build
|       |   springrest.cicd.openshift.iml
|       |   
|       +---src
|       |   \---main
|       |       \---jkube
|       |           +---s2i-chained-local
|       |           |       build-buildconfig.yaml
|       |           |       build-imagestream.yaml
|       |           |       deployment.yaml
|       |           |       keystore-secret.yaml
|       |           |       route.yaml
|       |           |       run-buildconfig.yaml
|       |           |       run-imagestream.yaml
|       |           |       service.yaml
|       |           |       
|       \---target
|           |   s2i-env-springrest-build
|           |   
|           +---classes
|           |   \---META-INF
|           |       \---jkube
|           |           |   openshift.yml
|           |           |   
|           |           \---openshift
|           |                   springrest-build-imagestream.yml
|           |                   springrest-build-s2i-buildconfig.yml
|           |                   springrest-deploymentconfig.yml
|           |                   springrest-imagestream.yml
|           |                   springrest-keystore-secret-secret.yml
|           |                   springrest-route.yml
|           |                   springrest-run-buildconfig.yml
|           |                   springrest-service.yml
|           |                   
|           +---docker
|           |   |   build.timestamp
|           |   |   
|           |   \---springrest-build
|           |       +---build
|           |       |   |   mvnw
|           |       |   |   mvnw.cmd
|           |       |   |   pom.xml
|           |       |   |   README.md
|           |       |   |   
|           |       |   +---.git
|           |       |   |   |   copied git folders/files
|           |       |   +---.idea
|           |       |   |   |   copied intellij folders/files         
|           |       |   +---.mvn
|           |       |   |   \---wrapper
|           |       |   |           maven-wrapper.jar
|           |       |   |           maven-wrapper.properties
|           |       |   |           
|           |       |   +---cicd
|           |       |   |   \---openshift
|           |       |   |       |   .gitignore
|           |       |   |       |   .jkube-dockerignore
|           |       |   |       |   pom.xml
|           |       |   |       |   springrest.cicd.openshift.iml
|           |       |   |       |   
|           |       |   |       +---src
|           |       |   |       |   \---main
|           |       |   |       |       \---jkube
|           |       |   |       |           +---s2i-chained-local
|           |       |   |       |           |       build-buildconfig.yaml
|           |       |   |       |           |       build-imagestream.yaml
|           |       |   |       |           |       deployment.yaml
|           |       |   |       |           |       keystore-secret.yaml
|           |       |   |       |           |       route.yaml
|           |       |   |       |           |       run-buildconfig.yaml
|           |       |   |       |           |       run-imagestream.yaml
|           |       |   |       |           |       service.yaml
|           |       |   |       |           |       
|           |       |   |       |                   
|           |       |   |       \---target
|           |       |   |           |   s2i-env-springrest-build
|           |       |   |           |   
|           |       |   |           +---classes
|           |       |   |           |   \---META-INF
|           |       |   |           |       \---jkube
|           |       |   |           |           |   openshift.yml
|           |       |   |           |           |   
|           |       |   |           |           \---openshift
|           |       |   |           |                   springrest-build-imagestream.yml
|           |       |   |           |                   springrest-build-s2i-buildconfig.yml
|           |       |   |           |                   springrest-deploymentconfig.yml
|           |       |   |           |                   springrest-imagestream.yml
|           |       |   |           |                   springrest-keystore-secret-secret.yml
|           |       |   |           |                   springrest-route.yml
|           |       |   |           |                   springrest-run-buildconfig.yml
|           |       |   |           |                   springrest-service.yml
|           |       |   |           |                   
|           |       |   |           +---docker
|           |       |   |           |   |   build.timestamp
|           |       |   |           |   |   
|           |       |   |           |   \---springrest-build
|           |       |   |           |       +---build
|           |       |   |           |       +---tmp
|           |       |   |           |       \---work
|           |       |   |           \---jkube
|           |       |   |               |   build-buildconfig.yaml
|           |       |   |               |   build-imagestream.yaml
|           |       |   |               |   deployment.yaml
|           |       |   |               |   keystore-secret.yaml
|           |       |   |               |   route.yaml
|           |       |   |               |   run-buildconfig.yaml
|           |       |   |               |   run-imagestream.yaml
|           |       |   |               |   service.yaml
|           |       |   |               |   
|           |       |   |               \---applyJson
|           |       |   |                   \---my-namespace
|           |       |   |                           buildconfig-springrest-build-s2i.json
|           |       |   |                           buildconfig-springrest-run.json
|           |       |   |                           deploymentconfig-springrest.json
|           |       |   |                           route-springrest.json
|           |       |   |                           secret-springrest-keystore-secret.json
|           |       |   |                           service-springrest.json
|           |       |   |                           
|           |       |   \---target
|           |       |       \---failsafe-reports
|           |       |               failsafe-summary.xml
|           |       |               
|           |       +---tmp
|           |       \---work
|           \---jkube
|               |   build-buildconfig.yaml
|               |   build-imagestream.yaml
|               |   deployment.yaml
|               |   keystore-secret.yaml
|               |   route.yaml
|               |   run-buildconfig.yaml
|               |   run-imagestream.yaml
|               |   service.yaml
|               |   
|               \---applyJson
|                   \---my-namespace
|                           buildconfig-springrest-build-s2i.json
|                           buildconfig-springrest-run.json
|                           deploymentconfig-springrest.json
|                           route-springrest.json
|                           secret-springrest-keystore-secret.json
|                           service-springrest.json
|                           
\---target
    \---failsafe-reports
            failsafe-summary.xml

This is my fileset for the openshift-maven-plugin step:

<assembly>
    <inline>
        <fileSets>
            <fileSet>
                <directory>${project.basedir}/../../</directory><!-- This is because it is a submodule -->
                <outputDirectory>.</outputDirectory>
            </fileSet>
        </fileSets>
    </inline>
    <name>.</name>
</assembly>

Maybe the .jkube-dockerignore is in the wrong place?

I haven't checked our code, but I suspect it might have something to do with line separators (could you switch your file from CRLF to LF [if that is the case] and see if it works as expected?)

@manusa Sadly this ends in the same output.

Yes, we checked the code and we're using the nio Files helper class to read the file entries.

However, if you're still using the configuration provided in this comment, then the issue has nothing to do with the .jkube-dockerignore. I think that the fact that we're discussing your problem in this issue that is related to the Dockerfile simple mode is misleading us.

In your case, you really need to provide the <excludes> configuration in for your FileSets in the assembly. The .jkube-dockerignore or .jkube-dockerexclude files are only applicable for Dockerfile mode.

@manusa Thanks for this clarification. I apologize for the trouble.

@manusa Thanks for this clarification. I apologize for the trouble.

OK, no problem. Just confirm to us if once you configure the excludes in your XML config, it works OK.

I have tested it and found out some things. First of all the exclusions are working but not correctly. In the oc:build step the content of <directory>${project.basedir}/../../</directory> is copied completely to the target\docker\springrest-build\build folder. After that the exclusions are deleted. It works for all but .git because this error is thrown:

Failed to execute goal org.eclipse.jkube:openshift-maven-plugin:1.2.0:build (s2i-chained-local) on project springrest.openshift: Failed to execute the build: Unable to create the build archive: C:\springrest\openshift\target\docker\springrest-build\build\.\.git\objects\00\163521cb06fd599fa4f8d74b6c5b81fed9d98d

To dig a bit deeper I deleted the .git folder to see what the exclusions are actually doing.
After copying the resources the exclusions are deleted. Example of the syntax need is below:

<excludes>
    <exclude>**/.git/**</exclude>
    <exclude>/.git/**</exclude>
    <exclude>.git</exclude>
    <exclude>.git/**</exclude>   -- the git stuff is not working because of the error.
    <exclude>**/target</exclude> -- this is applied for all target folders which are not directly in `<directory>${project.basedir}/../../</directory>`
    <exclude>target</exclude>  -- this is applied only for target in `<directory>${project.basedir}/../../</directory>`
    <exclude>target/**</exclude> -- this doesn't do anything at all
    <exclude>**/target/**</exclude> -- this doesn't do anything at all
    <exclude>.idea</exclude>
</excludes>

So exclusions should be prevented from copying to the target. And the syntax for globs should be improved. I would expect that **/target/** excludes all folders named target regardless of the folder depth.

I hope this helps.

Remember that the syntax for the exclusions is based on FileSystem.html#getPathMatcher.

Since you're on a Windows platform, try using \ instead e.g. **\target\**, or even <exclude>**${file.separator}target${file.separator}**</exclude>

It seems that maven doesn't care. I tried and the results are the same.

This issue should be fixed after #693

@ochstobi could you please confirm everything works now as expected?

In order to test this I used the following settings with the maven/xml-config quickstart:

  <repositories>
    <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
    </pluginRepository>
  </pluginRepositories>
  <!-- ... -->
        <plugins>
          <plugin>
            <groupId>com.github.eclipse.jkube</groupId>
            <artifactId>openshift-maven-plugin</artifactId>
            <version>master-SNAPSHOT</version>
            <configuration>
            <!-- ... -->
                      <fileSet>
                        <directory>${project.basedir}/../../..</directory>
                        <outputDirectory>.</outputDirectory>
                        <excludes>
                          <exclude>.git{/**,}</exclude>
                          <exclude>**/target/**</exclude>
                          <exclude>ide-config{/**,}</exclude>
                          <exclude>.idea{/**,}</exclude>
                          <exclude>.circleci{/**,}</exclude>
                          <exclude>quickstarts{/**,}</exclude>
                        </excludes>
                      </fileSet>
            </configuration>
          </plugin>
        </plugins>

Where can I get the version "master-SNAPSHOT" to test it? Can't find it in maven central.

Just configure the plugin as described in my previous comment.

Note that the Maven GAV coordinates change and that you need to add the Jitpack repository.

Sadly I don't have access to jitpack repository in my environment. So I can only test it after the offical release.

Well, you can always clone and install locally :wink:

We just released 1.3.0, could you please confirm you can no longer reproduce this issue?

@manusa I can confirm that this is working now. Great work!

Was this page helpful?
0 / 5 - 0 ratings