Commit 7d540543 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #18932 from glours

* pr/18932:
  Polish "Improve Deploying to Containers section"
  Improve Deploying to Containers section

Closes gh-18932
parents a74d5b1c d08b4367
...@@ -35,19 +35,32 @@ Once you have unpacked the jar file, you can also get an extra boost to startup ...@@ -35,19 +35,32 @@ Once you have unpacked the jar file, you can also get an extra boost to startup
More efficient container images can also be created by copying the dependencies to the image as a separate layer from the application classes and resources (which normally change more frequently). More efficient container images can also be created by copying the dependencies to the image as a separate layer from the application classes and resources (which normally change more frequently).
There is more than one way to achieve this layer separation. There is more than one way to achieve this layer separation.
For example, using a `Dockerfile` you could express it in this form (assuming the jar is already unpacked at `target/dependency`): For example, using a `Dockerfile` you could express it in this form:
[indent=0] [indent=0]
---- ----
FROM openjdk:8-jdk-alpine FROM openjdk:8-jdk-alpine AS builder
WORKDIR target/dependency
ARG appjar
COPY ${appjar} app.jar
RUN jar -xf ./app.jar
FROM openjdk:8-jre-alpine
VOLUME /tmp VOLUME /tmp
ARG DEPENDENCY=target/dependency ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib COPY --from=builder ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF COPY --from=builder ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app COPY --from=builder ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.MyApplication"] ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.MyApplication"]
---- ----
Assuming the above `Dockerfile` is the current directory, your docker image can be built specifying the path to your application jar, as show in the following example:
[indent=0]
----
docker build --build-arg appjar=path/to/myapp.jar .
----
[[cloud-deployment]] [[cloud-deployment]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment