-
Notifications
You must be signed in to change notification settings - Fork 1
Chore #1 CICD 구축 #4
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
Conversation
choes0101
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
작업 잘 해주셨습니다. 코멘트 남겨두었으니, 확인하시고 변경 부탁드립니다!
.env
Outdated
| DB_URL=jdbc:mysql://bookmark-db.cpcgeg8icg9s.ap-southeast-2.rds.amazonaws.com:3306/bookmark | ||
| DB_USERNAME=admin | ||
| DB_PASSWORD=bookmark12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env 파일은 Git에 커밋되지 않는 게 좋습니다!
보통 환경변수에는 민감한 내용이 포함될 수 있어서, .gitignore에 추가하고 Git 기록에서 제거해두면 더 안전할 것 같아요.
이미 커밋된 상태라서 비밀번호도 한 번 변경해두면 좋을 것 같습니다!
작업 잘 해주셔서 감사합니다 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.gitignore 로 옮기고 비밀번호도 한 번 변경해두었습니다!
seola12e
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
민감한 정보 secrets로 빼신 거랑, .env 파일 내리고 .gitignore에 추가한 것 좋은 것 같습니다!
작업하시느라 수고하셨습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음 맡으셔서 어려우셨을텐데 수고하셨어요 몇가지 코멘트 남겼습니다~
아, 그리고 이슈랑 PR 제목, 내용 모두 컨벤션과 템플릿 보고 수정 부탁드려요!
.github/workflows/dev.deploy.yml
Outdated
| on: | ||
| push: | ||
| branches: [ dev ] | ||
| pull_request: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR 단계에서 바로 배포되면 위험해요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
여기서
on:
push:
branches: [ dev ]
이렇게 pull_request를 없애면 될까요?
| @@ -0,0 +1,28 @@ | |||
| name: Deploy to EC2 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배포는 build가 확실히 완료된 이후에 진행되어야하는데 확인 부탁드려요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제 코드에서 deploy 부분에 needs:build만 추가하면 문제 없을까요?
.github/workflows/dev.build.yml
Outdated
| @@ -0,0 +1,48 @@ | |||
| name: Build and Push to DockerHub | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파일 이름을 build-dev.yml같은 형식으로 해주는게 한눈에 보기 편해보여요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 수정하겠습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정된 사항이 없는데 위 작성해주신 코멘트들을 먼저 반영하신 뒤에 리뷰를 다시 요청해주시면 더 좋을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했는데 아직 안올렸어요! 위에 말씀하심 부분들에 대해서 확실해지고 한번혹은 두번안에 커밋하겠습니당
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| public class HelloController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 컨트롤러는 삭제 부탁드려요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
배포 확인전 확인해보려고 만든건데 잘 작동하는 것을 확인했어요! 그러면 삭제해도 되는것일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네~ 해당 컨트롤러는 서비스에 필요하지 않아서 삭제해야돼요
나와야
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금 확인했는데 해당 파일은 무슨용도인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어라 저도 지금 봐서 다시 확인하겠습니다
jj0526
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 확인 부탁드려요
.env
Outdated
| @@ -0,0 +1,3 @@ | |||
| DB_URL=jdbc:mysql://bookmark-db.cpcgeg8icg9s.ap-southeast-2.rds.amazonaws.com:3306/bookmark | |||
| DB_USERNAME=admin | |||
| DB_PASSWORD=bookmarkbe1 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 내용들은 커밋되면 안돼요 해킹되면 과금될수도 있어요 ㅠㅠ
jj0526
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에 나눴던 내용중 여러개가 반영이 안된거같아요 확인 부탁해요
그리고 커밋메세지도 다 바꿔주세요
jj0526
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 남긴 내용 아니여도 다시 한번 찾아보고 고쳐주세요~ 제가 놓친게 있을수 있어요
그리고 커밋 메세지 전체랑 PR 템플릿 등등 컨벤션에 따라 부탁해요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤걸 수정하셨나요?
.github/workflows/deploy-dev.yml
Outdated
|
|
||
| jobs: | ||
| deploy: | ||
| needs: build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
job 이름이 필요한지 아니면 워크플로우 이름이 필요한지 한번 확인 부탁해요 저도 확실하지가 않아요
.github/workflows/deploy-dev.yml
Outdated
| username: ${{ secrets.EC2_USER }} | ||
| key: ${{ secrets.EC2_KEY }} | ||
| script: | | ||
| sudo timedatectl set-timezone Asia/Seoul |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 서버 시간을 배포할때마다 바꾸는거라 확인 부탁드려요
jj0526
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
커밋메세지랑 pr 템플릿 같은 부분들 컨벤션 보고 수정 부탁해요
jj0526
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr 템플릿이랑 커밋메세지 등 컨벤션 확인 부탁하고 수정부탁해요
fix: .gitignore 수정
fix:루트경로매핑
fix:deploy,build-dev 이름 변경, deploy-dev.yml 내용수정, 필요없는 파일 삭제
✅ 체크리스트: CICD 구축 및 자동 배포 설정
• CI/CD 워크플로우 구성
• GitHub Actions를 사용하여 dev 브랜치에 push / PR 시 자동으로 빌드 및 배포되도록 설정
• dev.build.yml 및 dev.deploy.yml 생성
• Docker 기반 빌드 및 이미지 푸시
• Gradle 빌드 후 Docker 이미지 생성
• Docker Hub로 이미지 푸시 (katekwak/bookmark-app:latest)
• EC2 서버 자동 배포 설정
• Docker Hub에서 이미지 pull 후 컨테이너 실행
• .env 파일을 통한 환경변수 주입
• 기존 컨테이너 중지 및 제거 후 재실행 처리 포함
• Gradle 캐시 설정
• GitHub Actions에서 빌드 속도 향상을 위한 Gradle 캐시 설정
• .env 환경변수 구성 및 외부화
• RDS(MySQL) 접속을 위한 환경변수 설정 (DB_URL, DB_USERNAME, DB_PASSWORD)
• .env는 Git에 커밋되지 않도록 설정
• EC2 서버 timezone 설정 (Asia/Seoul)
• HTTPS 서빙을 위한 Caddy 설정
• Caddy 설치 및 HTTP → HTTPS 자동 리디렉션 구성 완료
• 코드 풀 기반 배포 제거
• EC2 서버에서 git pull 방식 제거하고, 오직 Docker Hub 이미지 기반 배포로 전환