In Dockerfile,I can do this by "COPY xxx.sh /usr/local/bin/". How do it in Jib?
extraDirectories can‘t solve my problem. @briandealwis .I need copy a file into a folder of docker i mage. I didn't found a way of extraDirectories to solve it. extraDirectories:
<configuration>
<!-- Copies files from 'src/main/custom-extra-dir' and '/home/user/jib-extras' instead of 'src/main/jib' -->
<extraDirectories>
<paths>
<path>src/main/custom-extra-dir</path>
<path>/home/user/jib-extras</path>
</paths>
</extraDirectories>
</configuration>
But I wan't to do this.
in Dockerfile:
...
COPY wait-for-it.sh /usr/local/wait-for-it.sh
...
copy the the file wait-for-it.sh into docker images's /usr/local/wait-for-it.sh.
@andyzhaozhao you can place the wait-for-it.sh file at <project root>/src/main/jib/usr/local/wait-for-it.sh. No configuration is needed in this case (when using the default extra files directory src/main/jib). Then Jib will put the file at /usr/local/wait-for-it.sh in the image.
@briandealwis @chanseokoh Thank you. But I don't wan't to change my src codes. So high coupling of it. The 'ops' codes invade into the 'dev' codes. I think this‘s not
a good way to copy the wait-for-it.sh file to my src directory. I want separate the Dev and Ops.Are there any other way to solve my problem? May be I need use the Dockerfile directly instead of Jib?
Then, how about making a custom base image that has wait-for-it.sh pre-installed and have Jib base on it? Or, maybe the other direction: for example, you could run Jib without the script, and a later ops step could put the script using a Dockerfile, if that is the loose coupling you are talking about?
Will Jib Support COPY in the pom.xml now?
I'd say that is basically what <extraDirectories> does. You can configure the source path (directory) and control the destination at the same time.
@chanseokoh thank you as same. But ,either preparing a docker image which contains the wait-for-it.sh or putting script in other ops step is not a simple way to solve my problem.
How can I control the destination by _extraDirectories_ ? @chanseokoh
For now, you have to layout the file structure as you would want to see it in the image. For example, let's say locally you have /tmp/foo/bar/baz.txt in your laptop. Then if you specify the /tmp directory as <extraDirectories><paths><path>, the baz.txt will be placed under /foo/bar/ in the image. This is how you control the destination.
Most helpful comment
For now, you have to layout the file structure as you would want to see it in the image. For example, let's say locally you have
/tmp/foo/bar/baz.txtin your laptop. Then if you specify the/tmpdirectory as<extraDirectories><paths><path>, thebaz.txtwill be placed under/foo/bar/in the image. This is how you control the destination.