So the main intention was to dockerize a fat jar application and put it into Elasticbeanstalk. The problem is with the context. It's a little bit stupid to add so much context into docker if all I need is actually a single jar file.
I've been playing around with the .dockerignore file, but I am lost. I tried to use the gitignore negation, but it doesn't work.
*
!Dockerfile
*/
!target/
target/*
!target/*.jar
There's also that thing with regex, but it seems like complicated regex is not supported.
^((?!Dockerfile).)*$
I have also tried searching in stackoverflow, and these two are all I found:
This question might be similiar to the second one, but I think it's slightly difference since in here, I just want to include a single file into the context.
Any help will be appreciated.
This may sound strange, but if all you need is a single jar file, you could create a "docker" folder in your build system that contains your Dockerfile. When you run your builds, have the build scripts copy the single jar file into "docker" then execute the docker image build (from inside the "docker" folder) and push to your docker registry when done.
If you need to ignore everything except some directories or files and also ignore some unnecessary files inside those allowed directories you can use the following
.dockerignore
file:From the dockerfile reference:
So a line containing simply ** will ignore everything in the same directory as the Dockerfile.
As expected the exclamation can then be used to reference any files you do wish to send to the docker daemon.