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

Make layering of extraDirectory configurable #1020

Closed
remmeier opened this issue Sep 21, 2018 · 16 comments · Fixed by #1692
Closed

Make layering of extraDirectory configurable #1020

remmeier opened this issue Sep 21, 2018 · 16 comments · Fixed by #1692
Assignees
Milestone

Comments

@remmeier
Copy link

Files in the extra layer can be:

  • quickly changing project resources
  • rather static project resources
  • third-party resources
  • potentially have a substantial size

So it is thinkable to place extraDirectories inbetween any other layer for optimial layering. A configuration flag for this would be great. Or maybe even the possiblity to have multiple extra layers.

@coollog
Copy link
Contributor

coollog commented Sep 24, 2018

Hi @remmeier , thanks for the suggestion. We will definitely consider supporting multiple extra layers though the order will most likely not be configurable since each layer is pushed independently (and thus ordering does not matter). I think for multiple extra directories, we can support something like src/main/jib2, src/main/jib3, etc. as conventions for extra extra directories.

@coollog
Copy link
Contributor

coollog commented Nov 9, 2018

@GoogleContainerTools/java-tools Any comments on supporting extra extra directories (src/main/jib2)?

@TadCordle
Copy link
Contributor

@coollog Would the same convention be used for custom extra directories?

e.g. extraDirectory = file('custom/extra/dir')
Layered structure is custom/extra/dir, custom/extra/dir2, custom/extra/dir3, etc.

@coollog
Copy link
Contributor

coollog commented Nov 9, 2018

Yep, that could be added too, so any number 2 and onwards (consecutively) appended to the configured extra directory path will be used as extra directory layers in the numbered order.

@chanseokoh
Copy link
Member

I just thought about a (highly unlikely) edge case of extraDirectory = file('F:\'). Might need to be careful not to fail in that case.

And another edge case: what if src/main/jib doesn't exist but src/main/jib2 does? Or, src/main/jib and src/main/jib4 exist but no jib2 or jib3.

Might just be cleaner to get a list of extra directory paths in the config. However, these are edge cases that may work in one way or another anyway, so I also see some good things about the simple approach of jib, jib2, etc.

@coollog
Copy link
Contributor

coollog commented Nov 9, 2018

For F:, Jib would try to look for F:2, but that doesn't exist, so it stops.
For src/main/jib2 exists but src/main/jib doesn't, Jib looks for src/main/jib, doesn't find it, and then stops. Essentially, it should go in sequence.

@coollog coollog modified the milestones: v1.1.0, v1.0.0 Nov 9, 2018
@briandealwis
Copy link
Member

This seems to me to be a case where we abandon convention for configuration. @remmeier's examples don't cleanly map to 2, 3, 4, ... and I would guess that some of those files would be things generated or best copies into target/ rather than into the source tree.

Perhaps now's the time to flesh out an <extras> / extras mapping:

<extras>
  <dir>src/main/jib</dir>
  <dir>target/downloads</dir>
</extras>
extras = ['src/main/jib', 'build/downloads']

@foal
Copy link

foal commented Nov 23, 2018

One more point. Now If I select the extraDirectory parameter selected folder is used instead of standard. It isn't very clever - the configured folder have to be used along with the standard folder.

Standard folder used for resources belong to the project. extraDirectory for the resources produced during a build.

@chanseokoh
Copy link
Member

One more point. Now If I select the extraDirectory parameter selected folder is used instead of standard. It isn't very clever - the configured folder have to be used along with the standard folder.

I don't agree on this. For example, Maven has the convention that the default value for <sourceDirectory> is src/main/java. When you omit it, it's src/main/java. And when you configure it to something else, it uses the new directory as the source directory rather than adding it as an extra source directory . Jib parameters are working in the same manner.

@foal
Copy link

foal commented Apr 1, 2019

I see - you look on the extraDirectory parameter as on folder with extra data. But I understood the extra as one more directory with usual data - that is a point of confusing :)
Ok, agree - from your POV the implementation follows the Maven convention, but anyway it will better to have a possibility to configure several folders for the extra data.

@TadCordle
Copy link
Contributor

@remmeier @foal version 1.2.0 has been released with the multiple extra directories feature! (jib.extraDirectories(.paths|.permissions) / <extraDirectories>(<paths><path>|<permisssions>)

@remmeier
Copy link
Author

are there plans to make the position of extra layers configurable? we have use cases of third-party files in extra layers that are large in size and ideally placed below project resources.

@loosebazooka
Copy link
Member

loosebazooka commented Jul 17, 2019

The order of layers shouldn't matter with the registry/image format we are using. No invalidation is happening, if a layer doesn't change, it is not rebuilt or repushed.

(vs docker which must handle arbitrarily executed steps)

@ninpuabi
Copy link

ninpuabi commented Sep 12, 2019

the documentation says

<extraDirectories>
<paths></paths>

which puts them at the root. Is there a way to put them somewhere specific?

@ninpuabi
Copy link

the documentation says:
<extraDirectories>
<paths></paths>
but does not give the option to where to put them.

@loosebazooka
Copy link
Member

loosebazooka commented Sep 12, 2019

ah, so currently it's sort of attached to your local filesystem layout.

if you have a directory some/path/extra-dir/
with contents

extra-dir
 |_ potato.txt
 |_ some-dir
       |_ tomato.txt

and you do

<extraDirectories>
<paths>
  <path>some/path/extra-dir</path>
</paths>
</extraDirectories>

what goes into the root of the container is the contents of extra-dir, which means potato.txt and some-dir, some-dir/tomato.txt are all at /

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

Successfully merging a pull request may close this issue.

8 participants