From c1cd73c6f87e7e796b324d3825dd670d0e1b1b84 Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 20:47:32 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[chore]=20.gitignore=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 334c155a..6b057539 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,7 @@ out/ .vscode/ ### project +*.sh +*.yml *.yaml *.properties From 960ea94d353240f857b5225f856ffc779d60e4fd Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 20:49:58 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[build]=20mysql,=20redis=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=84=A4=EC=A0=95=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.gradle b/build.gradle index bec0f35a..f74bd3cb 100644 --- a/build.gradle +++ b/build.gradle @@ -33,6 +33,15 @@ dependencies { implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0' annotationProcessor 'com.github.therapi:therapi-runtime-javadoc-scribe:0.13.0' implementation 'com.github.therapi:therapi-runtime-javadoc:0.13.0' + + // mysql + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-jdbc' + runtimeOnly 'com.mysql:mysql-connector-j' + + // redis + implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation 'org.springframework.data:spring-data-redis' } tasks.named('test') { From 4bbf0e264c2db0feda8d05c69d605280edde7c76 Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 20:50:28 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[build]=20Dockerfile=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8e3e5f40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Use OpenJDK 17 as the base image +FROM openjdk:17 + +# Specify the build argument for the JAR file +ARG JAR_FILE=build/libs/*.jar + +# Copy the JAR file into the container +COPY ${JAR_FILE} app.jar + +# Set the entry point to run the JAR file +ENTRYPOINT ["java", "-jar", "/app.jar"] From e13e1af459c0eb17a5221dc89f317547d2f49226 Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 21:26:07 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[infra]=20CI/CD=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=20=EC=9E=91=EC=84=B1=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 00000000..a4011ee3 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,54 @@ +# CI/CD workflow +name: CI/CD + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + +permissions: + contents: read + +jobs: + CI: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v1 + + # TODO: 추후 테스트코드 작성 후 테스트 실패 시 CI 불가능하도록 수정 + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Docker Login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build Docker Image + run: docker build --platform linux/amd64 -t ${{ secrets.DOCKERHUB_USERNAME }}/orange . + + - name: Push Docker Image + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/orange + + CD: + runs-on: self-hosted + needs: CI + + steps: + - name: Remove Docker Container + run: sudo docker rm -f orange || true + + - name: Run Updated Docker Container + run: sudo docker run -t --env-file ./.env -d --name orange -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/orange From 0f4b22489d30ec5b9713d16160366adf13bc9eff Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 21:51:51 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[infra]=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=9D=BC=EB=B6=80=20=ED=91=9C=ED=98=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a4011ee3..b10ae99e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -24,7 +24,7 @@ jobs: distribution: 'temurin' - name: Setup Gradle - uses: gradle/actions/setup-gradle@v1 + uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 # TODO: 추후 테스트코드 작성 후 테스트 실패 시 CI 불가능하도록 수정 - name: Build with Gradle From ee5656fa82d05c6e5a7777c7ff241cbc4bc1ca29 Mon Sep 17 00:00:00 2001 From: win-luck Date: Sat, 27 Jul 2024 21:57:15 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[infra]=20Merge=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=EB=90=98=EC=97=88=EC=9D=84=20=EB=95=8C=EB=A7=8C=20CD=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b10ae99e..c761d11d 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -43,6 +43,7 @@ jobs: run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/orange CD: + if: github.event.pull_request.merged == true && github.ref == 'refs/heads/dev' runs-on: self-hosted needs: CI