Skip to content

Commit

Permalink
Polish "Improve Deploying to Containers section"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Nov 13, 2019
1 parent 6cf05ae commit d08b436
Showing 1 changed file with 19 additions and 16 deletions.
Expand Up @@ -39,27 +39,30 @@ For example, using a `Dockerfile` you could express it in this form:

[indent=0]
----
FROM openjdk:8-jdk-alpine AS builder
WORKDIR target/dependency
ARG fatjar
COPY ${fatjar} app.jar
RUN jar -xf ./app.jar
FROM openjdk:8-jre-alpine
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY --from=builder ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=builder ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=builder ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.MyApplication"]
----
and then build your docker image by passing the full path to your application jar:
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
ARG DEPENDENCY=target/dependency
COPY --from=builder ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=builder ${DEPENDENCY}/META-INF /app/META-INF
COPY --from=builder ${DEPENDENCY}/BOOT-INF/classes /app
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 fatjar=./full/path/to/your/springboot/app.jar
docker build --build-arg appjar=path/to/myapp.jar .
----



[[cloud-deployment]]
== Deploying to the Cloud
Spring Boot's executable jars are ready-made for most popular cloud PaaS (Platform-as-a-Service) providers.
Expand Down

0 comments on commit d08b436

Please sign in to comment.