java - Docker :: Issue with Dockerfile - target folder not available -


i have spring boot project , trying build project docker file on circleci continuous integration server.

the problem have source code in github repo; no target directory or jar file. dockerfile not able final artifact (packaging application jar).

please check docker file , suggest way forward.

from java:8 expose 8090 volume /tmp add target/spring-boot-rest-0.3.0.jar app.jar run bash -c 'touch /app.jar' entrypoint ["java","-djava.security.egd=file:/dev/./urandom","-dspring.profiles.active=container","-jar","/app.jar"] 

you need somehow package jar build docker image.

you can install maven in dockerfile , build project when build container. amounts automating steps described in other answers.

the example below assumes java source in /code directory , maven package target generating jar called target/spring-boot-rest-0.3.0.jar:

from java:8 expose 8090 volume /tmp workdir /code  run apt-get update   run apt-get install -y maven  add pom.xml /code/pom.xml   run ["mvn", "dependency:resolve"]   run ["mvn", "verify"]  # adding source, compile , package fat jar add src /code/src   run ["mvn", "package"]  add target/spring-boot-rest-0.3.0.jar app.jar run bash -c 'touch /app.jar' entrypoint ["java","-djava.security.egd=file:/dev/./urandom","-dspring.profiles.active=container","-jar","/app.jar"] 

however, doesn't seem way java folks (though how you'd containerize node or python app).

people seem build docker images maven. circl.ci supports maven builds, that's should do. plugin use.there bunch:

https://github.com/spotify/docker-maven-plugin/blob/master/readme.md

once have pom.xml file configured you'll instruct circl.ci create docker file command this:

mvn clean package docker:build 

the process similar whichever plugin use.