Docker: In Dockerfile, copy files temporarily, but not for final image -
i have java service i'd package, , thing final docker image needs jar file , config file. however, need run gradle
command first build jar, don't want things gradle
uses in result docker image.
here's current dockerfile:
run apt-get update && apt-get install -y openjdk-7-jdk re-create . / run ./gradlew shadowjar cmd ["java", "-jar", "service/build/libs/service.jar", "server", "service/service.yml"]
you can see have copy
first can run ./gradlew
(otherwise says command cannot found). in end, need service.jar
, service.yml
files.
i'm missing something, how can create available during ./gradlew
build step, have result image include service.jar
, service.yml
.
building image works follows.
... docker build command utilize whatever directory contains dockerfile build context (including of subdirectories). build context sent docker daemon before building image, means if utilize / source repository, entire contents of hard drive sent daemon ...
see https://docs.docker.com/reference/builder/
i see no way accomplish want. there 2 options:
having build dependencies within image , build jar file within container. bloats image.
i recommend build jar separately , add
executable , config files when build. means build dependencies must available on development environment, image little can be.
docker
No comments:
Post a Comment