-
Notifications
You must be signed in to change notification settings - Fork 0
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
Chore #10 개발서버 cicd 구축 #10
The head ref may contain hidden characters: "chore/#9/\uAC1C\uBC1C\uC11C\uBC84-CICD-\uAD6C\uCD95"
Conversation
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.
고생하셨습니다!
문제는 없는 것 같아요
도커 파일 수정과 dev에 머지하기 전에 개발 서버 환경변수 처리만 하면 될 것 같습니다!
Dockerfile-dev
Outdated
|
||
COPY ${JAR_FILE} docker-springboot.jar | ||
|
||
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=prod", "/docker-springboot.jar"] |
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.
스프링 환경이 prod로 되어있네요!
dev로 돌리면 조을 것 같아용
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.
고생하셨어요!
전체적으로 큰 문제는 없어보입니다!!
도커 네트워크 부분만 확인 부탁드려요!
.github/workflows/dev.yml
Outdated
# 이전 컨테이너 중지 및 삭제 | ||
echo "** 이전 컨테이너(${BEFORE_NAME}) 종료 및 삭제" | ||
sudo docker stop $BEFORE_NAME || true | ||
sudo docker rm $BEFORE_NAME || true |
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.
AFTER_NAME과 BEFORE_NAME으로 새로운 컨테이너와 이전에 사용한 컨테이너를 분리한 게 정말 좋네요!
새로운 컨테이너 관련 쉘 스크립트를 수정할 때, 한 눈에 수정해야 하는 부분을 찾을 수 있어 좋네요
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.
저도 아직 방법은 모릅니다만, 더이상 사용하지 않는 도커 이미지를 삭제하도록 해도 좋을 거 같아요.
CI/CD 구축 후 개발을 하면 항상 해당 서버에 도커 이미지가 잔뜩 쌓여있어 직접 일일이 지우기 번거롭더라고요
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.
docker image prune-a -f 로 지울 수 있어요!!
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.
배포 후 불필요한 이미지까지 정리하는 로직도 추가해서, 디스크 공간을 추가적으로 확보할 수 있도록 설정해놓겠습니다
sudo docker run --name $BLUE_NAME -d -p $BLUE_PORT:$BLUE_PORT \ | ||
--env-file ./gachtaxi-dev.env -e TZ=Asia/Seoul ${{ secrets.DEV_DOCKER_USER_NAME }}/gachtaxi |
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.
저희가 현재는 컨테이너 끼리 통신을 요구하지않고 gachtaxi-dev.env를 통해 환경 변수를 주입하고있는 형태라서 별도의 추가적인 네트워크 설정이 필요가 없는걸로 판단하였습니다
도커가 기본적으로 기본 네트워크를 사용하여 컨테이너 간 통신을 지원하는 것으로 알고있어, 별도의 네트워크 설정 없이 배포에는 문제가 없을거같습니다
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.
고생하셨어요!!!👍👍
📌 관련 이슈
관련 이슈 번호 #9
Close #
🚀 작업 내용
8080포트와 8081포트를 이용한 무중단 배포로 구상했습니다
Ec2가 아닌 라즈베리파이 환경이기 때문에 따로 AWS처럼 자동으로 .pem 파일을 제공하지않아서, 라즈베리 파이에서 키 생성 후 공개 키를 authorized_keys에 등록해준 뒤에, 개인 키 파일 .pem 형태로 변환해주는 방식을 사용했습니다. 해당 ssh 접속 방식은 생성한 .pem 파일을 사용해 로컬에서 라즈베리 파이에 접속 테스트를 완료했습니다. 해당 내용은 깃헙 액션으로 DEV_SSH_SECRET_PRIVATE_KEY 라는 이름으로 환경변수를 등록해놨습니다.
또한 라즈베리 파이에 배포 플로우 작성과성에서, 도커 이미지 생성과 빌드가 잘되는지 테스트하기 위해 직접 ssh로 접속해서 ARM 아키텍처 환경에서 Docker 이미지 빌드와 실행을 테스트하였습니다
추가로 deploy 조건인 if: github.event_name == 'push' 조건을 변경하고 배포까지 테스트를 완료했습니다
📸 스크린샷
📢 리뷰 요구사항
추가적인 내용으로 아래 사진처럼 깃헙액션 동적 ip 대역이 서버에서 자동으로 차단돼서 배포 과정에 문제가 생겨서
/etc/hosts.deny에서 모든 SSH 요청을 기본적으로 차단하고 있는 문제를 발견하고, 해당 내용(# sshd: ALL) 주석처리해서 트러블 슈팅 완료했습니다