Devops/AWS

[AWS] github action + Elastic Beanstalk + Kotlin SpringBoot ๋ฐฐํฌ cp: cannot stat './build/libs/*.jar': No such file or directory ์˜ค๋ฅ˜

yuri lee 2023. 1. 28. 20:37
๋ฐ˜์‘ํ˜•

Intro

์•ˆ๋…•ํ•˜์„ธ์š”. ์ €๋Š” Kotlin SprinBoot 3.0 ์œผ๋กœ github action์„ ํ†ตํ•ด AWS์˜ Elastic Beanstalk๋ฅผ ์‚ฌ์šฉํ•ด  API Server ๊ฐœ๋ฐœํ™˜๊ฒฝ ๊ตฌ์„ฑํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. Elastic Beanstalk ์„ธํŒ…๊ณผ, githb action ๊ด€๋ จ ์„ค์ •์„ ๋ชจ๋‘ ๋งˆ์น˜๊ณ , github push ๋ฅผ ํ†ตํ•ด ๋ฐฐํฌ๊ฐ€ ์ •์ƒ ์ž‘๋™ํ•˜๋Š”์ง€ ํ…Œ์ŠคํŠธ ํ•˜๋˜ ๋„์ค‘ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. 

 

 

cp: cannot stat './build/libs/*.jar': No such file or directory 

 

Why?

๋ฐ”๋กœ ํ•ด๋‹น ์—๋Ÿฌ๋ฅผ ๊ตฌ๊ธ€๋ง ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. ๊ตฌ๊ธ€๋ง์„ ํ•ด๋ณด๋‹ˆ, ์Šคํ”„๋ง ๋ถ€ํŠธ 2.5.0 ์ด์ƒ ๋ฒ„์ „์€ ๋”ฐ๋กœ ์„ค์ • ์—†์ด Gradle ๋นŒ๋“œํ•  ๊ฒฝ์šฐ, BootJar์™€ Jar ๊ฐ€ ๋ชจ๋‘ ์ƒ์„ฑ๋˜์–ด build/libs ์œ„์น˜์— ํŒŒ์ผ 2๊ฐœ๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ์ฝ”๋“œ๋Š” github action ์„ค์ • ํŒŒ์ผ์ธ๋ฐ์š”, build/libs ์œ„์น˜์— ํŒŒ์ผ์ด 2๊ฐœ ์ƒ์„ฑ๋˜๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น ๋ณต์‚ฌ ๋ช…๋ น์–ด์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋˜ ๊ฒƒ์ž…๋‹ˆ๋‹ค. 

  - name: Generate deployment package # (1)
    run: |
      mkdir -p deploy
      cp ./build/libs/*.jar deploy/application.jar
      cp ./api/Procfile deploy/Procfile
      cp -r .ebextensions deploy/.ebextensions
      cp -r .platform deploy/.platform
      cd deploy && zip -r deploy.zip .

 

์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ์Šคํ”„๋ง๋ถ€ํŠธ ๋ฒ„์ „์€ 3 ๋ฒ„์ „์ด์˜€๊ธฐ ๋•Œ๋ฌธ์—, ์‹ค์ œ ๋นŒ๋“œ์‹œ ํŒŒ์ผ์ด 2๊ฐœ ์ƒ์„ฑ๋˜๋Š”์ง€ ํ™•์ธํ•ด ๋ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ ํด๋” ๋‚ด์—์„œ Gradle build ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋นŒ๋“œ๋ฅผ ํ•ด๋ดค๊ณ , ์‹ค์ œ 2๊ฐœ๊ฐ€ ์ƒ์„ฑ๋˜๊ณ  ์žˆ์Œ์„ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค.

 

 

How to solve the problem

build.gradle.kts ํŒŒ์ผ์— ์•„๋ž˜์™€ ๊ฐ™์€ ์„ค์ •์„ ์ถ”๊ฐ€ํ•ด์คฌ์Šต๋‹ˆ๋‹ค. Jar task๋ฅผ ์Šคํ‚ตํ•ด์ฃผ์—ˆ๋”๋‹ˆ ๋”์ด์ƒ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. 

tasks.getByName<Jar>("jar") {
    enabled = false
}

 

Conclusion

์ƒ๊ฐ๋ณด๋‹ค ๋ฐฐํฌํ•˜๋Š” ๊ณผ์ •์—์„œ ๋งŽ์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜์Œ์œผ๋กœ github action์™€ AWS์˜ Elastic Beanstalk์„ ์‚ฌ์šฉํ•ด๋ดค๋Š”๋ฐ์š”, ๊ณต๋ถ€ํ•  ๋‚ด์šฉ๋„ ๋งŽ๊ณ  ์–ด๋ ค์› ๋„ค์š”. ๐Ÿฅฒ ๊ทธ๋ž˜๋„ ์ด ๊ณผ์ •์„ ํ†ตํ•ด ์ „๋ณด๋‹ค ์ƒˆ๋กœ์šด ์ง€์‹๋“ค์„ ๋งŽ์ด ๋ฐฐ์šฐ๊ฒŒ ๋œ ๊ฒƒ ๊ฐ™์•„ ์ข‹์Šต๋‹ˆ๋‹ค :) 

๋ฐ˜์‘ํ˜•