-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: gitignore에 .env 추가 * feat: application-jpa sql init mode 항목 always->never * feat: 개발환경 db 세팅 값을 cloud db for mysql로 변경 * feat: 개발환경 cicd 스크립트 작성 * feat: 개발용 main 브랜치 ci 스크립트 재작성 * fix: 트리거에서 개발서버 배포담당인 dev브랜치 제외
- Loading branch information
1 parent
0e873da
commit b7f68fb
Showing
6 changed files
with
223 additions
and
110 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Build And Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters