From ca3d104ea7c59718f9e1981226887675189def38 Mon Sep 17 00:00:00 2001 From: Kim Uijin <127496156+sansan20535@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:17:48 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20CI/CD=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Docker-CI-CD.yml | 66 ++++++++++++++++++++++++++++++ Dockerfile | 4 ++ build.gradle | 1 + 3 files changed, 71 insertions(+) create mode 100644 .github/workflows/Docker-CI-CD.yml create mode 100644 Dockerfile diff --git a/.github/workflows/Docker-CI-CD.yml b/.github/workflows/Docker-CI-CD.yml new file mode 100644 index 0000000..568f97a --- /dev/null +++ b/.github/workflows/Docker-CI-CD.yml @@ -0,0 +1,66 @@ +name: DOCKER-CD +on: + pull_request: + branches: [ "dev" ] + +jobs: + ci: + runs-on: ubuntu-22.04 + env: + working-directory: . + + steps: + - name: 체크아웃 + uses: actions/checkout@v3 + + - name: JDK 21 설치 + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '21' + + - name: application.yml 생성 + run: | + mkdir -p ./src/main/resources && cd $_ + touch ./application.yml + echo "${{ secrets.APPLICATION_DEV }}" > ./application.yml + cat ./application.yml + working-directory: ${{ env.working-directory }} + + - name: 빌드 + run: | + chmod +x gradlew + ./gradlew build -x test + working-directory: ${{ env.working-directory }} + shell: bash + + + - name: docker 로그인 + uses: docker/setup-buildx-action@v2.9.1 + + - name: docker hub 로그인 + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKER_LOGIN_USERNAME }} + password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }} + + - name: docker image 빌드 및 푸시 + run: | + docker build --platform linux/amd64 -t offroadserver/admin-web . + docker push offroadserver/admin-web + working-directory: ${{ env.working-directory }} + + cd: + needs: ci + runs-on: ubuntu-22.04 + + steps: + - name: docker 컨테이너 실행 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SERVER_IP }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SERVER_KEY }} + script: | + cd ~ + ./deploy.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f1544b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM amd64/amazoncorretto:17 +WORKDIR /app +COPY ./build/libs/Orb-admin-web-1.0.0-SNAPSHOT.jar /app/Orb-admin-web.jar +CMD ["java", "-Duser.timezone=Asia/Seoul", "-jar", "-Dspring.profiles.active=dev", "Orb-admin-web.jar"] diff --git a/build.gradle b/build.gradle index ee4e2b3..30c73c9 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,7 @@ dependencies { testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' implementation 'com.fasterxml.jackson.module:jackson-module-kotlin' + implementation 'org.springframework.boot:spring-boot-starter-actuator' //db implementation 'org.springframework.boot:spring-boot-starter-data-jpa' From d2f8284db99267c5d2eb2aa82c295b95a667e346 Mon Sep 17 00:00:00 2001 From: Kim Uijin <127496156+sansan20535@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:32:09 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=EC=8B=A4=ED=96=89=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0f1544b..dbc5c3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ FROM amd64/amazoncorretto:17 WORKDIR /app -COPY ./build/libs/Orb-admin-web-1.0.0-SNAPSHOT.jar /app/Orb-admin-web.jar +COPY ./build/libs/*.jar /app/Orb-admin-web.jar CMD ["java", "-Duser.timezone=Asia/Seoul", "-jar", "-Dspring.profiles.active=dev", "Orb-admin-web.jar"] From 220552a29bead671ef7c28e9b4cf357ed2bf7024 Mon Sep 17 00:00:00 2001 From: Kim Uijin <127496156+sansan20535@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:59:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20Dockerfile=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=EC=9D=84=2021=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Docker-CI-CD.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Docker-CI-CD.yml b/.github/workflows/Docker-CI-CD.yml index 568f97a..3c75958 100644 --- a/.github/workflows/Docker-CI-CD.yml +++ b/.github/workflows/Docker-CI-CD.yml @@ -1,4 +1,4 @@ -name: DOCKER-CD +name: DOCKER-CI-CD on: pull_request: branches: [ "dev" ] diff --git a/Dockerfile b/Dockerfile index dbc5c3a..62b5b08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM amd64/amazoncorretto:17 +FROM amd64/amazoncorretto:21 WORKDIR /app COPY ./build/libs/*.jar /app/Orb-admin-web.jar CMD ["java", "-Duser.timezone=Asia/Seoul", "-jar", "-Dspring.profiles.active=dev", "Orb-admin-web.jar"]