-
Notifications
You must be signed in to change notification settings - Fork 24
[조재구] sprint8 #221
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
Open
NINE-J
wants to merge
37
commits into
codeit-bootcamp-spring:조재구
Choose a base branch
from
NINE-J:조재구-sprint8
base: 조재구
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "\uC870\uC7AC\uAD6C-sprint8"
Open
[조재구] sprint8 #221
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Dockerfile 작성 - 이미지 빌드 및 실행 테스트 - docker-compose 구성
- AWS S3 테스트 - 테스트 코드 로깅 설정 변경
- S3BinaryContentStorage - 단위 테스트 S3 Mocking - AWS S3와 호환되는 오픈소스 객체 스토리지 MiniO 고려해봐도 좋을 것.
- 프레임워크 사용으로 불가피한 Object 타입 외 개선할 수 있는 부분 검토 후 수정 - IntelliJ에선 정상 동작하지만 VSCode에서 오류 발생하던 `-parameters` 설정 이슈 해결
- 멀티 스테이지 빌드 활용해서 이미지 크기 감소 - 이미지 레이어 캐시 고려
조재구 sprint1
조재구 sprint2
조재구 sprint3
조재구 sprint4
조재구 sprint5
조재구 sprint6
조재구 sprint7
- DNS CNAME 연결과 CORS 관련 테스트
- main 브랜치에 PR 생성 시 테스트 실행 - CodeCov를 통해 테스트 커버리지 뱃지 확인
조재구 sprint8 - CD/CD 중 CI 테스트
- main 브랜치에 PR 생성 시 테스트 실행 - CodeCov를 통해 테스트 커버리지 뱃지 확인 - Docker image build and push - Update ECS - 태스크 정의의 개정이 증가함.
- test, deploy 이동
feat: CD(지속적 배포)를 위한 워크플로우 설정
docs: README.md
이걸 왜 안 바꿨을까..? 금쪽이네 아주.
- 프리티어 리소스를 고려해 구동 중인 서비스를 중단 - 필요한 경우 `--desired-count` 수정, `# 새 태스크 정의로 서비스 재시작` 주석 해제해서 진행
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
프로젝트 마일스톤
AWS S3
)AWS ECS
,RDS
)GitHub Actions
)베이스 코드
이전 미션에서 아직 달성하지 못한 요구사항이 있어 이 미션을 수행하기 어렵다면 베이스 코드를 참고해보세요.
주요 변경 사항
1. 원활한 실습 진행을 위해
Spring Boot Admin
관련 코드는 삭제되었습니다.admin
모듈IntelliJ Gradle
툴 윈도우에서도 삭제해주세요.spring boot admin
의존성 삭제2. 프로젝트 버전이 변경되었습니다.
v1.2-M8
1.2
:api-doc
버전을 따릅니다.M8
: 미션 8을 의미합니다.과금 안내사항
미션 진행 중 유의사항
이 미션은 AWS 프리티어 할당량 내에서 충분히 수행 가능하도록 설계되었습니다. 불필요한 비용이 발생하지 않도록 미션 요구사항을 사전에 꼼꼼히 확인해 주시기 바랍니다.
미션 종료 후 안내사항
멘토님들의 리뷰가 완료된 후에는 추후에 진행할 실습(미션, 중급 프로젝트 등)을 위해, 이번 미션에서 생성했던 모든 AWS 리소스(EC2, RDS, S3)를 반드시 삭제해 주세요. 리소스를 '중지'하는 것이 아닌 '삭제'해야 추가 비용이 발생하지 않습니다.
애플리케이션 컨테이너화
Dockerfile 작성
/app
).dockerignore
를 활용해 제외하세요.80
포트를 노출하도록 설정하세요.PROJECT_NAME
: discodeitPROJECT_VERSION
: 1.2-M8JVM_OPTS
: 기본값은 빈 문자열로 정의이미지 빌드 및 실행 테스트
local
)를 지정하세요.prod
프로필로 실행하세요.http://localhost:8081
로 접속 가능하도록 포트를 매핑하세요.Docker Compose 구성
docker-compose.yml
파일을 작성합니다..env
파일을 활용하되,.env
는 형상관리에서 제외하여 보안을 유지하세요.BinaryContentStorage
데이터가 유지되도록 하세요.schema.sql
이 자동으로 실행되도록 구성하세요.depends_on
).--build
플래그를 사용하여 서비스 시작 전에 이미지를 빌드하도록 합니다.BinaryContentStorage 고도화 (AWS S3)
AWS S3 버킷 구성
discodeit-binary-content-storage-(사용자 이니셜)
형식으로 지정하세요.AWS S3 접근을 위한 IAM 구성
discodeit
)를 생성하세요.AmazonS3FullAccess
권한을 할당하고, 사용자 생성을 완료하세요..env
파일에 추가합니다..env
파일은 리뷰를 위해 PR에 별도로 첨부해주세요. 단, 엑세스 키와 시크릿 키는 제외하세요.AWS S3 테스트
implementation 'software.amazon.awssdk:s3:2.31.7'
com.sprint.mission.discodeit.stoarge.s3
AWSS3Test
Properties
클래스를 활용해서.env
에 정의한 AWS 정보를 로드하세요.AWS S3를 활용한
BinaryContentStroage
고도화S3BinaryContentStorage
를 구현하세요.discodeit.storage.type
값이s3
인 경우에만 Bean으로 등록되어야 합니다.S3BinaryContentStorageTest
를 함께 작성하면서 구현하세요.BinaryContentStorage
설정을 유연하게 제어할 수 있도록application.yaml
을 수정하세요..env
파일에 작성된 값을 임포트하는 방식으로 설정하세요.download
메소드는PresignedUrl
을 활용해 리다이렉트하는 방식으로 구현하세요.AWS를 활용한 배포 (AWS RDS, ECR, ECS)
AWS RDS 구성
프리티어
아니오
7일
모두 체크 해제
비활성화
SSH
내 IP
SSH/SSL > Use SSH tunnel
설정을 활성화하세요. 이때 이전에 다운로드한.pem
파일을 활용하세요.rds-ssh
인스턴스는 완전히 삭제하여 과금에 유의하세요.AWS ECR 구성
discodeit
)를 생성하세요.aws configure
실행 후 앞서 생성한discodeit
IAM 사용자 정보를 입력하세요.ap-northeast-2
json
discodeit
IAM 사용자가 ECR에 접근할 수 있도록 다음 권한을 부여하세요.AmazonElasticContainerRegistryPublicFullAccess
푸시 명령 보기
를 클릭하면 관련 명령어를 확인할 수 있습니다.discodeit
레포지토리에 push 하세요.latest
,1.2-M8
linux/amd64
,linux/arm64
AWS ECS 구성
discodeit.env
파일을 만들어 다음의 내용을 작성하세요.태스크 실행 역할
에 S3 관련 권한을 추가하세요.discodeit
클러스터 상세 화면에서 서비스를 생성하세요.HTTP
를 선택하세요.Anywhere-IPv4
를 선택하여 모든 IP를 허용하세요.심화 요구사항
이미지 최적화하기
빌드
,런타임
) 빌드를 활용해 이미지의 크기를 줄여보세요.local-slim
1.2-M8
또는local
)와 크기를 비교해보세요.GitHub Actions를 활용한 CI/CD 파이프라인 구축
.github/workflows/test.yml
파일을 생성하세요.main
브랜치에 PR이 생성되면 실행되도록 설정하세요..github/workflows/deploy.yml
파일을 생성하세요.release
브랜치에 코드가 푸시되면 실행되도록 설정하세요.AWS_ACCESS_KEY
: IAM 사용자의 액세스 키AWS_SECRET_KEY
: IAM 사용자의 시크릿 키AWS_REGION
: AWS 리전(ap-northeast-2
)ECR_REPOSITORY_URI
: ECR 레포지토리 URIECS_CLUSTER
: ECS 클러스터 이름(discodeit-cluster
)ECS_SERVICE
: ECS 서비스 이름(discodeit-service
)ECS_TASK_DEFINITION
: ECS 태스크 정의 이름(discodeit-task
)us-east-1
으로 설정해야합니다.x86_64
입니다.latest
와 GitHub 커밋 해시를 사용하도록 설정하세요.AWS_REGION
으로 설정해야합니다.aws ecs update-service --desired-count
옵션을 활용하세요.리뷰를 위해 PR에 포함해야할 정보
.env
파일 (AWS 키는 제외)