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

on:
workflow_run:
workflows: ["discovery-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 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
29 changes: 29 additions & 0 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: discovery-service prod CD 파이프라인

on:
workflow_run:
workflows: ["discovery-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 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초마다 갱신
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