-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#1 CI/CD 구축 및 Netflix Eureka Client(Gateway) 설정 #2
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
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
84a6ab0
feat: Dockerfile 작성
1winhyun 328c3c5
feat: ci 및 ci-dev 작성
1winhyun 065d2a2
feat: application-local,dev 작성
1winhyun 025222d
feat: 게이트웨이 라우트 구현
1winhyun 69defe5
feat: 다른 서비스, api 호출 시 사용하기 위한 빈 구현
1winhyun 98bd457
feat: cors 설정 및 의존성 수정
1winhyun e841c55
refactor: 라우트 설정 수정
1winhyun 7edc481
feat: cd-prod 작성
1winhyun 8bdeae5
fet: prod 서버 리소스 파일 작성
1winhyun cba66d1
refactor: prod 리소스 파일 eureka client defaultzone 수정
1winhyun e8ab40e
refactor: prod 서버 eureka client defaultzone 수정
1winhyun d5ee785
refactor: 게이트웨이 라우트 설정 prod에 적용되도록 수정
1winhyun f1fadb2
refactor: 스웨거를 위한 라우트 설정
1winhyun 1e18f6b
refactor: 스웨거 urls 등록을 위한 dev 리소스 파일 수정
1winhyun cde3e4b
refactor: 오타 수정
1winhyun ee57b7e
refactor: local, prod 리소스 파일 스웨거 경로 추가
1winhyun 98548ce
refactor: cd-prod environment 수정
1winhyun 0bc45eb
refactor: ci 성공시에만 cd 동작하도록 수정
1winhyun b92874b
refactor: GatewayConfiguration 경로 수정
1winhyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: gateway-service dev CD 파이프라인 | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["gateway-service CI pipeline"] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| deploy: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| runs-on: ubuntu-latest | ||
| environment: dev | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Docker 이미지 dev 서버 배포 | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{secrets.DEV_HOST}} | ||
| username: ${{secrets.DEV_USERNAME}} | ||
| key: ${{secrets.DEV_KEY}} | ||
| script: | | ||
| cd /home/ubuntu | ||
| docker rm -f gateway-service-dev || true | ||
| docker compose pull gateway-service-dev | ||
| docker compose up -d --no-deps --force-recreate --pull always gateway-service-dev | ||
| docker image prune -f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: gateway-service prod CD 파이프라인 | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["gateway-service CI pipeline"] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| deploy: | ||
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
| runs-on: ubuntu-latest | ||
| environment: prod | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Docker 이미지 dev 서버 배포 | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{secrets.PROD_HOST}} | ||
| username: ${{secrets.PROD_USERNAME}} | ||
| key: ${{secrets.PROD_KEY}} | ||
| script: | | ||
| cd /home/ubuntu | ||
| docker rm -f gateway-service-prod || true | ||
| docker compose pull gateway-service-prod | ||
| docker compose up -d --no-deps --force-recreate --pull always gateway-service-prod | ||
| docker image prune -f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: gateway-service CI pipeline | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - dev | ||
| pull_request: | ||
| branches: | ||
| - dev | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| environment: production | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: jdk 설정 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
| cache: 'gradle' | ||
|
|
||
| - name: Gradle Wrapper 권한 부여 | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: gradle 빌드 | ||
| run: ./gradlew clean build | ||
|
|
||
| - name: 도커 로그인 | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | ||
|
|
||
| - name: 이미지 빌드 및 푸시 | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| tags: ${{ secrets.DOCKER_USERNAME }}/unionmate-gateway-service:latest | ||
| push: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM openjdk:21-jdk | ||
|
|
||
| COPY build/libs/*SNAPSHOT.jar app.jar | ||
|
|
||
| ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -Dspring.profiles.active=${PROFILE} -jar /app.jar"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/unionmate/gateway_service/global/SecurityConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.unionmate.gateway_service.global; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.cors.CorsConfiguration; | ||
| import org.springframework.web.cors.reactive.CorsWebFilter; | ||
| import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; | ||
|
|
||
| @Configuration | ||
| public class SecurityConfig { | ||
| @Bean | ||
| public CorsWebFilter corsWebFilter() { | ||
| CorsConfiguration config = new CorsConfiguration(); | ||
| config.setAllowedOrigins(List.of("http://localhost:3000")); | ||
| config.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS")); | ||
| config.setAllowCredentials(true); | ||
| config.setAllowedHeaders(List.of("*")); | ||
| config.setExposedHeaders(List.of("Authorization", "Authorization-refresh")); | ||
|
|
||
| UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
| source.registerCorsConfiguration("/**", config); | ||
|
|
||
| return new CorsWebFilter(source); | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
src/main/java/com/unionmate/gateway_service/global/gateway/GatewayConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.unionmate.gateway_service.global.gateway; | ||
|
|
||
| import org.springframework.cloud.gateway.route.RouteLocator; | ||
| import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Profile; | ||
| import org.springframework.http.HttpHeaders; | ||
|
|
||
| @Configuration | ||
| @Profile({"local","dev","prod"}) | ||
| public class GatewayConfiguration { | ||
|
|
||
| @Bean | ||
| public RouteLocator customRouteLocator(RouteLocatorBuilder builder) { | ||
| return builder.routes() | ||
| // 인증 필요 없는 라우트 | ||
| // path 경로는 추후 개발에 진행되며 수정될 예정 | ||
| .route("backend_route", r -> r.path("/back") | ||
| .filters(f -> f | ||
| .removeRequestHeader(HttpHeaders.COOKIE) | ||
| ) | ||
| .uri("lb://backend-service")) | ||
|
|
||
| //스웨거를 위한 라우트 설정(각 서비스마다 등록해줘야 합니다.) | ||
| .route("backend-service_api_docs", r -> r.path("/api-docs/backend/**") | ||
| .filters(f -> f | ||
| .rewritePath("/api-docs/backend/(?<rem>.*)", "/${rem}") | ||
| ) | ||
| .uri("lb://backend-service")) | ||
| .build(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| server: | ||
| port: 8000 | ||
|
|
||
| spring: | ||
| main: | ||
| web-application-type: reactive | ||
| application: | ||
| name: gateway-service | ||
|
|
||
| eureka: | ||
| client: | ||
| fetch-registry: true | ||
| register-with-eureka: true | ||
| service-url: | ||
| defaultZone: http://3.34.87.16:8761/eureka | ||
|
|
||
| springdoc: | ||
| api-docs: | ||
| enabled: true | ||
| swagger-ui: | ||
| path: /swagger-ui.html | ||
| urls: | ||
| - name: backend-service | ||
| url: /api-docs/backend/v3/api-docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| server: | ||
| port: 8000 | ||
|
|
||
| spring: | ||
| main: | ||
| web-application-type: reactive | ||
| application: | ||
| name: gateway-service | ||
|
|
||
| eureka: | ||
| client: | ||
| fetch-registry: true | ||
| register-with-eureka: true | ||
| service-url: | ||
| defaultZone: http://localhost:8761/eureka | ||
|
|
||
| springdoc: | ||
| api-docs: | ||
| enabled: true | ||
| swagger-ui: | ||
| path: /swagger-ui.html | ||
| urls: | ||
| - name: backend-service | ||
| url: /api-docs/backend/v3/api-docs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| server: | ||
| port: 8000 | ||
|
|
||
| spring: | ||
| main: | ||
| web-application-type: reactive | ||
| application: | ||
| name: gateway-service | ||
|
|
||
| eureka: | ||
| client: | ||
| fetch-registry: true | ||
| register-with-eureka: true | ||
| service-url: | ||
| defaultZone: http://discovery-service-prod:8761/eureka | ||
|
|
||
| springdoc: | ||
| api-docs: | ||
| enabled: true | ||
| swagger-ui: | ||
| path: /swagger-ui.html | ||
| urls: | ||
| - name: backend-service | ||
| url: /api-docs/backend/v3/api-docs | ||
|
|
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.