File tree 4 files changed +92
-0
lines changed
4 files changed +92
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ## Builder
2
+ FROM ghcr.io/graalvm/native-image:ol8-java17-22 AS build
3
+
4
+ # Copy
5
+ WORKDIR /app
6
+ COPY pom.xml mvnw ./
7
+ COPY src ./src
8
+ COPY .mvn/ ./.mvn
9
+
10
+ # Build
11
+ RUN ./mvnw package -Pnative -DskipTests -Dspring-boot.run.profiles=prod
12
+
13
+ # ## Deployer
14
+ FROM amazonlinux:2023.3.20240131.0 AS deploy
15
+
16
+ # Copy
17
+ WORKDIR /app
18
+ COPY --from=build /app/target/aws-java-rest-api ./aws-java-rest-api
19
+
20
+ # User, port and health check
21
+ USER 1001
22
+ EXPOSE 8080
23
+ HEALTHCHECK CMD timeout 10s bash -c 'true > /dev/tcp/127.0.0.1/8080'
24
+
25
+ # Startup
26
+ ENTRYPOINT ["/app/aws-java-rest-api" ]
Original file line number Diff line number Diff line change
1
+ ### Builder
2
+ FROM ghcr.io/graalvm/native-image:ol8-java17-22 AS build
3
+
4
+ # Copy
5
+ WORKDIR /app
6
+ COPY pom.xml mvnw ./
7
+ COPY src ./src
8
+ COPY .mvn/ ./.mvn
9
+
10
+ # Build
11
+ RUN ./mvnw package -Pnative -DskipTests -Dspring-boot.run.profiles=prod
12
+
13
+ ### Deployer
14
+ FROM debian:bookworm-slim AS deploy
15
+
16
+ # Copy
17
+ WORKDIR /app
18
+ COPY --from=build /app/target/aws-java-rest-api ./aws-java-rest-api
19
+
20
+ # User, port and health check
21
+ USER 1001
22
+ EXPOSE 8080
23
+ HEALTHCHECK CMD timeout 10s bash -c 'true > /dev/tcp/127.0.0.1/8080'
24
+
25
+ # Startup
26
+ ENTRYPOINT ["/app/aws-java-rest-api"]
Original file line number Diff line number Diff line change @@ -20,3 +20,20 @@ Tasks:
20
20
- Spring Boot DevTools
21
21
- Spring Boot Actuator
22
22
- Lombok
23
+
24
+ ## Docker
25
+
26
+ Building:
27
+
28
+ ``` sh
29
+ docker build -t aws-java-rest-api .
30
+ ```
31
+
32
+ Running:
33
+
34
+ ``` sh
35
+ docker run -it --rm \
36
+ -p 8080:8080 \
37
+ --name aws-java-rest-api \
38
+ aws-java-rest-api
39
+ ```
Original file line number Diff line number Diff line change 45
45
</dependencies >
46
46
47
47
<build >
48
+ <finalName >aws-java-rest-api</finalName >
48
49
<plugins >
49
50
<plugin >
50
51
<groupId >org.springframework.boot</groupId >
61
62
</plugins >
62
63
</build >
63
64
65
+ <profiles >
66
+ <profile >
67
+ <id >native</id >
68
+ <build >
69
+ <plugins >
70
+ <plugin >
71
+ <groupId >org.graalvm.buildtools</groupId >
72
+ <artifactId >native-maven-plugin</artifactId >
73
+ <executions >
74
+ <execution >
75
+ <id >build-native</id >
76
+ <goals >
77
+ <goal >compile-no-fork</goal >
78
+ </goals >
79
+ <phase >package</phase >
80
+ </execution >
81
+ </executions >
82
+ </plugin >
83
+ </plugins >
84
+ </build >
85
+ </profile >
86
+ </profiles >
64
87
</project >
You can’t perform that action at this time.
0 commit comments