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

Support extra classpath folders at runtime #1157

Closed
victornoel opened this issue Oct 17, 2018 · 17 comments · Fixed by #1642
Closed

Support extra classpath folders at runtime #1157

victornoel opened this issue Oct 17, 2018 · 17 comments · Fixed by #1642
Labels
Milestone

Comments

@victornoel
Copy link

Currently, it is possible to:

  • add files to the image both within the classpath (via resources folder) or the filesystem (via the jib folder).
  • add files to the container via the use of volumes
  • add files to the resources directory via volumes mounted inside /app/resources.

But it is not possible to add folders to the classpath directly.

For example, I have an image built with jib and a folder named config on the host containing a logback.xml file, there is no way to add the whole config directory as a classpath entry, I have to mount each file one by one into /app/resources.

I'm not sure how to solve this though…

@chanseokoh
Copy link
Member

chanseokoh commented Oct 17, 2018

Hi @victornoel,

I wonder if you can use the following workaround. Say the config folder is $CONFIG (your path to the config folder).

Copy $CONFIG/* into <project root>/src/main/jib/app/resources. That is, if you have $CONFIG/logback.xml, you'll place it at <project root>/src/main/jib/app/resources/logback.xml. (If you need to copy files during/after the build process, this FAQ may help.)

Then, the files will be placed under /app/resources in the image (e.g., /app/resources/logback.xml). You may even do this with /app/classes.

@chanseokoh
Copy link
Member

Ah, sorry, you're saying you want to do this at runtime.

@chanseokoh
Copy link
Member

Wait, but reading your original post again, it doesn't seem like you really need a way to add files at runtime.

@victornoel
Copy link
Author

@chanseokoh yes I do, it is to specify some configurations file that can change when the application is deployed. logback.xml is an example, but there are more (and that's why I need the whole directory to be mounted as a classpath folder).

@chanseokoh
Copy link
Member

chanseokoh commented Oct 17, 2018

I see. How about this workaround?

You'll see what entrypoint your image will have during building, e.g.,

Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, example.HelloWorld]

Then you customize the entrypoint (using the container.entrypoint parameter) so that it becomes

java -cp /app/resources:/app/classes:/app/libs/*:/your/mounted/config/folder example.HelloWorld

@victornoel
Copy link
Author

@chanseokoh indeed that's seems to be a valid workaround, thanks for the idea :)

@victornoel
Copy link
Author

@chanseokoh in the end, it's not great, because it doesn't play well with the other options such as jvmFlags (which are used only when the entrypoint is not overridden).

Any way to get a new configuration feature for this? :)

@chanseokoh
Copy link
Member

When you are not customizing the default entrypoint (i.e., when not defining container.entrypoint), Jib just adds the container.jvmFlags values to the default entrypoint. That's why container.jvmFlags and conatiner.mainClass are ignored when you define your own entrypoint. So, you can just directly embed the JVM flags in container.entrypoint. Do you think this will work?

Another potential option (based on which base image you use) could be to use another environment variable: https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#jvm-flags

@victornoel
Copy link
Author

@chanseokoh yes, you are right, this makes sense, I didn't think about it enough :P

@TadCordle
Copy link
Contributor

Closing since it sounds like there's a valid workaround.

@victornoel
Copy link
Author

@TadCordle honestly it's more of a hack than a acceptable workaround, not very maintainable: it is relevant to think that one wants to inherit from the command line built by jib while adding some extra directories to the classpath.

Personally, I abandoned the idea of changing the classpath and had to modify my application in the end…

@TadCordle
Copy link
Contributor

Ok, in that case I will reopen. The way the thread ended made it sound like everything was acceptable.

@TadCordle TadCordle reopened this Nov 30, 2018
@victornoel
Copy link
Author

@TadCordle no problem, thanks :)

@coollog coollog added this to the v1.1.0 milestone Nov 30, 2018
@chanseokoh
Copy link
Member

Related #894

@briandealwis
Copy link
Member

Fixed by #1642

@victornoel
Copy link
Author

@briandealwis thanks :)

@TadCordle
Copy link
Contributor

@victornoel @kurczynski @tellisnz-shift version 1.2.0 has been released with the <container><extraClasspath> / jib.container.extraClasspath configuration parameter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants