[8주차] 성현준/ [deploy] Docker Compose 및 GitHub Actions CI/CD 설정 #137
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.
1. 무슨 이유로 코드를 변경했나요?
8주차 과제인 Docker Compose를 통한 멀티 컨테이너 환경 구성과 GitHub Actions CI/CD 파이프라인 구축을 완료했습니다.
Docker Compose를 사용하여 MySQL 데이터베이스와 Spring Boot 애플리케이션을 함께 실행할 수 있도록 docker-compose.yml 파일을 작성했습니다. 또한 GitHub Actions를 통해 코드 푸시 시 자동으로 빌드 및 배포가 이루어지도록 CI/CD 파이프라인을 구축했습니다.
민감한 정보가 포함된 application.yml 파일을 GitHub Secrets에 저장하여 보안을 강화하고, CI/CD 실행 시 Secret에서 읽어와 사용하도록 설정했습니다.
2. 어떤 위험이나 장애를 발견했나요?
초기에는 GitHub Actions 워크플로우 파일을 blog_manage 폴더 내부에 생성하여 GitHub Actions가 워크플로우를 인식하지 못하는 문제가 발생했습니다. GitHub Actions는 리포지토리 루트의 .github/workflows/ 경로를 찾기 때문에 워크플로우 파일을 리포지토리 루트로 이동하고, docker-compose.yml과 Dockerfile 경로를 blog_manage/로 수정하여 해결했습니다.
GitHub Actions runner에서 docker-compose 명령어를 찾을 수 없는 문제가 발생했습니다. 최신 Docker CLI는 docker compose (하이픈 없이)를 사용하므로 명령어를 수정하여 해결했습니다.
로컬에서 docker-compose 실행 시 MySQL 포트(3306)가 이미 사용 중이어서 포트 충돌이 발생했습니다. docker-compose.yml에서 MySQL 외부 포트를 3307로 변경하여 해결했습니다.
3. 완료 사항
docker-compose.yml: MySQL 8.0 이미지와 Dockerfile로 빌드한 Spring Boot 애플리케이션을 포함한 멀티 컨테이너 환경 구성
.github/workflows/cicd.yml: GitHub Actions CI/CD 파이프라인 구축 (코드 체크아웃, application.yml 생성, Docker Compose 빌드 및 실행, 헬스 체크, 로그 확인)
GitHub Secrets: application.yml 파일을 APPLICATION_YML Secret에 저장하여 민감한 정보 보호
Docker Compose 설정: MySQL healthcheck 추가, 네트워크 및 볼륨 설정, 환경 변수 설정
5. 추가 사항
close #136