aws 서버에 프로젝트 배포를 하는데 build fail 오류가 생겨 해결방법을 기록한다git으로 서버배포할 때 참고한 블로그
-> https://velog.io/@wndudrla1011/chapter-8
EC2 서버에 프로젝트 배포하기 - 루타블의 개발일기
🔧 먼저 깃허브에서 코드를 받아올 수 있게 EC2에 깃을 설치하겠다.sudo yum install git🔧 설치가 완료되면 다음 명령어로 설치 상태를 확인git --version🔧 git이 성공적으로 설치되면 git clone으로 프로
velog.io
위에 스텝대로 무난히 진행되다가 build fail 메세지가 출력됨
$ ./deploy.sh
> Git Pull
Already up to date.
> 프로젝트 Build 시작
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
Directory '/home/ubuntu/app/repository/MyApp' does not contain a Gradle build.
A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. It may also contain a 'build.gradle' or 'build.gradle.kts' file.
To create a new Gradle build in this directory run 'gradlew init'
For more information about the 'init' task, please refer to https://docs.gradle.org/8.5/userguide/build_init_plugin.html i n the Gradle documentation.
For more details on creating a Gradle build, please refer to https://docs.gradle.org/8.5/userguide/tutorial_using_tasks.ht ml in the Gradle documentation.
* Try:
> Run gradlew init to create a new Gradle build in this directory.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.
천천히 읽어보니 setting.gradle이 없단다..
로컬에서 프로젝트 폴더에 확인해보니 정말 없다..어휴 결국 직접 파일을 만들어 git에 push 해주었다
#settings.gradle
rootProject.name = 'MyApp'
settinds.gradle 파일은 build.gradle과 같은 경로에 생성해주었다.
다시 ec2로 가서 빌드설정파일을 실행해주었다
$ ./deploy.sh
> Git Pull
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 17 (delta 6), reused 17 (delta 6), pack-reused 0
Unpacking objects: 100% (17/17), 7.59 KiB | 22.00 KiB/s, done.
From https://github.com/ds-jeong/MyApp
5fce017..21f8cda master -> origin/master
Updating 5fce017..21f8cda
Fast-forward
.gradle/8.5/executionHistory/executionHistory.bin | Bin 440109 -> 440109 bytes
.gradle/8.5/executionHistory/executionHistory.lock | Bin 17 -> 17 bytes
.gradle/8.5/fileHashes/fileHashes.bin | Bin 41647 -> 41647 bytes
.gradle/8.5/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes
.gradle/buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 17 bytes
.gradle/file-system.probe | Bin 8 -> 8 bytes
build/libs/MyApp-0.0.1-SNAPSHOT-plain.jar | Bin 6494917 -> 6494917 bytes
settings.gradle | 1 +
8 files changed, 1 insertion(+)
create mode 100644 settings.gradle
> 프로젝트 Build 시작
<-<-------------> 0% CONFIGURING [11m 13s]
> root project
^C^Z
[1]+ Stopped ./deploy.sh
오? 된거같다 근데 command가 멈췃다
흠..springBoot 프로젝트를 배포할땐 느리다는데 그문제인가..
서치를 해보니 나같은 경우가 있더라
->https://sundries-in-myidea.tistory.com/102
AWS EC2 프리티어에서 메모리 부족현상 해결방법
AWS free tier를 사용하다보면 2%가 부족할 때가 있다. AWS 프리티어는 가난한 대학생에게는 한줄기 빛과 같은 존재인데, AWS의 프리티어라서 적게 돈이 나가는 것도 좋고, 실제로 이것저것 해볼 수 있
sundries-in-myidea.tistory.com
감사하게도 위 블로그를 참고했더니 1분도안되서 빌드가 끝나고 튕기는 현상도 없다
$ ./deploy.sh
> Git Pull
Already up to date.
> 프로젝트 Build 시작
Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
> Task :buildEnvironment
------------------------------------------------------------
Root project 'MyApp'
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 12s
1 actionable task: 1 executed
> step1 디렉토리로 이동
> Build 파일 복사
> 현재 구동 중인 애플리케이션 pid 확인
현재 구동 중인 애플리케이션 pid:
> 현재 구동 중인 애플리케이션이 없으므로 종료하지 않는다.
> 새 애플리케이션 배포
> JAR Name: MyApp-0.0.1-SNAPSHOT-plain.jar
제대로 올라간듯 하다
-> https://velog.io/@m1njae/AWS-%ED%83%84%EB%A0%A5%EC%A0%81-IP-%EC%A3%BC%EC%86%8C-%EC%84%A4%EC%A0%95
[AWS] 탄력적 IP 주소 설정
EC2 인스턴스를 껐다가 다시 실행하면 IP가 변경된다고? 탄력적 IP 주소를 설정하자!
velog.io
위에 블로그를 참고해서 화면을 위한 탄력 ip를 할당받았다
-> https://velog.io/@hoooons/AWS-EC2-%EB%A1%9C-React-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0
그리곤 위에 블로그를 참고해서 여러 패키지를 다운로드를 완료했다
npm error code ENOSPC
npm error syscall write
npm error errno -28
npm error nospc ENOSPC: no space left on device, write
npm error nospc There appears to be insufficient space on your system to finish.
npm error nospc Clear up some disk space and try again.
npm error A complete log of this run can be found in: /home/ubuntu/.npm/_logs/2024-08-05T13_08_44_437Z-debug-0.log
react root 폴더에서 npm start 명령어를 시도했더니 위와 같은 에러를 뱉는다..
서버에서 최적화하고 난리를 쳐도 안되길래 서치끝에 찾아냈다
pakage.json내에 sourcemap 를 false 처리해주는것..
보통 개발환경에서는 바로 소스코드를 확인할수 있도록 디폴트가 true로 되있지만
실서버에선 소스코드를 확인할 일이 없고, 빌드시 해당 과정에서 메모리를 많이 사용한다..
#pakage.json
/* "build": "react-scripts build",*/
"scripts": {
"start": "react-scripts start",
"build" : "GENERATE_SOURCEMAP=false react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
해서 위와 같이 수정 후 git에 반영해주고 aws에서는 다시 pull..
수정 된 json 파일을 가지고 왔지만 혹시 몰라 디스크공간을 확보 위까지 진행했다
/*시스템 재부팅*/
$ sudo reboot
여기까지하고 보통 npm start가 된다
주소창에 탄력ip:3000으로 치면 화면이나와야 정상
혹시 몰라 aws에 보안 그룹을 확인해보니 3000 port 는 열려있음
원인을 찾다가 캐시문제인가 싶어서 아래 스텝을 진행해보았다
/*임시 파일 삭제*/
$ sudo rm -rf /tmp/*
/*로그 파일 삭제*/
$ sudo rm -rf /var/log/*.log
/*npm 캐시 삭제*/
npm cache clean --force
/*패키지 제거*/
$ sudo apt-get autoremove
$ sudo apt-get clean
/*시스템 재부팅*/
$ sudo reboot
여기까지 실행 후 npm 재설치를 해줬는데.. 여전한 에러..
$ npm install
npm error code ENOTEMPTY
npm error syscall rename
npm error path /home/ubuntu/app/repository/MyApp/src/main/frontend/node_modules/acorn
npm error dest /home/ubuntu/app/repository/MyApp/src/main/frontend/node_modules/.acorn-I5v5oviz
npm error errno -39
npm error ENOTEMPTY: directory not empty, rename '/home/ubuntu/app/repository/MyApp/src/main/frontend/node_modules/acorn' -> '/home/ubuntu/app/repository/MyApp/src/main/frontend/node_modules/.acorn-I5v5oviz'
npm error A complete log of this run can be found in: /home/ubuntu/.npm/_logs/2024-08-05T13_25_20_689Z-debug-0.log
/*node_modules 삭제*/
$ rm -rf node_modules
/*npm 캐시 clean*/
$ npm cache clean --force
$ npm install
/*package-lock.json 삭제*/
$ rm package-lock.json
$ npm install
/*node_modules 권한 수정*/
$ sudo chown -R $USER:$GROUP node_modules
/*.npm 디렉토리 권한 및 파일 확인*/
sudo chown -R $USER:$GROUP ~/.npm
/*시스템 재부팅*/
$ sudo reboot
이제서야 된다..흠? node_modules 충돌인건가; 어쨋든 서버가 올라가는걸 확인했다
'Server' 카테고리의 다른 글
Linux / Ubuntu 설치 후 보안설정 및 시간동기화 (0) | 2022.07.15 |
---|---|
Linux / 디렉토리 구조와 설명 (0) | 2022.07.13 |
Linux / Linux Ubuntu zulu -version 11 설치 (0) | 2022.07.13 |
Linux / Window10 운영체제에 LinuxUbuntu 설치 (0) | 2022.07.13 |