Skip to content

Commit

Permalink
Merge pull request #174 from Media-XI/feat/spring-boot-admin
Browse files Browse the repository at this point in the history
[monitoring] spring boot admin, ec2 action flow delete
  • Loading branch information
Hoon9901 authored May 28, 2024
2 parents a7bd9f5 + b7d53c9 commit 3cc7158
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,6 @@ jobs:
- name: Push to ${{ env.REGISTRY }}
run: docker push ${{ env.DOCKER_IMAGE_NAME }}

# Docker 이미지 이름을 image.txt 파일에 쓰기
- name: Write Docker image name to file
run: echo "${{ env.DOCKER_IMAGE_NAME }}" > image.txt

- name: Create zip file for AWS CodeDeploy
run: mkdir ${{ env.AWS_CODE_DEPLOY_NAME }} && cp -r appspec.yml image.txt scripts ${{ env.AWS_CODE_DEPLOY_NAME }}

# AWS 설정
- name: AWS Configure
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

# AWS S3로 배포 파일 업로드
- name: Upload to AWS S3
run: |
aws deploy push \
--application-name ${{ env.AWS_CODE_DEPLOY_NAME }} \
--s3-location s3://${{ env.AWS_S3_BUCKET_NAME }}/codedeploy/$GITHUB_SHA.zip \
--ignore-hidden-files \
--source ${{ env.AWS_CODE_DEPLOY_NAME }}
# AWS EC2 CodeDeploy 배포 요청
- name: Delpoy to AWS EC2
run: |
aws deploy create-deployment \
--application-name ${{ env.AWS_CODE_DEPLOY_NAME }} \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} \
--description "Deploy artscope" \
--s3-location bucket=$AWS_S3_BUCKET_NAME,key=codedeploy/$GITHUB_SHA.zip,bundleType=zip
# 다음 버전으로 업데이트
- name: Autoincrement a new minor version
run: |
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-mail' // email
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'de.codecentric:spring-boot-admin-starter-client:3.2.3'


// Elasticsearch
implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/example/codebase/util/ClientUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.BeanSerializer;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -46,6 +47,10 @@ public static StringBuilder jsonBodyForLogging(Object body) throws IOException {
return stringBuilder.append("null");
}

if (!(body instanceof BeanSerializer)) {
return stringBuilder.append("not serializable object");
}

try {
jsonInString = objectMapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(body)
Expand Down
24 changes: 24 additions & 0 deletions src/main/resources/application-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
spring:
boot:
admin:
client:
url:
- ENC(OPBnD61N+eMc4g7DOlX8RPCH7HPVog3OhqbitXLaGMtSTBgQ8BeJI6B32kletTsZ)
username: ${ADMIN_SERVER_USERNAME}
password: ${ADMIN_SERVER_PASSWORD}
instance:
name: artscope-backend-${spring.profiles.active}
service-url:
- ${ADMIN_CLIENT_URL}

management:
endpoints:
web:
exposure:
include: '*'
info:
env:
enabled: true
endpoint:
health:
show-details: always
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ spring:
- s3
- mail
- es
- admin

mvc:
pathmatch:
Expand Down

0 comments on commit 3cc7158

Please sign in to comment.