File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ FROM maven:3.8.5-openjdk-17 AS JARBUILDER
2+
3+ WORKDIR build
4+
5+ COPY src src
6+ COPY pom.xml pom.xml
7+
8+ RUN mvn clean package -DskipTests
9+
10+ # above we are builing the project jar file and consuming it below to launch the application
11+
112FROM bellsoft/liberica-openjre-alpine
213
314WORKDIR springApplication/app
415
5- COPY target/*.jar app.jar
16+ COPY --from=JARBUILDER build/ target/*.jar app.jar
617
718CMD ["java" , "-jar" , "app.jar" ]
819
Original file line number Diff line number Diff line change @@ -37,9 +37,7 @@ project-root/
3737``` sh
3838git clone https://github.com/beneite/SpringBootBasics.git
3939cd SpringWithDocker
40- mvn clean package -DskipTests
4140```
42- > Running ``` mvn clean package -DskipTests ``` will create a SpringWithDocker-0.0.1-SNAPSHOT.jar file in target folder.
4341
4442### 2️⃣ Build and Run Containers
4543
@@ -49,6 +47,8 @@ docker compose --profile entireApp up --build
4947- ` --profile entireApp ` will spin up the tagged services with 'entireApp' only
5048- ` -d ` runs containers in detached mode
5149- ` --build ` forces a rebuild of the Spring Boot image
50+ - The docker compose will also take care of building the docker file/image.
51+ - The docker file used is a multistage where in stage 1st i am creating the .jar file using the same in 2nd stage to bring the application up.
5252
5353### 3️⃣ Check Running Containers
5454
You can’t perform that action at this time.
0 commit comments