diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index 8701c522..c9e6fbb9 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -6,16 +6,15 @@ on: - dev jobs: - deploy: + build-and-deploy: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - - name: JDK 17 설정 + - name: JDK 21 설정 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'zulu' - name: gradlew 실행 권한 부여 @@ -24,22 +23,119 @@ jobs: - name: JAR 빌드 run: ./gradlew clean build - - name: JAR를 EC2로 전송 + - name: 빌드된 JAR 파일 확인 + run: | + echo "빌드된 JAR 파일 목록:" + find service/*/build/libs -name "*.jar" + + - name: 변경된 서비스 확인 + id: check_changes + uses: dorny/paths-filter@v2 + with: + filters: | + restaurant-exposure: + - 'service/restaurant-exposure-service/**' + search: + - 'service/search-service/**' + cache: + - 'service/cache-service/**' + advertisement: + - 'service/advertisement-service/**' + coupon: + - 'service/coupon-service/**' + delivery-time: + - 'service/delivery-time-service/**' + restaurant: + - 'service/restaurant-service/**' + + - name: SSH 키 설정 env: PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }} - HOST: ${{ secrets.DEV_EC2_HOST }} + run: | + echo "$PRIVATE_KEY" > private_key + chmod 600 private_key + + - name: 가게노출 서비스 배포 + if: steps.check_changes.outputs.restaurant-exposure == 'true' + env: + HOST: ${{ secrets.DEV_EC2_HOST1 }} USER: ${{ secrets.DEV_EC2_USER }} run: | - echo "$PRIVATE_KEY" > private_key && chmod 600 private_key - scp -o StrictHostKeyChecking=no -i private_key mono/build/libs/*.jar ${USER}@${HOST}:~/app.jar + scp -o StrictHostKeyChecking=no -i private_key service/restaurant-exposure-service/build/libs/*.jar ${USER}@${HOST}:~/restaurant-exposure-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar restaurant-exposure-service.jar' || true + rm -rf estaurant-exposure-service.log + source ~/.bash_profile + nohup java -jar restaurant-exposure-service.jar --spring.profiles.active=dev > restaurant-exposure-service.log 2>&1 & + EOF - - name: EC2에서 JAR 실행 + - name: 검색 서비스 배포 + if: steps.check_changes.outputs.search == 'true' env: - PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }} - HOST: ${{ secrets.DEV_EC2_HOST }} + HOST: ${{ secrets.DEV_EC2_HOST2 }} USER: ${{ secrets.DEV_EC2_USER }} run: | + scp -o StrictHostKeyChecking=no -i private_key service/search-service/build/libs/*.jar ${USER}@${HOST}:~/search-service.jar ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF - pkill -f 'java -jar app.jar --spring.profiles.active=dev' || true - nohup java -jar app.jar --spring.profiles.active=dev > app.log 2>&1 & - EOF \ No newline at end of file + pkill -f 'java -jar search-service.jar' || true + rm -rf search-service.log + source ~/.bash_profile + nohup java -jar search-service.jar --spring.profiles.active=dev > search-service.log 2>&1 & + EOF + + - name: 기타 서비스 배포 + if: | + steps.check_changes.outputs.cache == 'true' || + steps.check_changes.outputs.advertisement == 'true' || + steps.check_changes.outputs.coupon == 'true' || + steps.check_changes.outputs.delivery-time == 'true' || + steps.check_changes.outputs.restaurant == 'true' + env: + HOST: ${{ secrets.DEV_EC2_HOST3 }} + USER: ${{ secrets.DEV_EC2_USER }} + run: | + if [[ "${{ steps.check_changes.outputs.cache }}" == 'true' ]]; then + scp -o StrictHostKeyChecking=no -i private_key service/cache-service/build/libs/*.jar ${USER}@${HOST}:~/cache-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar cache-service.jar' || true + rm -rf cache-service.log + source ~/.bash_profile + nohup java -jar cache-service.jar --spring.profiles.active=dev > cache-service.log 2>&1 & + EOF + fi + if [[ "${{ steps.check_changes.outputs.advertisement }}" == 'true' ]]; then + scp -o StrictHostKeyChecking=no -i private_key service/advertisement-service/build/libs/*.jar ${USER}@${HOST}:~/advertisement-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar advertisement-service.jar' || true + rm -rf advertisement-service.log + source ~/.bash_profile + nohup java -jar advertisement-service.jar --spring.profiles.active=dev > advertisement-service.log 2>&1 & + EOF + fi + if [[ "${{ steps.check_changes.outputs.coupon }}" == 'true' ]]; then + scp -o StrictHostKeyChecking=no -i private_key service/coupon-service/build/libs/*.jar ${USER}@${HOST}:~/coupon-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar coupon-service.jar' || true + rm -rf coupon-service.log + source ~/.bash_profile + nohup java -jar coupon-service.jar --spring.profiles.active=dev > coupon-service.log 2>&1 & + EOF + fi + if [[ "${{ steps.check_changes.outputs.delivery-time }}" == 'true' ]]; then + scp -o StrictHostKeyChecking=no -i private_key service/delivery-time-service/build/libs/*.jar ${USER}@${HOST}:~/delivery-time-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar delivery-time-service.jar' || true + rm -rf delivery-time-service.log + source ~/.bash_profile + nohup java -jar delivery-time-service.jar --spring.profiles.active=dev > delivery-time-service.log 2>&1 & + EOF + fi + if [[ "${{ steps.check_changes.outputs.restaurant }}" == 'true' ]]; then + scp -o StrictHostKeyChecking=no -i private_key service/restaurant-service/build/libs/*.jar ${USER}@${HOST}:~/restaurant-service.jar + ssh -o StrictHostKeyChecking=no -i private_key ${USER}@${HOST} << EOF + pkill -f 'java -jar restaurant-service.jar' || true + rm -rf restaurant-service.log + source ~/.bash_profile + nohup java -jar restaurant-service.jar --spring.profiles.active=dev > restaurant-service.log 2>&1 & + EOF + fi diff --git a/service/cache-service/src/main/resources/application.yml b/service/cache-service/src/main/resources/application.yml index 936482ab..158ce1c8 100644 --- a/service/cache-service/src/main/resources/application.yml +++ b/service/cache-service/src/main/resources/application.yml @@ -27,6 +27,7 @@ spring: redis: host: localhost port: 6379 + external-api: cache-service: endpoints: http://localhost:7001/api/v1/cache @@ -43,13 +44,18 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: database-platform: org.hibernate.dialect.MySQLDialect - show-sql: true - properties: - hibernate: - format_sql: true - hibernate: - ddl-auto: none + data: + redis: + host: ${REDIS_HOST} + port: ${REDIS_PORT} + password: ${REDIS_PASSWORD} + +external-api: + cache-service: + endpoints: ${CACHE_SERVICE_ENDPOINT} + --- + spring: config: activate: diff --git a/service/coupon-service/build.gradle b/service/coupon-service/build.gradle index 264665f3..4e46585e 100644 --- a/service/coupon-service/build.gradle +++ b/service/coupon-service/build.gradle @@ -23,6 +23,9 @@ repositories { mavenCentral() } +bootJar.enabled = true +jar.enabled = false + dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' diff --git a/service/restaurant-exposure-service/src/main/resources/application.yml b/service/restaurant-exposure-service/src/main/resources/application.yml index d63c92a5..5abf3602 100644 --- a/service/restaurant-exposure-service/src/main/resources/application.yml +++ b/service/restaurant-exposure-service/src/main/resources/application.yml @@ -24,18 +24,6 @@ spring: hibernate: ddl-auto: none - elasticsearch: - uris: http://localhost:9200 - username: elastic - password: your_elastic_password - data: - elasticsearch: - repositories: - enabled: true - redis: - host: localhost - port: 6379 - logging: level: tracer: TRACE @@ -66,13 +54,25 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: database-platform: org.hibernate.dialect.MySQLDialect - show-sql: true - properties: - hibernate: - format_sql: true hibernate: ddl-auto: none + +external-api: + advertisement-service: + endpoints: ${ADVERTISEMENT_SERVICE_ENDPOINT} + coupon-service: + endpoints: ${COUPON_SERVICE_ENDPOINT} + delivery-service: + endpoints: ${DELIVERY_SERVICE_ENDPOINT} + cache-service: + endpoints: ${CACHE_SERVICE_ENDPOINT} + restaurant-service: + endpoints: ${RESTAURANT_SERVICE_ENDPOINT} + search-service: + endpoints: ${SEARCH_SERVICE_ENDPOINT} + --- + spring: config: activate: diff --git a/service/restaurant-service/src/main/resources/application.yml b/service/restaurant-service/src/main/resources/application.yml index 5195fbfd..04380b7e 100644 --- a/service/restaurant-service/src/main/resources/application.yml +++ b/service/restaurant-service/src/main/resources/application.yml @@ -24,22 +24,6 @@ spring: hibernate: ddl-auto: none - elasticsearch: - uris: http://localhost:9200 - username: elastic - password: your_elastic_password - data: - elasticsearch: - repositories: - enabled: true - redis: - host: localhost - port: 6379 - -logging: - level: - tracer: TRACE - --- spring: config: @@ -52,10 +36,6 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: database-platform: org.hibernate.dialect.MySQLDialect - show-sql: true - properties: - hibernate: - format_sql: true hibernate: ddl-auto: none elasticsearch: @@ -67,6 +47,7 @@ spring: repositories: enabled: true --- + spring: config: activate: diff --git a/service/search-service/src/main/resources/application.yml b/service/search-service/src/main/resources/application.yml index 03217478..51c96808 100644 --- a/service/search-service/src/main/resources/application.yml +++ b/service/search-service/src/main/resources/application.yml @@ -24,18 +24,10 @@ spring: format_sql: true hibernate: ddl-auto: none - elasticsearch: uris: http://localhost:9200 username: elastic password: your_elastic_password - data: - elasticsearch: - repositories: - enabled: true - redis: - host: localhost - port: 6379 logging: level: @@ -61,7 +53,6 @@ spring: elasticsearch: uris: ${ELASTICSEARCH_URL} username: ${ELASTICSEARCH_USERNAME} - password: ${ELASTICSEARCH_PASSWORD} data: elasticsearch: repositories: @@ -70,12 +61,8 @@ spring: password: ${REDIS_PASSWORD} external-api: - advertisement-service: - endpoints: http://localhost:8083/api/v1/advertisements - coupon-service: - endpoints: http://localhost:8082/api/v1/coupons - delivery-service: - endpoints: http://localhost:8081/api/v1/deliveries + search-service: + endpoints: ${SEARCH_SERVICE_ENDPOINT} ---