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

[CHORE] 환경 분리를 위한 yml 파일 변경 #106

Merged
merged 8 commits into from
Sep 24, 2023
29 changes: 13 additions & 16 deletions .github/workflows/api-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,22 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성

# 3) AWS Secrets Manger 환경변수 사용
- name: Read secrets from AWS Secrets Manager into environment variables
uses: abhilash1in/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
secrets: /secret/umbba-dev
parse-json: false

Comment on lines +45 to +54
Copy link
Member

Choose a reason for hiding this comment

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

오오 이거 쓴거 너무 좋은데?

# 4) FCM secret key 파일 생성
- name: FCM secret key 파일 생성
run: |
# application.yml 파일 생성
cd ./umbba-api/src/main/resources
rm application.yaml

touch ./application.yml

# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml

# 생성된 파일 확인
cat ./application.yml

####################################

# FCM secret key 폴더 생성
mkdir ./firebase
cd ./firebase

Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/api-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,17 @@ jobs:
with:
java-version: '11'
distribution: 'temurin'

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성
run: |
## create application.yml
cd ./umbba-api/src/main/resources
rm application.yaml

# application.yml 파일 생성
touch ./application.yml

# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml

# application.yml 파일 확인
cat ./application.yml
# 3) AWS Secrets Manger 환경변수 사용
- name: Read secrets from AWS Secrets Manager into environment variables
uses: abhilash1in/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
secrets: /secret/umbba-dev
parse-json: false

shell: bash

# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
29 changes: 13 additions & 16 deletions .github/workflows/notification-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,21 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성
# 3) AWS Secrets Manger 환경변수 사용
- name: Read secrets from AWS Secrets Manager into environment variables
uses: abhilash1in/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
secrets: /secret/umbba-dev
parse-json: false

# 4) FCM secret key 파일 생성
- name: FCM secret key 파일 생성
run: |
# application.yml 파일 생성
cd ./umbba-notification/src/main/resources
rm application.yaml

touch ./application.yml

# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml

# 생성된 파일 확인
cat ./application.yml

####################################
cd ./umbba-api/src/main/resources

# FCM secret key 폴더 생성
mkdir ./firebase
cd ./firebase

Expand Down
26 changes: 9 additions & 17 deletions .github/workflows/notification-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,15 @@ jobs:
java-version: '11'
distribution: 'temurin'

# 3) 환경변수 파일 생성
- name: make application.yml 파일 생성
run: |
## create application.yml
cd ./umbba-notification/src/main/resources
rm application.yaml

# application.yml 파일 생성
touch ./application.yml

# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.UMBBA_SECRET }}" >> ./application.yml

# application.yml 파일 확인
cat ./application.yml

shell: bash
# 3) AWS Secrets Manger 환경변수 사용
- name: Read secrets from AWS Secrets Manager into environment variables
uses: abhilash1in/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
secrets: /secret/umbba-dev
parse-json: false

# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ subprojects {
// Health Check
implementation 'org.springframework.boot:spring-boot-starter-actuator'

// AWS Secrets Manager
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.3'
implementation 'org.springframework.cloud:spring-cloud-starter-aws-secrets-manager-config:2.2.6.RELEASE'
}

test {
Expand Down
4 changes: 4 additions & 0 deletions umbba-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ dependencies {

// s3
// implementation "org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE"

// AWS Secrets Manager
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.3'
implementation 'org.springframework.cloud:spring-cloud-starter-aws-secrets-manager-config:2.2.6.RELEASE'
}

81 changes: 0 additions & 81 deletions umbba-api/src/main/resources/application.yaml

This file was deleted.

137 changes: 137 additions & 0 deletions umbba-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
spring:
profiles:
group:
"local": "local_setting, common"
"local_notification": "local_notification_setting, common"
"set1": "set1_setting, common"
"set2": "set2_setting, common"
"notification": "notification_setting, common"
active: local

# common
---
spring:
config:
activate:
on-profile: common

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${DB_URL}
username: ${DB_USER}
password: ${DB_PWD}
hikari:
pool-name: Hikari 커넥션 풀 # Pool
connection-timeout: 30000 # 30초(default: 30초)
maximum-pool-size: 10 # default: 10개
max-lifetime: 600000 # 10분(default: 30분)
leak-detection-threshold: 3500 # default: 0(이용X)

jpa:
show-sql: false
hibernate:
ddl-auto: update
ejb:
naming_strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
properties:
hibernate:
format_sql: true

cloud:
aws:
credentials:
accessKey: ${CLOUD_ACCESS}
secretKey: ${CLOUD_SECRET}
region:
static: ${CLOUD_REGION}
s3:
bucket: ${BUCKET_NAME}
stack:
auto: false
sqs:
notification:
name: ${SQS_NOTIFICATION_NAME}
url: ${SQS_NOTIFICATION_URL}

kakao:
client-id: ${KAKAO_ID}
authorization-grant-type: authorization_code
redirect-uri: ${KAKAO_REDIRECT}
apple:
iss: ${APPLE_ISS}
client-id: ${APPLE_ID}
# nonce:

jwt:
secret: ${JWT_SECRET}

slack:
webhook:
url: ${SLACK_URL}

fcm:
key:
path: ${FCM_JSON_PATH}
scope: ${FCM_SCOPE}
# firebase-create-scoped: "https://www.googleapis.com/auth/firebase.messaging"
api:
url: ${FCM_API_URL}
topic:
"qna_notification"
Comment on lines +40 to +80
Copy link
Member

Choose a reason for hiding this comment

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

훨씬 깔꼼&굿 이네요


logging:
level:
com:
amazonaws:
util:
EC2MetadataUtils: error

# local_setting
---
spring:
config:
activate:
on-profile: local_setting

server:
port: 9091

# local_notification_setting
---
spring:
config:
activate:
on-profile: local_notification_setting

server:
port: 9092

# set1_setting
---
spring:
config:
activate:
on-profile: set1_setting

server:
port: 8081

# set2_setting
---
spring:
config:
activate:
on-profile: set2_setting

server:
port: 8082

# notification_setting
---
spring:
config:
activate:
on-profile: notification_setting

Comment on lines +88 to +135
Copy link
Member

Choose a reason for hiding this comment

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

환경 분리 넘 최고다 감사함다 ㅠㅠ

server:
port: 8083
7 changes: 7 additions & 0 deletions umbba-api/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
aws:
secretsmanager:
name: umbba-dev
cloud:
aws:
region:
static: ap-northeast-2
Loading