-
Notifications
You must be signed in to change notification settings - Fork 24
[이지현] sprint8 #219
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
jhlee-codes
wants to merge
29
commits into
codeit-bootcamp-spring:이지현
Choose a base branch
from
jhlee-codes:이지현-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: "\uC774\uC9C0\uD604-sprint8"
Open
[이지현] sprint8 #219
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
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.
기본 요구사항
애플리케이션 컨테이너화
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 구성
S3 버킷에 접근하기 위한 IAM 사용자(
discodeit
)를 생성하세요.AmazonS3FullAccess
권한을 할당하고, 사용자 생성을 완료하세요.생성된 사용자에 엑세스 키를 생성하세요.
발급받은 키를 포함해서 AWS 관련 정보는
.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 구성
AWS RDS PostgreSQL 인스턴스를 생성하세요.
과금이 발생할 수 있으니 다음 항목은 한번 더 확인해주세요.
프리티어
아니오
7일
모두 체크 해제
비활성화
SSH 터널링을 통해 개발 환경에서 접근할 수 있도록 EC2를 구성하세요.
EC2 인스턴스를 생성하세요.
보안 그룹에서 인바운드 규칙을 편집하세요.
SSH
내 IP
DataGrip을 통해 연결 후 데이터베이스와 사용자, 테이블을 초기화하세요.
데이터 소스 추가 시
SSH/SSL > Use SSH tunnel
설정을 활성화하세요. 이때 이전에 다운로드한.pem
파일을 활용하세요.연결이 성공하면 데이터베이스와 사용자, 테이블을 초기화하세요.
구성이 완료되면
rds-ssh
인스턴스는 완전히 삭제하여 과금에 유의하세요.AWS ECR 구성
이미지를 배포할 퍼블릭 레포지토리(
discodeit
)를 생성하세요.AWS CLI를 설치하세요.
aws configure
실행 후 앞서 생성한discodeit
IAM 사용자 정보를 입력하세요.ap-northeast-2
json
discodeit
IAM 사용자가 ECR에 접근할 수 있도록 다음 권한을 부여하세요.AmazonElasticContainerRegistryPublicFullAccess
Docker 클라이언트를 배포할 레지스트리에 대해 인증합니다.
AWS 콘솔을 통해 생성한 레포지토리 페이지로 이동 후 우측 상단
푸시 명령 보기
를 클릭하면 관련 명령어를 확인할 수 있습니다.멀티플랫폼을 지원하도록 애플리케이션 이미지를 빌드하고,
discodeit
레포지토리에 push 하세요.latest
,1.2-M8
linux/amd64
,linux/arm64
AWS 콘솔에서 푸시된 이미지를 확인하세요.
AWS ECS 구성
배포 환경에서 컨테이너 실행 간 사용할 환경 변수를 정의하고, S3에 업로드하세요.
discodeit.env
파일을 만들어 다음의 내용을 작성하세요.이 파일을 S3에 업로드하세요.
이 파일은 형상관리되지 않도록 주의하세요.
AWS ECS 콘솔에서 클러스터를 생성하세요.
태스크를 정의하세요.
태스크 실행 역할
에 S3 관련 권한을 추가하세요.discodeit
클러스터 상세 화면에서 서비스를 생성하세요.태스크의 EC2 보안 그룹의 인바운드 규칙을 설정하여 어디서든 접근할 수 있도록 하세요.
HTTP
를 선택하세요.Anywhere-IPv4
를 선택하여 모든 IP를 허용하세요.태스크 실행이 완료되면 해당 EC2의 퍼블릭 IP에 접속해보세요.
심화 요구사항
이미지 최적화하기
빌드
,런타임
) 빌드를 활용해 이미지의 크기를 줄여보세요.local-slim
1.2-M8
또는local
)와 크기를 비교해보세요.GitHub Actions를 활용한 CI/CD 파이프라인 구축
CI(지속적 통합)를 위한 워크플로우를 설정하세요.
.github/workflows/test.yml
파일을 생성하세요.main
브랜치에 PR이 생성되면 실행되도록 설정하세요.테스트가 실행하는 Job을 정의하세요.
CodeCov를 통해 테스트 커버리지 뱃지를 README에 추가해보세요.
CD(지속적 배포)를 위한 워크플로우를 설정하세요.
.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에 포함해야할 정보
원활한 리뷰를 위해 PR에 다음과 같은 정보를 포함해주세요.
.env
파일 (AWS 키는 제외)RDS
ECR
ECS
VPC
IAM
주요 변경 사항
Spring Boot Admin
관련 코드는 삭제되었습니다.admin
모듈IntelliJ Gradle
툴 윈도우에서도 삭제해주세요.spring boot admin
의존성 삭제2. 프로젝트 버전이 변경되었습니다.
v1.2-M8
1.2
:api-doc
버전을 따릅니다.M8
: 미션 8을 의미합니다.스크린샷
멘토에게