Skip to content
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

[#23] 컨테이너 기반 실행을 위해 Docker 도입 #25

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 빌드 환경 구성
FROM amazoncorretto:21
WORKDIR /workspace/app

# JAR 파일 복사
COPY ./build/libs/api-gateway-0.0.1-SNAPSHOT.jar /workspace/app/api-gateway.jar
COPY ./src/main/resources/application.yml /workspace/app
COPY ./src/main/resources/application-route.yml /workspace/app

ENTRYPOINT ["java", "-jar", "api-gateway.jar", "--spring.config.location=file:/workspace/app/application.yml"]
57 changes: 57 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3'
services:
eureka-discovery:
build:
context: ./eureka-discovery
dockerfile: Dockerfile
container_name: eureka-discovery
ports:
- "8761:8761"
networks:
- eureka-network

api-gateway:
build:
context: ./api-gateway
dockerfile: Dockerfile
container_name: api-gateway
ports:
- "8080:8080"
environment:
- EUREKA_SERVER_URI=http://eureka-discovery:8761/eureka/
depends_on:
- eureka-discovery
networks:
- eureka-network

user-service:
build:
context: ./user-service
dockerfile: Dockerfile
container_name: user-service
ports:
- "8081:8081"
environment:
- EUREKA_SERVER_URI=http://eureka-discovery:8761/eureka/
depends_on:
- eureka-discovery
networks:
- eureka-network

group-service:
build:
context: ./group-service
dockerfile: Dockerfile
container_name: group-service
ports:
- "8082:8082"
environment:
- EUREKA_SERVER_URI=http://eureka-discovery:8761/eureka/
depends_on:
- eureka-discovery
networks:
- eureka-network

networks:
eureka-network:
driver: bridge
9 changes: 9 additions & 0 deletions eureka-discovery/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 빌드 환경 구성
FROM amazoncorretto:21
WORKDIR /workspace/app

# JAR 파일 복사
COPY ./build/libs/eureka-discovery-0.0.1-SNAPSHOT.jar /workspace/app/eureka-discovery.jar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COPY문을 여러번 쓰는 것 vs 한줄에 쓰는 것에 대한 차이를 조사해보시면 좋습니다.

COPY ./src/main/resources/application.yml /workspace/app

ENTRYPOINT ["java", "-jar", "eureka-discovery.jar", "--spring.config.location=file:/workspace/app/application.yml"]
10 changes: 10 additions & 0 deletions group-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 빌드 환경 구성
FROM amazoncorretto:21
WORKDIR /workspace/app

# JAR 파일 복사
COPY ./build/libs/group-service-0.0.1-SNAPSHOT.jar /workspace/app/group-service.jar
COPY ./src/main/resources/application.yml /workspace/app
COPY ./src/main/resources/application-route.yml /workspace/app

ENTRYPOINT ["java", "-jar", "group-service.jar", "--spring.config.location=file:/workspace/app/application.yml"]
1 change: 1 addition & 0 deletions group-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
runtimeOnly 'com.mysql:mysql-connector-j'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'me.kong:common-library:0.0.1-SNAPSHOT'
Expand Down
2 changes: 1 addition & 1 deletion group-service/src/main/resources/application-route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ eureka:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka
defaultZone: ${EUREKA_SERVER_URI}
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
10 changes: 10 additions & 0 deletions user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 빌드 환경 구성
FROM amazoncorretto:21
WORKDIR /workspace/app

# JAR 파일 복사
COPY ./build/libs/user-service-0.0.1-SNAPSHOT.jar /workspace/app/user-service.jar
COPY ./src/main/resources/application.yml /workspace/app
COPY ./src/main/resources/application-route.yml /workspace/app

ENTRYPOINT ["java", "-jar", "user-service.jar", "--spring.config.location=file:/workspace/app/application.yml"]
1 change: 1 addition & 0 deletions user-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation 'me.kong:common-library:0.0.1-SNAPSHOT'

implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
runtimeOnly 'com.mysql:mysql-connector-j'
}

dependencyManagement {
Expand Down
2 changes: 1 addition & 1 deletion user-service/src/main/resources/application-route.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ eureka:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka
defaultZone: ${EUREKA_SERVER_URI}
instance:
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
Loading