Skip to content

Commit d08b436

Browse files
committed
Polish "Improve Deploying to Containers section"
See spring-projectsgh-18932
1 parent 6cf05ae commit d08b436

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/deployment.adoc

+19-16
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,30 @@ For example, using a `Dockerfile` you could express it in this form:
3939

4040
[indent=0]
4141
----
42-
FROM openjdk:8-jdk-alpine AS builder
43-
WORKDIR target/dependency
44-
ARG fatjar
45-
COPY ${fatjar} app.jar
46-
RUN jar -xf ./app.jar
47-
48-
FROM openjdk:8-jre-alpine
49-
VOLUME /tmp
50-
ARG DEPENDENCY=target/dependency
51-
COPY --from=builder ${DEPENDENCY}/BOOT-INF/lib /app/lib
52-
COPY --from=builder ${DEPENDENCY}/META-INF /app/META-INF
53-
COPY --from=builder ${DEPENDENCY}/BOOT-INF/classes /app
54-
ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.MyApplication"]
55-
----
56-
and then build your docker image by passing the full path to your application jar:
42+
FROM openjdk:8-jdk-alpine AS builder
43+
WORKDIR target/dependency
44+
ARG appjar
45+
COPY ${appjar} app.jar
46+
RUN jar -xf ./app.jar
47+
48+
FROM openjdk:8-jre-alpine
49+
VOLUME /tmp
50+
ARG DEPENDENCY=target/dependency
51+
COPY --from=builder ${DEPENDENCY}/BOOT-INF/lib /app/lib
52+
COPY --from=builder ${DEPENDENCY}/META-INF /app/META-INF
53+
COPY --from=builder ${DEPENDENCY}/BOOT-INF/classes /app
54+
ENTRYPOINT ["java","-cp","app:app/lib/*","com.example.MyApplication"]
55+
----
56+
57+
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:
58+
5759
[indent=0]
5860
----
59-
docker build --build-arg fatjar=./full/path/to/your/springboot/app.jar
61+
docker build --build-arg appjar=path/to/myapp.jar .
6062
----
6163

6264

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

0 commit comments

Comments
 (0)