Skip to content

Commit

Permalink
[IDLE-248] config: Dockerfile 수정 및 shell script 추가
Browse files Browse the repository at this point in the history
- fargate 동작시, eureka 서버에 private ip가 아닌 메타데이터의 ip가 등록된다.
- shell script를 통해 런타임 시점에서 메타데이터 ip에 등록된 private ip를 가져오도록 함.
- with @0112leesy
  • Loading branch information
minnseong committed Aug 31, 2023
1 parent dd1e193 commit 2a9e8ad
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion backend/book-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM openjdk:21-ea-17-jdk-slim
COPY build/libs/book-service-0.0.1-SNAPSHOT.jar book-service.jar
CMD ["java", "-jar", "book-service.jar"]

RUN apt update && apt install curl -y && apt install jq -y
COPY entrypoint.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
7 changes: 7 additions & 0 deletions backend/book-service/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

response=$(curl -s ${ECS_CONTAINER_METADATA_URI_V4})
export ECS_INSTANCE_IP_ADDRESS=$(echo $response | jq -r '.Networks[0].IPv4Addresses[0]')
echo $ECS_INSTANCE_IP_ADDRESS

java -jar book-service.jar
7 changes: 6 additions & 1 deletion backend/user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM openjdk:21-ea-17-jdk-slim
COPY build/libs/user-service-0.0.1-SNAPSHOT.jar user-service.jar
CMD ["java", "-jar", "user-service.jar"]

RUN apt update && apt install curl -y && apt install jq -y
COPY entrypoint.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
7 changes: 7 additions & 0 deletions backend/user-service/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

response=$(curl -s ${ECS_CONTAINER_METADATA_URI_V4})
export ECS_INSTANCE_IP_ADDRESS=$(echo $response | jq -r '.Networks[0].IPv4Addresses[0]')
echo $ECS_INSTANCE_IP_ADDRESS

java -jar user-service.jar

0 comments on commit 2a9e8ad

Please sign in to comment.