Skip to content

Commit

Permalink
merge: Feature/#164 dev prod yml 분리 및 서브모듈 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonjerry authored Aug 2, 2023
2 parents 262254f + a0c437f commit 271c00f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 20 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/backend-dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: 백엔드 메인으로 checkout
- name: 선택된 브랜치로 checkout
uses: actions/checkout@v3

- name: firebase key 생성
run: |
echo "${{ secrets.FIREBASE_KEY }}" > firebase-kerdy.json
- name: firebase key 이동
run: |
cp firebase-kerdy.json src/main/resources
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: true

- name: JDK 11로 설정
uses: actions/setup-java@v3
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/backend-prod-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
steps:
- name: workflow_dispatch에서 지정한 branch로 checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: true

- name: firebase key 생성
run: |
Expand Down Expand Up @@ -65,16 +68,17 @@ jobs:
uses: docker/build-push-action@v4
with:
context: backend/emm-sale
file: backend/emm-sale/Dockerfile
file: backend/emm-sale/Dockerfile-prod
platforms: linux/arm64/v8
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/kerdy:latest

# deploy:
# needs: build
# name: 배포
# runs-on: [ self-hosted, label-prod ]
# steps:
# - name: 도커 실행
# run: |
# sudo docker stop kerdy && docker rm kerdy && docker rmi ${{ DOCKERHUB_USERNAME }}/kerdy
# sudo docker run -d -p 8080:8080 --name kerdy
deploy:
needs: build
name: 배포
runs-on: [ self-hosted, label-prod ]
steps:
- name: 도커 실행
run: |
docker stop kerdy && docker rm kerdy && docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/kerdy
docker run -d -p 8080:8080 --name kerdy ${{ secrets.DOCKERHUB_USERNAME }}/kerdy
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "backend/emm-sale/src/main/resources/kerdy-submodule"]
path = backend/emm-sale/src/main/resources/kerdy-submodule
url = https://github.com/java-saeng/kerdy-submodule.git
4 changes: 4 additions & 0 deletions backend/emm-sale/Dockerfile-prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:11 as build
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} kerdy.jar
ENTRYPOINT ["java","-Dspring.profiles.active=prod","-jar","/kerdy.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FirebaseCloudMessageClient {
private static final String PREFIX_ACCESS_TOKEN = "Bearer ";
private static final String PREFIX_FCM_REQUEST_URL = "https://fcm.googleapis.com/v1/projects/";
private static final String POSTFIX_FCM_REQUEST_URL = "/messages:send";
private static final String FIREBASE_KEY_PATH = "firebase-kerdy.json";
private static final String FIREBASE_KEY_PATH = "kerdy-submodule/firebase-kerdy.json";
private static final boolean DEFAULT_VALIDATE_ONLY = false;

private final ObjectMapper objectMapper;
Expand Down
21 changes: 21 additions & 0 deletions backend/emm-sale/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spring:
dialect: org.hibernate.dialect.MySQL8Dialect
format_sql: true
show-sql: true
config:
activate:
on-profile: default

logging:
level:
Expand Down Expand Up @@ -42,3 +45,21 @@ security:
firebase:
project:
id: kerdy


---

spring:
config:
import: classpath:kerdy-submodule/application-dev.yml
activate:
on-profile: dev

---

spring:
config:
import: classpath:kerdy-submodule/application-prod.yml
activate:
on-profile: prod

1 change: 1 addition & 0 deletions backend/emm-sale/src/main/resources/kerdy-submodule
Submodule kerdy-submodule added at cb7dbb

0 comments on commit 271c00f

Please sign in to comment.