From f99aa0070f4073858da74cefe0aadfe3b190a51e Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 19:28:59 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20gitignore=EC=97=90=20.env=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= 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 fcc22047..754acf39 100644 --- a/.gitignore +++ b/.gitignore @@ -381,3 +381,5 @@ gradle-app.setting # End of https://www.toptal.com/developers/gitignore/api/macos,windows,intellij,intellij+iml,intellij+all,visualstudiocode,java,gradle,kotlin /db/ + +.env \ No newline at end of file From cd0428fc6244faf90350f000a1975f692419af4b Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 19:30:18 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20application-jpa=20sql=20init=20mode?= =?UTF-8?q?=20=ED=95=AD=EB=AA=A9=20always->never?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infrastructure/jpa/src/main/resources/application-jpa.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/jpa/src/main/resources/application-jpa.yaml b/infrastructure/jpa/src/main/resources/application-jpa.yaml index c7affc08..c8f9190f 100644 --- a/infrastructure/jpa/src/main/resources/application-jpa.yaml +++ b/infrastructure/jpa/src/main/resources/application-jpa.yaml @@ -17,7 +17,7 @@ spring: sql: init: - mode: always # 필요한 경우 'never'로 변경 + mode: never # 필요한 경우 'never'로 변경 server: port: 8080 From 5cfa6e9fcfa510a56f6920b3f18fd429ead625c7 Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 21:26:03 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EA=B0=9C=EB=B0=9C=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20db=20=EC=84=B8=ED=8C=85=20=EA=B0=92=EC=9D=84=20clou?= =?UTF-8?q?d=20db=20for=20mysql=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 --- docker-compose.yml | 74 ++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 262876be..5959c3a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,42 +1,40 @@ # docker-compose.yml services: - mysql: - container_name: spot-mysql - image: mysql:8 # 선호하는 버전 있을 경우 선정 예정! - ports: - - 3306:3306 # 혹시나 기존에 MySQL 사용 중일 경우 앞자리를 다른 포트로 바꿔야함. - volumes: - - ./db/mysql/data:/var/lib/mysql # 기존 데이터 파일과 격리를 위해 db/mysql/data 로 설정함! - command: - - '--character-set-server=utf8mb4' - - '--collation-server=utf8mb4_unicode_ci' - environment: - TZ : "Asia/Seoul" - MYSQL_ROOT_PASSWORD: test1234 # 임시 비밀번호 - MYSQL_DATABASE: spot # DB 이름 선정 시 변경 예정. - MYSQL_USER: test1234 # 임시 유저 - MYSQL_PASSWORD: test1234 # 임시 비밀번호 - healthcheck: # MySQL 서비스 상태 확인 - test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] - timeout: 20s - retries: 10 + mysql: + container_name: spot-mysql + image: mysql:8 # 선호하는 버전 있을 경우 선정 예정! + ports: + - 3306:3306 # 혹시나 기존에 MySQL 사용 중일 경우 앞자리를 다른 포트로 바꿔야함. + volumes: + - ./db/mysql/data:/var/lib/mysql # 기존 데이터 파일과 격리를 위해 db/mysql/data 로 설정함! + command: + - '--character-set-server=utf8mb4' + - '--collation-server=utf8mb4_unicode_ci' + environment: + TZ : "Asia/Seoul" + MYSQL_ROOT_PASSWORD: test1234 # 임시 비밀번호 + MYSQL_DATABASE: spot # DB 이름 선정 시 변경 예정. + MYSQL_USER: test1234 # 임시 유저 + MYSQL_PASSWORD: test1234 # 임시 비밀번호 + healthcheck: # MySQL 서비스 상태 확인 + test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + timeout: 20s + retries: 10 - server: - build: # 디렉토리에 있는 도커파일 이용해서 이미지 빌드 - context: . - dockerfile: Dockerfile.dev - container_name: spot-spring-server - ports: - - 8080:8080 - depends_on: # 항상 mysql 실행하고 서버 실행되게 함. - mysql: - condition: service_healthy # mysql 컨테이너의 healthcheck가 정상일 때까지 대기! - environment: - SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/spot - SPRING_DATASOURCE_USERNAME: test1234 - SPRING_DATASOURCE_PASSWORD: test1234 - volumes: - - ./:/app - - ~/.gradle:/root/.gradle - command: ./gradlew :application:bootRun \ No newline at end of file + server: + build: # 디렉토리에 있는 도커파일 이용해서 이미지 빌드 + context: . + dockerfile: Dockerfile.dev + container_name: spot-spring-server + ports: + - 8080:8080 + environment: + - SPRING_DATASOURCE_URL=${DB_URL} + - SPRING_DATASOURCE_USERNAME=${DB_USERNAME} + - SPRING_DATASOURCE_PASSWORD=${DB_PASSWORD} + - TZ=Asia/Seoul + volumes: + - ./:/app + - ~/.gradle:/root/.gradle + command: ./gradlew :application:bootRun \ No newline at end of file From 3eb28a81f4ab440db9b5edf0c1a278ae9c844974 Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 21:48:00 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=EA=B0=9C=EB=B0=9C=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20cicd=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-ci.yaml | 71 -------------------- .github/workflows/dev-cicd.yaml | 115 ++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/dev-ci.yaml create mode 100644 .github/workflows/dev-cicd.yaml diff --git a/.github/workflows/dev-ci.yaml b/.github/workflows/dev-ci.yaml deleted file mode 100644 index 68b7ca8a..00000000 --- a/.github/workflows/dev-ci.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build And Test - -on: - push: - branches: - - dev - - main - pull_request: - branches: - - dev - - main - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: "17" - distribution: "corretto" - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew build -x test --stacktrace --parallel - - - name: Run tests - run: ./gradlew test - - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - files: '**/build/test-results/test/TEST-*.xml' - - - name: JUnit Report Action - uses: mikepenz/action-junit-report@v3 - if: always() - with: - report_paths: '**/build/test-results/test/TEST-*.xml' - - - name: Store test results - uses: actions/upload-artifact@v3 - if: always() - with: - name: test-results - path: '**/build/test-results/test/TEST-*.xml' - - - name: Test Report Summary - if: always() - run: | - echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - ./gradlew test --console=plain || true - echo '```' >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/dev-cicd.yaml b/.github/workflows/dev-cicd.yaml new file mode 100644 index 00000000..e40f8710 --- /dev/null +++ b/.github/workflows/dev-cicd.yaml @@ -0,0 +1,115 @@ +name: Build And Test + +on: + push: + branches: + - dev + - main + pull_request: + branches: + - dev + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "corretto" + + - name: Cache Gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test --stacktrace --parallel + + - name: Run tests + run: ./gradlew test + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: '**/build/test-results/test/TEST-*.xml' + + - name: JUnit Report Action + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: '**/build/test-results/test/TEST-*.xml' + + - name: Store test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: test-results + path: '**/build/test-results/test/TEST-*.xml' + + - name: Test Report Summary + if: always() + run: | + echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./gradlew test --console=plain || true + echo '```' >> $GITHUB_STEP_SUMMARY + + deploy: + needs: build-and-test + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:${{ github.sha }} + + - name: Deploy to Dev NCP Server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.DEV_NCP_SERVER_HOST }} + username: ${{ secrets.DEV_NCP_SERVER_USERNAME }} + password: ${{ secrets.DEV_NCP_SERVER_PASSWORD }} + script: | + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} + docker stop spot-server-dev || true + docker rm spot-server-dev || true + docker run -d --name spot-server-dev \ + -p 8080:8080 \ + -e SPRING_DATASOURCE_URL=${{ secrets.DEV_DB_URL }} \ + -e SPRING_DATASOURCE_USERNAME=${{ secrets.DEV_DB_USERNAME }} \ + -e SPRING_DATASOURCE_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} \ + -e TZ=Asia/Seoul \ + ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} + docker system prune -af \ No newline at end of file From 856c27d2ceac0df821e5eefc7b2fec8e2ab3f3ec Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 21:48:23 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20=EA=B0=9C=EB=B0=9C=EC=9A=A9=20main?= =?UTF-8?q?=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20ci=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=20=EC=9E=AC=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main-ci.yaml | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/main-ci.yaml diff --git a/.github/workflows/main-ci.yaml b/.github/workflows/main-ci.yaml new file mode 100644 index 00000000..481b6ad5 --- /dev/null +++ b/.github/workflows/main-ci.yaml @@ -0,0 +1,71 @@ +name: Build And Test + +on: + push: + branches: + - dev + - main + pull_request: + branches: + - dev + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "corretto" + + - name: Cache Gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test --stacktrace --parallel + + - name: Run tests + run: ./gradlew test + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: '**/build/test-results/test/TEST-*.xml' + + - name: JUnit Report Action + uses: mikepenz/action-junit-report@v3 + if: always() + with: + report_paths: '**/build/test-results/test/TEST-*.xml' + + - name: Store test results + uses: actions/upload-artifact@v3 + if: always() + with: + name: test-results + path: '**/build/test-results/test/TEST-*.xml' + + - name: Test Report Summary + if: always() + run: | + echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + ./gradlew test --console=plain || true + echo '```' >> $GITHUB_STEP_SUMMARY \ No newline at end of file From 8e0d2d567c392903bbada0dd60d3d5486e89fffb Mon Sep 17 00:00:00 2001 From: Minseong Park Date: Tue, 16 Jul 2024 21:49:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20=ED=8A=B8=EB=A6=AC=EA=B1=B0=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B0=9C=EB=B0=9C=EC=84=9C=EB=B2=84=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=EB=8B=B4=EB=8B=B9=EC=9D=B8=20dev=EB=B8=8C=EB=9E=9C?= =?UTF-8?q?=EC=B9=98=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main-ci.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main-ci.yaml b/.github/workflows/main-ci.yaml index 481b6ad5..fc4be30b 100644 --- a/.github/workflows/main-ci.yaml +++ b/.github/workflows/main-ci.yaml @@ -3,11 +3,9 @@ name: Build And Test on: push: branches: - - dev - main pull_request: branches: - - dev - main jobs: