Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
28 changes: 28 additions & 0 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: discovery-service dev CD 파이프라인

on:
workflow_run:
workflows: ["discovery-service CI pipeline"]
types:
- completed

jobs:
deploy:
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 discovery-service-dev || true
docker compose pull discovery-service-dev
docker compose up -d --no-deps --force-recreate --pull always discovery-service-dev
docker image prune -f
28 changes: 28 additions & 0 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: discovery-service prod CD 파이프라인

on:
workflow_run:
workflows: ["discovery-service CI pipeline"]
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
environment: dev
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 discovery-service-prod || true
docker compose pull discovery-service-prod
docker compose up -d --no-deps --force-recreate --pull always discovery-service-prod
docker image prune -f
46 changes: 46 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: discovery-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-discovery-service:latest
push: true
5 changes: 5 additions & 0 deletions Dockerfile
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"]
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ dependencyManagement {

tasks.named('test') {
useJUnitPlatform()
systemProperty "spring.profiles.active", "test"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class DiscoveryServiceApplication {

public static void main(String[] args) {
Expand Down
15 changes: 15 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
port: 8761

spring:
application:
name: discovery-service-dev

eureka:
client:
register-with-eureka: false
fetch-registry: false

server:
wait-time-in-ms-when-sync-empty: 0 # 초기 레지스트리 정보가 비어 있어도 지연 없이 즉시 서버 시작
response-cache-update-interval-ms: 30000 # 클라이언트에게 제공할 서비스 목록 캐시를 30초마다 갱신
15 changes: 15 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
port: 8761

spring:
application:
name: discovery-service

eureka:
client:
register-with-eureka: false
fetch-registry: false

server:
wait-time-in-ms-when-sync-empty: 0 # ?? ????? ??? ?? ??? ?? ?? ?? ?? ??
response-cache-update-interval-ms: 30000 # ??????? ??? ??? ?? ??? 30??? ??
Copy link
Member

Choose a reason for hiding this comment

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

주석으로 남겨주신 내용은 어떤 의미일까요 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

아 주석이 ?로 되어있었네요!! 주석 수정해놓았습니다.

우선 wait-time-in-ms-when-sync-empty: 0의 경우 서버가 동작할 때 레지스트리가 비어 있는 상태라면 얼마의 시간동안 응답을 지연할지 정하는 부분입니다. 즉, 0으로 설정할 경우 바로 서비스를 시작한다는 의미입니다.
다음으로 eureka.server.response-cache-update-interval-ms:30000의 경우 유레카 서버가 유지하는 읽기 전용 응답 캐시를 갱신하는 주기입니다. 즉, 등록과 해제가 일어나면 최대 30초 지연될 수 있다는 의미입니다.

15 changes: 15 additions & 0 deletions src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
port: 8761

spring:
application:
name: discovery-service-prod

eureka:
client:
register-with-eureka: false
fetch-registry: false

server:
wait-time-in-ms-when-sync-empty: 0 # 초기 레지스트리 정보가 비어 있어도 지연 없이 즉시 서버 시작
response-cache-update-interval-ms: 30000 # 클라이언트에게 제공할 서비스 목록 캐시를 30초마다 갱신
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

8 changes: 8 additions & 0 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
spring:
application:
name: discovery-service-test

eureka:
client:
register-with-eureka: false
fetch-registry: false