Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat#38] Github Action workflow 분리 및 mysql db production 적용 #43

Merged
merged 3 commits into from
Feb 17, 2024
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
59 changes: 5 additions & 54 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,12 @@
name: Build

on: [ pull_request, workflow_dispatch ]

on:
push:
branches:
- main
workflow_dispatch:

jobs:
style:
name: CheckStyle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Run Checkstyle
run: ./gradlew checkstyleMain checkstyleTest
- name: Make firebase-adminsdk.json
run: |
touch src/main/resources/timeet-firebase-adminsdk.json
echo "${{ secrets.FIREBASE_ADMINSDK }}" | base64 --decode > src/main/resources/timeet-firebase-adminsdk.json
- name: Make application-prod.yml
run: |
touch src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" | base64 --decode > src/main/resources/application-prod.yml
- name: Make application-test.yml
run: |
touch src/main/resources/application-test.yml
echo "${{ secrets.APPLICATION_TEST }}" | base64 --decode > src/main/resources/application-test.yml
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew clean build sonar --info

- name: Verify JAR File Exists
run: |
ls -l ./build/libs/
if [ -z "$(ls -A ./build/libs/*.jar)" ]; then
echo "No JAR files found in ./build/libs directory."
exit 1
fi

build:
runs-on: ubuntu-latest
steps:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: check

on: [ pull_request, workflow_dispatch ]


jobs:
style:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Run Checkstyle
run: ./gradlew checkstyleMain checkstyleTest
- name: Make firebase-adminsdk.json
run: |
touch src/main/resources/timeet-firebase-adminsdk.json
echo "${{ secrets.FIREBASE_ADMINSDK }}" | base64 --decode > src/main/resources/timeet-firebase-adminsdk.json
- name: Make application-prod.yml
run: |
touch src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" | base64 --decode > src/main/resources/application-prod.yml
- name: Make application-test.yml
run: |
touch src/main/resources/application-test.yml
echo "${{ secrets.APPLICATION_TEST }}" | base64 --decode > src/main/resources/application-test.yml
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew clean build sonar --info

- name: Verify JAR File Exists
run: |
ls -l ./build/libs/
if [ -z "$(ls -A ./build/libs/*.jar)" ]; then
echo "No JAR files found in ./build/libs directory."
exit 1
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
timeet-firebase-adminsdk.json
HELP.md
.gradle
Expand Down
27 changes: 17 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
version: '3.7'
services:
db:
image: mysql:8-oracle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arm 아키텍처도 지원되는 이미지로 수정해주셔서 감사해요!!
제 노트북에서도 잘 작동하네요 😄

restart: always
environment:
MYSQL_DATABASE: '{MYSQL_DATABASE}'
MYSQL_USER: '${MYSQL_USER}'
MYSQL_PASSWORD: '${MYSQL_PASSWORD}'
MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD}'
Comment on lines +6 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

환경변수 사용해서 설정값 분리 잘 하셨습니다!! 💯 보안상 이슈는 없어보여요! 👏

ports:
- '3306:3306'
volumes:
- db_data:/var/lib/mysql

app:
build:
context: .
dockerfile: Dockerfile
environment: # 환경 변수 설정
- SPRING_DATASOURCE_URL=jdbc:h2:file:/usr/src/app/data/mydb;DB_CLOSE_ON_EXIT=FALSE
platform: linux/amd64
image: syw5141/dnd-10th-2-backend:latest
ports:
- "8080:8080"
# h2data 볼륨을 컨테이너 내부의 /usr/src/app/data에 매핑
volumes:
- h2data:/usr/src/app/data
depends_on:
- db

# 볼륨 정의 (기본 설정 사용)
volumes:
h2data:
db_data:
Loading