Skip to content

Commit

Permalink
[Weekly/11/Feature/MySQL] MySQL 연동, 도커 볼륨 및 이미지 저장 연동 (#111)
Browse files Browse the repository at this point in the history
* [Weekly/10/Test/CurationController] curationControllerUnitTest 2 (#90)

* feat: MySQL 도입 및 배포 관련 설정

* feat: 서버 도메인 이름 변수화, 이미지 저장소와 도커 볼륨 연동
  • Loading branch information
lja3723 committed Nov 12, 2024
1 parent 156ab91 commit ba84e20
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 36 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ name: CI/CD Github Action
on:
push:
branches: [ "Master", "Weekly/*" ]
pull_request_target:
branches: [ "Master", "Weekly/*" ]

permissions:
contents: read

env:
DATASOURCE_URL : ${{ secrets.ENV_DATASOURCE_URL }}
DATASOURCE_USERNAME : ${{ secrets.ENV_DATASOURCE_USERNAME }}
DATASOURCE_PASSWORD : ${{ secrets.ENV_DATASOURCE_PASSWORD }}
GOOGLE_CLIENT_ID : ${{ secrets.ENV_GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.ENV_GOOGLE_CLIENT_SECRET }}
GOOGLE_REDIRECT_URI : ${{ secrets.ENV_GOOGLE_REDIRECT_URI }}
IMAGE_UPLOAD_PATH : ${{ secrets.ENV_IMAGE_UPLOAD_PATH }}
JWT_SECRET : ${{ secrets.ENV_JWT_SECRET }}
KAKAO_CLIENT_ID : ${{ secrets.ENV_KAKAO_CLIENT_ID }}
KAKAO_CLIENT_SECRET : ${{ secrets.ENV_KAKAO_CLIENT_SECRET }}
KAKAO_REDIRECT_URI : ${{ secrets.ENV_KAKAO_REDIRECT_URI }}
KAKAOPAY_SECRET_KEY : ${{ secrets.ENV_KAKAOPAY_SECRET_KEY }}
SERVER_DOMAIN_NAME : ${{ secrets.ENV_SERVER_DOMAIN_NAME }}

jobs:
## 1단계: 프로젝트 빌드
Expand Down Expand Up @@ -137,14 +138,17 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
echo "GOOGLE_CLIENT_ID=${{ secrets.ENV_GOOGLE_CLIENT_ID }}" > ~/.env
echo "DATASOURCE_URL=${{ secrets.ENV_DATASOURCE_URL }}" > ~/.env
echo "DATASOURCE_USERNAME=${{ secrets.ENV_DATASOURCE_USERNAME }}" >> ~/.env
echo "DATASOURCE_PASSWORD=${{ secrets.ENV_DATASOURCE_PASSWORD }}" >> ~/.env
echo "GOOGLE_CLIENT_ID=${{ secrets.ENV_GOOGLE_CLIENT_ID }}" >> ~/.env
echo "GOOGLE_CLIENT_SECRET=${{ secrets.ENV_GOOGLE_CLIENT_SECRET }}" >> ~/.env
echo "GOOGLE_REDIRECT_URI=${{ secrets.ENV_GOOGLE_REDIRECT_URI }}" >> ~/.env
echo "JWT_SECRET=${{ secrets.ENV_JWT_SECRET }}" >> ~/.env
echo "IMAGE_UPLOAD_PATH=${{ secrets.ENV_IMAGE_UPLOAD_PATH }}" >> ~/.env
echo "KAKAO_CLIENT_ID=${{ secrets.ENV_KAKAO_CLIENT_ID }}" >> ~/.env
echo "KAKAO_CLIENT_SECRET=${{ secrets.ENV_KAKAO_CLIENT_SECRET }}" >> ~/.env
echo "KAKAO_REDIRECT_URI=${{ secrets.ENV_KAKAO_REDIRECT_URI }}" >> ~/.env
echo "KAKAOPAY_SECRET_KEY=${{ secrets.ENV_KAKAOPAY_SECRET_KEY }}" >> ~/.env
echo "SERVER_DOMAIN_NAME=${{ secrets.ENV_SERVER_DOMAIN_NAME }}" >> ~/.env
echo "Environment setup has been completed."
- name: Pull New Docker Image
Expand Down Expand Up @@ -175,7 +179,7 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: GITHUB_SHA
script: sudo docker run --rm -d -p 80:8080 --env-file ~/.env --name would-you-in ${{ secrets.DOCKER_REPO_FULLNAME }}
script: sudo docker run --rm -d -p 80:8080 --env-file ~/.env --name would-you-in -v would-you-in-image-volume:${{ secrets.ENV_IMAGE_UPLOAD_PATH }} ${{ secrets.DOCKER_REPO_FULLNAME }}

- name: Clean-Up Docker Image
uses: appleboy/ssh-action@master
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'com.h2database:h2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'com.fasterxml.jackson.core:jackson-databind'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ spring:
activate:
on-profile: create
jpa:
show-sql: true
hibernate:
ddl-auto: create
6 changes: 1 addition & 5 deletions src/main/resources/application-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ spring:
activate:
on-profile: deploy
jpa:
show-sql: false
hibernate:
ddl-auto: create

# log4j log level setting
logging.level.org.ktc2.cokaen.wouldyouin: info
ddl-auto: update
3 changes: 1 addition & 2 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ spring:
activate:
on-profile: dev
jpa:
show-sql: true
hibernate:
ddl-auto: update
ddl-auto: create-drop
33 changes: 15 additions & 18 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spring:
max-file-size: 10MB
max-request-size: 10MB

# 임시 프로젝트 url
profiles:
default: dev

Expand All @@ -22,31 +21,29 @@ spring:
restart:
enabled: false

# h2 database settings
h2:
console:
enabled: true

datasource:
url: jdbc:h2:mem:test
driver-class-name: org.h2.Driver
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${DATASOURCE_URL}?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
username: ${DATASOURCE_USERNAME}
password: ${DATASOURCE_PASSWORD}

jpa:
database: mysql
database-platform: org.hibernate.dialect.MySQLDialect
properties:
hibernate:
format_sql: true
default_batch_fetch_size: 100
show-sql: true
hibernate.ddl-auto: create

# log4j log level setting
logging.level.org.ktc2.cokaen.wouldyouin: debug

# for image storage path
image:
api-url: http://52.78.71.136/api/images
api-url: ${SERVER_DOMAIN_NAME}/api/images
upload:
parent-path: src/main/resources/static/images
parent-path: ${IMAGE_UPLOAD_PATH}
curation:
child-path: curation
member:
Expand Down Expand Up @@ -75,7 +72,7 @@ oauth:
client:
id: ${KAKAO_CLIENT_ID}
secret: ${KAKAO_CLIENT_SECRET}
redirect_uri: ${KAKAO_REDIRECT_URI}
redirect_uri: ${SERVER_DOMAIN_NAME}/api/auth/social/redirect/kakao
google:
uri:
login:
Expand All @@ -87,14 +84,14 @@ oauth:
client:
id: ${GOOGLE_CLIENT_ID}
secret: ${GOOGLE_CLIENT_SECRET}
redirect_uri: ${GOOGLE_REDIRECT_URI}
redirect_uri: ${SERVER_DOMAIN_NAME}/api/auth/social/redirect/google
scope:
- email
- profile
payment:
"approval_url": "http://localhost:8080/api/events"
"cancel_url": "http://localhost:8080/api/events"
"fail_url": "http://localhost:8080/api/events"
"approval_url": ${SERVER_DOMAIN_NAME}/api/events
"cancel_url": ${SERVER_DOMAIN_NAME}/api/events
"fail_url": ${SERVER_DOMAIN_NAME}/api/events
"secret_key": ${KAKAOPAY_SECRET_KEY}
"kakao_pay_single_payment_url": "online/v1/payment/ready"
"kakao-pay-request-host": "https://open-api.kakaopay.com"
"kakao_pay_single_payment_url": online/v1/payment/ready
"kakao-pay-request-host": https://open-api.kakaopay.com

0 comments on commit ba84e20

Please sign in to comment.