Skip to content

Commit

Permalink
Merge pull request #25 from f-lab-edu/feature/23
Browse files Browse the repository at this point in the history
[#23] 컨테이너 기반 실행을 위해 Docker 도입
  • Loading branch information
hyeok-kong authored Jun 6, 2024
2 parents 1678071 + 695289c commit de69f7c
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 2 deletions.
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
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}}

0 comments on commit de69f7c

Please sign in to comment.