diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4e84923..0bf7695 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -59,14 +59,15 @@ jobs: key: ${{ secrets.KEY }} port: 22 script: | - docker rm -f $(docker ps -qa --filter "name=zzansuni-spring") # 기존 zzansuni-spring 서버만 잡아서 중지합니다. + docker rm -f $(docker ps -qa --filter "name=zzansuni-spring-prod") + docker rm -f $(docker ps -qa --filter "name=zzansuni-spring-dev") # 기존에 사용되던 spring 이미지만 제거합니다. docker rmi $(docker images -q --filter "reference=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}") docker image prune -f # 사용하지 않는 도커 이미지들을 제거합니다. docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} docker run -d -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod \ - --name zzansuni-spring \ + --name zzansuni-spring-prod \ -e KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }} \ -e NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} \ -e KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }} \ @@ -76,4 +77,19 @@ jobs: -e S3_BUCKET=${{ secrets.S3_BUCKET }} \ -e S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} \ -e S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} \ + -e SERVER_URL=https://api.reditus.site \ + ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} + + docker run -d -p 8081:8080 -e SPRING_PROFILES_ACTIVE=dev \ + --name zzansuni-spring-dev \ + -e KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }} \ + -e NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} \ + -e KAKAO_REDIRECT_URI=${{ secrets.KAKAO_DEV_REDIRECT_URI }} \ + -e MYSQL_URL=${{ secrets.MYSQL_DEV_URL }} \ + -e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \ + -e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \ + -e S3_BUCKET=${{ secrets.S3_BUCKET }} \ + -e S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} \ + -e S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} \ + -e SERVER_URL=http://api.reditus.site:8081 \ ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} diff --git a/zzansuni-api-server/app/src/main/resources/application.yml b/zzansuni-api-server/app/src/main/resources/application.yml index 19a2b11..9b51f95 100644 --- a/zzansuni-api-server/app/src/main/resources/application.yml +++ b/zzansuni-api-server/app/src/main/resources/application.yml @@ -50,7 +50,7 @@ server: spring: config: activate: - on-profile: dev, prod # dev, prod 공통 설정 + on-profile: local, dev, prod # dev, prod 공통 설정 datasource: driver-class-name: com.mysql.cj.jdbc.Driver jpa: @@ -77,10 +77,10 @@ kakao: naver: client-id: ${NAVER_CLIENT_ID:Ob2i2TZtIsaNqH8j_q9X} --- -spring: # dev profile +spring: # local profile config: activate: - on-profile: dev + on-profile: local datasource: url: jdbc:mysql://localhost:3306/zzansuni?createDatabaseIfNotExist=true username: "root" @@ -94,10 +94,10 @@ kakao: naver: client-secret: ${NAVER_CLIENT_SECRET:placeholder} --- -spring: # prod profile +spring: # dev,prod profile config: activate: - on-profile: prod + on-profile: dev, prod datasource: url: ${MYSQL_URL} username: ${MYSQL_USERNAME} @@ -121,4 +121,4 @@ kakao: redirect-uri: ${KAKAO_REDIRECT_URI} naver: client-secret: ${NAVER_CLIENT_SECRET} -server-url: 'https://api.reditus.site' \ No newline at end of file +server-url: ${SERVER_URL} \ No newline at end of file