-
Notifications
You must be signed in to change notification settings - Fork 0
[EDMT-454] Docker 엔트리포인트 JAVA_OPTS 설정 개선 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
58cd3e6
20d25c7
7e61716
3a7115c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM eclipse-temurin:21-jdk-alpine | ||
| ARG JAR_FILE=build/libs/edukit-api.jar | ||
| COPY ${JAR_FILE} app.jar | ||
| ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-Dspring.profiles.active=dev", "-jar", "/app.jar"] | ||
| ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| FROM eclipse-temurin:21-jdk-alpine | ||
| ARG JAR_FILE=build/libs/edukit-api.jar | ||
| COPY ${JAR_FILE} app.jar | ||
| ENTRYPOINT ["java", "-Duser.timezone=Asia/Seoul", "-Dspring.profiles.active=prod", "-jar", "/app.jar"] | ||
| ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,19 +6,16 @@ services: | |||||
| PROFILE: dev | ||||||
| TZ: Asia/Seoul | ||||||
| HOSTNAME: ${HOSTNAME_BLUE:-dev-1-blue} | ||||||
| JAVA_OPTS: "-javaagent:/app/jmx_prometheus_javaagent.jar=9081:/app/jmx-config.yml" | ||||||
| ports: | ||||||
| - "8080:8080" | ||||||
| - "9081:9081" | ||||||
| env_file: | ||||||
| - .env | ||||||
| restart: always | ||||||
| volumes: | ||||||
| - ./log/blue:/log | ||||||
| - /opt/jmx_prometheus_javaagent.jar:/app/jmx_prometheus_javaagent.jar | ||||||
| - ./jmx-config.yml:/app/jmx-config.yml | ||||||
| networks: | ||||||
| - app-network | ||||||
| entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dev 환경도 동일하게 exec 적용 필요 dev compose 역시 - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]Also applies to: 36-36 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| app-green: | ||||||
| container_name: app-green | ||||||
|
|
@@ -27,19 +24,16 @@ services: | |||||
| PROFILE: dev | ||||||
| TZ: Asia/Seoul | ||||||
| HOSTNAME: ${HOSTNAME_GREEN:-dev-1-green} | ||||||
| JAVA_OPTS: "-javaagent:/app/jmx_prometheus_javaagent.jar=9082:/app/jmx-config.yml" | ||||||
| ports: | ||||||
| - "8081:8080" | ||||||
| - "9082:9082" | ||||||
| env_file: | ||||||
| - .env | ||||||
| restart: always | ||||||
| volumes: | ||||||
| - ./log/green:/log | ||||||
| - /opt/jmx_prometheus_javaagent.jar:/app/jmx_prometheus_javaagent.jar | ||||||
| - ./jmx-config.yml:/app/jmx-config.yml | ||||||
| networks: | ||||||
| - app-network | ||||||
| entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainapp-green도 동일 이슈 — 동일한 수정 적용 필요 아래와 같이 - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]app-green 서비스의 entrypoint 동일 여부 확인을 위해 아래 명령어 실행합니다. 🏁 Script executed: #!/bin/bash
rg -n "entrypoint" -C3 docker-compose.dev.ymlLength of output: 520 app-green 서비스에도 exec 적용 필요 - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=dev -jar /app.jar"]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| nginx: | ||||||
| container_name: nginx | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,19 +6,16 @@ services: | |||||
| PROFILE: prod | ||||||
| TZ: Asia/Seoul | ||||||
| HOSTNAME: ${HOSTNAME_BLUE:-prod-1-blue} | ||||||
| JAVA_OPTS: "-javaagent:/app/jmx_prometheus_javaagent.jar=9081:/app/jmx-config.yml" | ||||||
| ports: | ||||||
| - "8080:8080" | ||||||
| - "9081:9081" | ||||||
| env_file: | ||||||
| - .env | ||||||
| restart: always | ||||||
| volumes: | ||||||
| - ./log/blue:/log | ||||||
| - /opt/jmx_prometheus_javaagent.jar:/app/jmx_prometheus_javaagent.jar | ||||||
| - ./jmx-config.yml:/app/jmx-config.yml | ||||||
| networks: | ||||||
| - app-network | ||||||
| entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 쉘 entrypoint로 인한 신호 전달 및 명령 인젝션 위험 수정 필요 현재 - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]Also applies to: 36-36 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| app-green: | ||||||
| container_name: app-green | ||||||
|
|
@@ -27,19 +24,16 @@ services: | |||||
| PROFILE: prod | ||||||
| TZ: Asia/Seoul | ||||||
| HOSTNAME: ${HOSTNAME_GREEN:-prod-1-green} | ||||||
| JAVA_OPTS: "-javaagent:/app/jmx_prometheus_javaagent.jar=9082:/app/jmx-config.yml" | ||||||
| ports: | ||||||
| - "8081:8080" | ||||||
| - "9082:9082" | ||||||
| env_file: | ||||||
| - .env | ||||||
| restart: always | ||||||
| volumes: | ||||||
| - ./log/green:/log | ||||||
| - /opt/jmx_prometheus_javaagent.jar:/app/jmx_prometheus_javaagent.jar | ||||||
| - ./jmx-config.yml:/app/jmx-config.yml | ||||||
| networks: | ||||||
| - app-network | ||||||
| entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Verification inconclusiveprod app-green: 동일 수정 적용 필요 다음과 같이 - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]prod app-green: entrypoint에 exec 추가 필요 sh -c로 java를 실행하면 PID 1이 쉘이 되어 시그널 전달·종료 처리 문제가 발생할 수 있습니다. exec로 대체하세요. - entrypoint: ["sh", "-c", "java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]
+ entrypoint: ["sh", "-c", "exec java $$JAVA_OPTS -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -jar /app.jar"]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| nginx: | ||||||
| container_name: nginx | ||||||
|
|
||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Verification inconclusive
프로덕션 이미지에서의 sh -c는 보안/신호 전달 리스크 — exec 추가 또는 JAVA_TOOL_OPTIONS로 전환 필요
JAVA_TOOL_OPTIONS로 옵션을 주입해 쉘을 제거하는 구성을 권장합니다.프로덕션 Dockerfile: ENTRYPOINT에서 sh -c 제거 — 신호 전달·쉘 인젝션 위험 (긴급 수정 필요)
sh -c 사용 시 PID 1로서 SIGTERM/SIGINT 등이 자식 JVM으로 직접 전달되지 않으며, $JAVA_OPTS 같은 환경변수 확장으로 쉘 인젝션 위험이 있음.
최소 변경(신호 전달 보장):
권장(쉘 제거 — 안전·명시적 인수 전달):
운영 권장: 옵션은 JAVA_TOOL_OPTIONS로 주입하여 쉘을 제거한 exec 형식으로 실행. 파일: Dockerfile-prod (라인 4)
📝 Committable suggestion
🤖 Prompt for AI Agents