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

Allow copying of directory to new layer in image. #213

Closed
coollog opened this issue Apr 6, 2018 · 5 comments · Fixed by #455
Closed

Allow copying of directory to new layer in image. #213

coollog opened this issue Apr 6, 2018 · 5 comments · Fixed by #455
Assignees

Comments

@coollog
Copy link
Contributor

coollog commented Apr 6, 2018

The current way of adding arbitrary files would be to include them in the src/main/resources directory. However, that adds the files to the classpath, which may not be desirable.

The use case of being able to add arbitrary files include being able to add agent libraries to the image, such as JRebel.

The proposed configuration for Maven is:

<configuration>
  <copy>
    <fromDirectory></fromDirectory>
    <pathOnImage></pathOnImage>
  </copy>
</configuration>

The fromDirectory's contents would be placed in the directory on the image at pathOnImage.

For Gradle:

jib {
  copy {
    fromDirectory = 
    pathOnImage = 
  }
}
@coollog
Copy link
Contributor Author

coollog commented Apr 9, 2018

@loosebazooka @TadCordle @patflynn How does this sound? The alternative is to allow to user to define multiple directories to copy.

@TadCordle
Copy link
Contributor

TadCordle commented Apr 9, 2018

I feel like the naming could be improved; I'm not sure why, but I feel like calling it "adding files to the image" gets the point across better than "copying files". Maybe instead of copy, the parameter could be called add? Or something less active, like additionalFiles, although that might be too verbose.

Also, should there be more symmetry between the two inner parameters? When I see something start with "from" I usually expect the destination to start with "to".

@coollog
Copy link
Contributor Author

coollog commented Apr 9, 2018

For the naming, the main reasoning behind using copy is to keep it consistent with what people are used to for Dockerfiles. Dockerfiles has both COPY and ADD directives, but ADD does some more magic behind the scenes, such as unpacking an archive. We could change this to add, but if we do, it might be best to have it do the same as what ADD would do to avoid confusion?

For the inner parameters, perhaps we can call it fromDirectory and toPathOnImage? Or shorten it to src and dest to have it like Dockerfile? Or, we could just change copy (or add) to be a method with two parameters such that you would write something like:

jib {
  copy 'sourcefolder' '/path/on/image'
}

@TadCordle
Copy link
Contributor

Ah, didn't realize Dockerfiles had a COPY and ADD. In that case, I think it would make sense to go with src and dest for the parameters if we're going for Dockerfile similarity. Although I do like the last option you listed of having a method with two parameters as well, however that one could hurt readability if the directories get long.

@coollog
Copy link
Contributor Author

coollog commented Jul 11, 2018

This will be taken care of by #473

@coollog coollog closed this as completed Jul 11, 2018
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.

2 participants