Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assembly descriptor removed but still in documentation #497

Closed
msillence opened this issue Nov 17, 2020 · 14 comments · Fixed by #568
Closed

Assembly descriptor removed but still in documentation #497

msillence opened this issue Nov 17, 2020 · 14 comments · Fixed by #568
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@msillence
Copy link

msillence commented Nov 17, 2020

Description

descriptor support has been removed from the plugin but is still documented at the end of section 5.2.5 https://www.eclipse.org/jkube/docs/kubernetes-maven-plugin

This commit removed support:
cd47542#diff-7fe446a69cdae536171e449f96f5705c613db53de41eb9cddf032229e6e05893

Info

  • Eclipse JKube version : 1.0.2
  • Maven version (mvn -v) : 3.0.6

  • If it's a bug, how to reproduce :

try and build a docker image using example documentation and you get the error:

Unable to parse configuration of mojo org.eclipse.jkube:kubernetes-maven-plugin:1.0.2:build for parameter descriptors: Cannot find 'descriptors' in class org.eclipse.jkube.kit.common.AssemblyConfiguration

@rohanKanojia
Copy link
Member

Which descriptors element are you referring to? I'm not able to find it in assembly configuration docs.

@msillence
Copy link
Author

msillence commented Nov 17, 2020

  <assembly>
    <mode>dir</mode>
    <targetDir>/opt/demo</targetDir>
    <descriptor>assembly.xml</descriptor>
  </assembly>
</build>

just above section : 5.2.6. Assembly

I was hoping for a drop in replacement but I was using this feature in fabirc8

@rohanKanojia
Copy link
Member

ah, I'm sorry. Looks like we missed it. This is not supported anymore since we refactored jkube-kit out of maven. Could you please elaborate what you're trying to package into your Docker image using this assembly.xml? Maybe we can provide you an alternative..

@manusa
Copy link
Member

manusa commented Nov 17, 2020

The only option right now is for you to inline the descriptor in the configuration

@msillence
Copy link
Author

My assembly is:

<inline>

	<fileSets>
		<fileSet>
			<outputDirectory>/</outputDirectory>
			<directory>src/main/resources/docker/</directory>
			<lineEnding>unix</lineEnding>
			<fileMode>0755</fileMode>
		</fileSet>
	</fileSets>

	<dependencySets>
		<dependencySet>
			<scope>provided</scope>
			<outputDirectory>.</outputDirectory>
		</dependencySet>

		<dependencySet>
			<scope>compile</scope>
			<outputDirectory>.</outputDirectory>
		</dependencySet>
	</dependencySets>
</inline>

it says lineEnding and dependencySets are not supported

@manusa
Copy link
Member

manusa commented Nov 17, 2020

For these more complex scenarios, I would recommend using the maven-resources-plugin or maven-assembly-plugin first to preprocess and then use the target directory as the fileSet source for JKube.

Check out an example here: http://blog.marcnuri.com/quarkus-jkube-qute-markdown-different-sources (The Build: Maven Assembly Plugin describes a setup similar to what you need)

So. you can keep your assembly.xml descriptor, but you'll need to configure it the maven-assembly-plugin and run the assembly prior to kubernetes-maven-plugin build task.

@msillence
Copy link
Author

thanks, that worked, though I couldnt get it working with a Dockerfile, the docker file is so minimal I've converted it to xml and embedded it in the pom.

I'm not sure if I'm allowed to mix a dockerfile and an assembly/inline - it's probably my lack of understanding about the copy path and using the directory assembly

@manusa
Copy link
Member

manusa commented Nov 20, 2020

I'm not sure if I'm allowed to mix a dockerfile and an assembly/inline - it's probably my lack of understanding about the copy path and using the directory assembly

Yes you should be able

Take a look at this quickstart https://github.com/eclipse/jkube/tree/master/quickstarts/maven/docker-file-provided which showcases different possibilities to work with external Docker files.

I think you're probably interested in this one:
https://github.com/eclipse/jkube/blob/db9c522bce061f4e327c4e9f06930b5ac29b70b2/quickstarts/maven/docker-file-provided/pom.xml#L149

@msillence
Copy link
Author

msillence commented Nov 30, 2020

OK this works for me:

			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.3.0</version>
				<configuration>
					<appendAssemblyId>false</appendAssemblyId>
					<finalName>preassembled</finalName>
					<outputDirectory>target/assembly</outputDirectory>
					<descriptors>
						<descriptor>src/main/assembly/assembly.xml</descriptor>
					</descriptors>
				</configuration>
...
			</plugin>

			<plugin>
				<groupId>org.eclipse.jkube</groupId>
				<artifactId>kubernetes-maven-plugin</artifactId>
				<version>1.0.2</version>
				<configuration>
					<images>
						<image>
							<name>artifactname:${project.version}</name>

							<build>
								<contextDir>${project.basedir}/</contextDir>
								<dockerFile>src/main/docker/Dockerfile</dockerFile>
								<assembly>
									<name>target/assembly/preassembled</name>
								</assembly>
							</build>
						</image>
					</images>
				</configuration>

Note that the contextDir is common to both the path to the dockerfile and the assembly directory
The Dockerfile copy must then match the images/image/build/assembly/name

COPY --chown=app:app target/assembly/preassembled/ /app/

If you don't have a name configured in the assembly then you get a null pointer in the plugin

I feel this is now really off topic to the orignal request

@manusa
Copy link
Member

manusa commented Dec 1, 2020

I feel this is now really off topic to the original request

Yes, we still need to fix the documentation or point to a workaround.

@manusa manusa reopened this Dec 1, 2020
@manusa manusa added the documentation Improvements or additions to documentation label Dec 1, 2020
@manusa manusa changed the title assembly descriptor removed but still in docuementation Assembly descriptor removed but still in documentation Dec 1, 2020
@rohanKanojia
Copy link
Member

rohanKanojia commented Dec 1, 2020

@msillence : Hi, Would it be possible for you to help us by contributing a PR to fix documentation and provide workaround?

@msillence
Copy link
Author

msillence commented Dec 1, 2020

When I moved this config to my real project it failed with an OOM - it was recursively adding the entire target folder to the docker image build in the target folder - until it failed

This is my current config that doesn't suffer from that problem - not sure why it was working on the smaller test project:

<build>
	<contextDir>${project.basedir}/target/assembly/preassembled</contextDir>
	<dockerFile>${project.basedir}/src/main/docker/Dockerfile</dockerFile>
	<assembly>
		<name>./</name>
	</assembly>
</build>

and docker file now reads:

COPY ./ /app/

I'll have a think about the PR assuming that my workaround is the right approach

@rohanKanojia
Copy link
Member

hmmm, I'm afraid if this could be a bug in our plugin itself. Would it be possible for you to share a demo project so that we can reproduce this OOM error?

@rohanKanojia rohanKanojia self-assigned this Feb 4, 2021
@rohanKanojia
Copy link
Member

I think OOM error might be related to #561 #544 #529 (I have a PR #567 that should fix #529)

I'm removing <descriptor> reference from the documentation

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Feb 4, 2021
…entation

Remove assembly `<descriptor>` field from documentation as it's no
longer supported
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Apr 7, 2021
…entation

Remove assembly `<descriptor>` field from documentation as it's no
longer supported
manusa pushed a commit to rohanKanojia/jkube that referenced this issue May 18, 2021
…entation

Remove assembly `<descriptor>` field from documentation as it's no
longer supported
@manusa manusa added this to the 1.3.0 milestone May 18, 2021
manusa pushed a commit that referenced this issue May 18, 2021
Remove assembly `<descriptor>` field from documentation as it's no
longer supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants