diff --git a/Dockerfile b/Dockerfile index 398d6cb..58ac1af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,8 @@ RUN apt update && apt upgrade -y && apt install -y python3 python3-pip && \ # 작업 디렉토리 설정 WORKDIR /app +COPY ai /app/ai + # 빌드 이미지에서 생성된 JAR 파일을 런타임 이미지로 복사 COPY --from=build /app/build/libs/*.jar /app/ohlottery.jar diff --git a/src/main/resources/ai/lottery_prediction.py b/ai/lottery_prediction.py similarity index 100% rename from src/main/resources/ai/lottery_prediction.py rename to ai/lottery_prediction.py diff --git a/src/main/resources/ai/lottery_probability_predictor.py b/ai/lottery_probability_predictor.py similarity index 100% rename from src/main/resources/ai/lottery_probability_predictor.py rename to ai/lottery_probability_predictor.py diff --git a/src/main/resources/ai/oh-lottery_main.csv b/ai/oh-lottery_main.csv similarity index 100% rename from src/main/resources/ai/oh-lottery_main.csv rename to ai/oh-lottery_main.csv diff --git a/src/main/java/com/ohlottery/service/LotteryAINumberService.java b/src/main/java/com/ohlottery/service/LotteryAINumberService.java index efe8c5c..ce31008 100644 --- a/src/main/java/com/ohlottery/service/LotteryAINumberService.java +++ b/src/main/java/com/ohlottery/service/LotteryAINumberService.java @@ -6,19 +6,15 @@ import java.io.BufferedReader; import java.io.InputStreamReader; -import java.net.URL; @Service public class LotteryAINumberService { - private final URL scriptURL - = getClass().getClassLoader().getResource("ai/lottery_probability_predictor.py"); - public JsonNode getAINumberResults() { JsonNode aiNumberResults = null; try { - ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath()); + ProcessBuilder processBuilder = new ProcessBuilder("python3", "/app/ai/lottery_probability_predictor.py"); Process process = processBuilder.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); diff --git a/src/main/java/com/ohlottery/service/LotteryAIPriceService.java b/src/main/java/com/ohlottery/service/LotteryAIPriceService.java index decf047..edd9a36 100644 --- a/src/main/java/com/ohlottery/service/LotteryAIPriceService.java +++ b/src/main/java/com/ohlottery/service/LotteryAIPriceService.java @@ -5,19 +5,15 @@ import java.io.BufferedReader; import java.io.InputStreamReader; -import java.net.URL; @Service @RequiredArgsConstructor public class LotteryAIPriceService { - private final URL scriptURL - = getClass().getClassLoader().getResource("ai/lottery_prediction.py"); - public String executePythonPredictionScript() { try { // Python 스크립트 실행 - ProcessBuilder processBuilder = new ProcessBuilder("python3", scriptURL.getPath()); + ProcessBuilder processBuilder = new ProcessBuilder("python3", "/app/ai/lottery_prediction.py"); processBuilder.redirectErrorStream(true); Process process = processBuilder.start(); @@ -31,7 +27,7 @@ public String executePythonPredictionScript() { int exitCode = process.waitFor(); if (exitCode != 0) { - throw new RuntimeException("Python 스크립트 실행 실패. Exit code: " + exitCode); + throw new RuntimeException("Python 스크립트 실행 실패. Exit code(" + exitCode + "), " + output); } return output.toString();