-
Notifications
You must be signed in to change notification settings - Fork 4
전체 프로젝트 코드 대신 빌드한 JAR 파일만 AWS 에 배포하기 #14
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
base: main
Are you sure you want to change the base?
Conversation
| push: | ||
| branches: | ||
| - main | ||
| - push-only-jar-file-to-s3 |
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.
main 브랜치와 구분하기 위해 현재 브랜치를 기준으로 Github Actions 수행
| # (3.5) 빌드한 JAR 파일 복사 | ||
| - name: Copy Jar file | ||
| run: cp ./build/libs/*.jar ./deploy/spring-webapp.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.
Github Actions 에서 build 파일을 미리 복사합니다.
deploy 디렉터리를 압축해서 S3 에 푸시할 예정이라 해당 path 에 복사합니다.
| --ignore-hidden-files \ | ||
| --s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ | ||
| --source . | ||
| --source ./deploy |
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.
aws deploy push 명령어에서 --source 를 사용하면 압축할 path 를 지정할 수 있습니다.
deploy 디렉터리만 압축해서 보내도록 지정해줍니다.
| # build 파일 복사 | ||
| echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG | ||
| cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE | ||
|
|
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 Actions 워크플로우에서 JAR 파일을 복사했습니다.
AWS EC2 에는 프로젝트 전체가 있는게 아니라서 스크립트에서 해당 내용을 제외합니다.
Description
프로젝트 전체 코드를 올리는 대신 빌드 파일만 올리는 방법입니다.
기존 방식은 전체 프로젝트를 서버에 올린 후 빌드 파일을 복사해서 실행하는 거라면 새로운 방식은 Github Actions 에서 미리 빌드 파일을 복사해서 해당 파일만 올립니다.
AWS EC2
서버에 들어가서 확인해보면 jar 파일만 올라가있는 것을 확인할 수 있습니다
로그는 스크립트를 실행하면서 생긴겁니다.