-
Notifications
You must be signed in to change notification settings - Fork 24
[한동우] sprint8 #222
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
Dw-real
wants to merge
35
commits into
codeit-bootcamp-spring:한동우
Choose a base branch
from
Dw-real:한동우-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: "\uD55C\uB3D9\uC6B0-sprint8"
Open
[한동우] sprint8 #222
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 작성
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 구성
AWS RDS PostgreSQL 인스턴스를 생성하세요.

과금이 발생할 수 있으니 다음 항목은 한번 더 확인해주세요.
템플릿: 프리티어
퍼블릭 액세스: 아니오
모니터링 > 보존기간: 7일
모니터링 > 추가 모니터링 설정: 모두 체크 해제
추가 구성 > 백업: 비활성화
SSH 터널링을 통해 개발 환경에서 접근할 수 있도록 EC2를 구성하세요.
보안 그룹에서 인바운드 규칙을 편집하세요.
SSH
내 IP
DataGrip을 통해 연결 후 데이터베이스와 사용자, 테이블을 초기화하세요.
데이터 소스 추가 시
SSH/SSL > Use SSH tunnel
설정을 활성화하세요. 이때 이전에 다운로드한.pem
파일을 활용하세요.연결이 성공하면 데이터베이스와 사용자, 테이블을 초기화하세요.
-[x] 구성이 완료되면
rds-ssh
인스턴스는 완전히 삭제하여 과금에 유의하세요.AWS ECR 구성
-[x] 이미지를 배포할 퍼블릭 레포지토리(discodeit)를 생성하세요.
aws configure
실행 후 앞서 생성한discodeit
IAM 사용자 정보를 입력하세요.discodeit
IAM 사용자가 ECR에 접근할 수 있도록 다음 권한을 부여하세요.AmazonElasticContainerRegistryPublicFullAccess
latest
,1.2-M8
linux/amd64
,linux/arm64
AWS ECS 구성
discodeit.env
파일을 만들어 다음의 내용을 작성하세요.이 파일을 S3에 업로드하세요.
이 파일은 형상관리되지 않도록 주의하세요.
AWS ECS 콘솔에서 클러스터를 생성하세요.

태스크를 정의하세요.

discodeit
클러스터 상세 화면에서 서비스를 생성하세요.태스크의 EC2 보안 그룹의 인바운드 규칙을 설정하여 어디서든 접근할 수 있도록 하세요.
태스크 실행이 완료되면 해당 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
)Docker 이미지 빌드 및 푸시
us-east-1
으로 설정해야합니다.latest
와 GitHub 커밋 해시를 사용하도록 설정하세요.ECS 서비스 업데이트
AWS_REGION
으로 설정해야합니다.프리티어 리소스를 고려해 AWS CLI를 사용해 기존에 구동 중인 서비스를 중단하는 Step을 추가하세요.
aws ecs update-service --desired-count
옵션을 활용하세요.AWS 콘솔을 통해 새로 등록된 태스크 정의로 배포되었는지 확인하세요.
스크린샷
.env 파일 (AWS 키 제외)
RDS
ECR
ECS
VPC
IAM
멘토에게