[정수진] sprint8#297
Open
5ranke wants to merge 5 commits intocodeit-bootcamp-spring:정수진from
Hidden character warning
The head ref may contain hidden characters: "\uc815\uc218\uc9c4-sprint8"
Open
Conversation
azjaehyun
approved these changes
Oct 22, 2025
Collaborator
azjaehyun
left a comment
There was a problem hiding this comment.
수진님 sprint8 개발하시느라 수고많으셨습니다.
cicd 배포 파이프라인 문법은 꼭 한번은 구성해서 테스트 하는걸
추천드립니다.
샘플 코드도 같이 제공해드려요
1. CI 워크플로우 생성: .github/workflows/ci.yml
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test with Gradle
run: ./gradlew test
- name: Generate JaCoCo Report
run: ./gradlew jacocoTestReport
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/reports/jacoco/test/jacocoTestReport.xml
fail_ci_if_error: false. 2. CD 워크플로우 생성: .github/workflows/cd.yml
name: CD
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Build, tag, and push image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REGISTRY_ALIAS: ${{ secrets.ECR_REGISTRY_ALIAS }}
REPOSITORY: discodeit
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:latest .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:latest
- name: Update ECS service
run: |
aws ecs update-service \
--cluster discodeit-cluster \
--service discodeit-service \
--force-new-deployment \
--region ${{ secrets.AWS_REGION }}3. GitHub Secrets 설정:
CODECOV_TOKENAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGIONECR_REGISTRY_ALIAS
스프린트9도 화이팅입니다.
Comment on lines
+48
to
+50
| volumes: | ||
| - dbdata:/var/lib/postgresql/data | ||
| - ./db/init:/docker-entrypoint-initdb.d:ro |
Collaborator
There was a problem hiding this comment.
디비 생성할때 바로 init에 스키마 생성 쿼리를 넣어줍시다.
그러면 바로 기동되면서 스키마도 자동으로 생성되니까요!
수정 제안 코드:
volumes:
- dbdata:/var/lib/postgresql/data
- ./src/main/resources/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro| * AWS S3에 이미지 파일을 업로드/다운로드/Presigned URL 생성하는 간단 테스트 클래스. | ||
| * (src/main/java 아래 위치) | ||
| */ | ||
| public class AWSS3Test { |
Collaborator
There was a problem hiding this comment.
이 파일은 왜 여기에?!!
src/test/java/com/sprint/mission/discodeit/storage/s3/ 여기 경로로 가야되는거 아닌가요?!
| .build(); | ||
|
|
||
| s3.putObject(req, RequestBody.fromBytes(bytes)); | ||
| return binaryContentId; |
Collaborator
There was a problem hiding this comment.
파일 업로드하고 나서 로깅도 추가해줍시다!!
log.info("S3에 파일 업로드 성공: {}", key); // ✅ 로깅 추가
| String presignedUrl = generatePresignedUrl(key, metaData.contentType()); | ||
|
|
||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.set(HttpHeaders.LOCATION, presignedUrl); |
Collaborator
There was a problem hiding this comment.
여기도 개발하기 편하게
log.info("생성된 Presigned URL: {}", presignedUrl); // ✅ 로깅 추가
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포트를 노출하도록 설정하세요.이미지 빌드 및 실행 테스트
local)를 지정하세요.Docker Compose 구성
docker-compose.yml파일을 작성합니다.BinaryContentStorage데이터가 유지되도록 하세요.schema.sql이 자동으로 실행되도록 구성하세요.depends_on).BinaryContentStorage 고도화 (AWS S3)
AWS S3 버킷 구성
AWS S3 접근을 위한 IAM 구성
discodeit)를 생성하세요.AmazonS3FullAccess권한을 할당하고, 사용자 생성을 완료하세요..env파일에 추가합니다.AWS S3 테스트
AWS S3를 활용한
BinaryContentStroage고도화S3BinaryContentStorage를 구현하세요.discodeit.storage.type값이s3인 경우에만 Bean으로 등록되어야 합니다.S3BinaryContentStorageTest를 함께 작성하면서 구현하세요.BinaryContentStorage설정을 유연하게 제어할 수 있도록application.yaml을 수정하세요..env파일에 작성된 값을 임포트하는 방식으로 설정하세요.download메소드는PresignedUrl을 활용해 리다이렉트하는 방식으로 구현하세요.AWS를 활용한 배포 (AWS RDS, ECR, ECS)
AWS RDS 구성
AWS ECR 구성
discodeit)를 생성하세요.aws configure실행 후 앞서 생성한discodeitIAM 사용자 정보를 입력하세요.discodeitIAM 사용자가 ECR에 접근할 수 있도록 다음 권한을 부여하세요.discodeit레포지토리에 push 하세요.AWS ECS 구성
discodeit클러스터 상세 화면에서 서비스를 생성하세요.심화 요구사항
이미지 최적화하기
빌드,런타임) 빌드를 활용해 이미지의 크기를 줄여보세요.GitHub Actions를 활용한 CI/CD 파이프라인 구축
.github/workflows/deploy.yml파일을 생성하세요.release브랜치에 코드가 푸시되면 실행되도록 설정하세요.리뷰를 위해 PR에 포함해야할 정보
원활한 리뷰를 위해 PR에 다음과 같은 정보를 포함해주세요.
[ ]
.env파일 (AWS 키는 제외)env.txt
RDS
ECS
VPC
멘토에게