Skip to content

Commit 302803b

Browse files
committed
จัดเตรียมการใช้งาน Server ทั้งในแบบ JVM และ Native Binaries ในรูปแบบ Docker เพื่อง่ายต่อการใช้งาน
1 parent 5a3e55a commit 302803b

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed

build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ jooq {
146146
//logging = Logging.DEBUG
147147
jdbc.apply {
148148
driver = "org.postgresql.Driver"
149-
url = "jdbc:postgresql://localhost:5432/postgres"
150-
//url = "jdbc:postgresql://jungmha-postgres:5432/postgres"
149+
//url = "jdbc:postgresql://localhost:5432/postgres"
150+
url = "jdbc:postgresql://jungmha-postgres:5432/postgres"
151151
user = "postgres"
152152
password = "sql@min"
153153
properties.add(Property().apply {

docker-compose.yml

+19-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,25 @@ services:
1919
- dev_network
2020

2121

22+
jungmha-native-image:
23+
container_name: jungmha-native-image
24+
image: ghcr.io/graalvm/graalvm-community:17.0.9
25+
ports:
26+
- "8081:8080"
27+
volumes:
28+
- .:/app/source-code
29+
working_dir: /app/source-code
30+
command:
31+
- sh
32+
- -c
33+
- |
34+
chmod +x run_aot_app.sh; ./run_aot_app.sh
35+
36+
networks:
37+
- dev_network
2238

23-
jungmha-app:
24-
container_name: jungmha-app
39+
jungmha-jvm-app:
40+
container_name: jungmha-jvm-app
2541
image: amazoncorretto:17
2642
restart: unless-stopped
2743
ports:
@@ -33,9 +49,7 @@ services:
3349
- sh
3450
- -c
3551
- |
36-
chmod +x gradlew;
37-
./gradlew assemble;
38-
java -jar build/docker/optimized/layers/application.jar
52+
chmod +x run_jit_app.sh; ./run_jit_app.sh
3953
networks:
4054
- dev_network
4155

run_aot_app.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# ตรวจสอบว่ามี dir ชื่อ build/native/nativeOptimizedCompile หรือไม่
4+
if [ ! -d "build/native/nativeOptimizedCompile" ]; then
5+
# ถ้าไม่มีให้รันคำสั่ง ./gradlew nativeOptimizedCompile
6+
./gradlew nativeOptimizedCompile
7+
8+
# เมื่อเสร็จสิ้นให้ cd เข้าไปใน build/native/nativeOptimizedCompile
9+
cd build/native/nativeOptimizedCompile || exit
10+
else
11+
# ถ้ามีอยู่แล้วให้เข้าไปใน build/native/nativeOptimizedCompile
12+
cd build/native/nativeOptimizedCompile || exit
13+
fi
14+
15+
# หลังจากเข้าไปใน build/native/nativeOptimizedCompile ให้รัน ./jungmha-0.0.1-alpha
16+
./jungmha-0.0.1-alpha

run_jit_app.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# ตรวจสอบว่ามี dir ชื่อ build/docker/optimized/layers หรือไม่
4+
if [ ! -d "build/docker/optimized/layers" ]; then
5+
# ถ้าไม่มีให้รันคำสั่ง ./gradlew assemble
6+
./gradlew assemble
7+
fi
8+
9+
# ให้รันคำสั่ง java -jar build/docker/optimized/layers/application.jar
10+
java -jar build/docker/optimized/layers/application.jar

src/main/resources/application.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ micronaut.server.write-idle-timeout=45m
3131

3232

3333
# Database
34-
datasources.default.jdbc-url=jdbc:postgresql://localhost:5432/postgres
35-
#datasources.default.jdbc-url=jdbc:postgresql://jungmha-postgres:5432/postgres
34+
#datasources.default.jdbc-url=jdbc:postgresql://localhost:5432/postgres
35+
datasources.default.jdbc-url=jdbc:postgresql://jungmha-postgres:5432/postgres
3636
datasources.default.driver-class-name=org.postgresql.Driver
3737
datasources.default.username=postgres
3838
datasources.default.password=sql@min

0 commit comments

Comments
 (0)