Conversation
- serverless v4부터 로그인/라이선스 키가 필요해 v3.38.0으로 고정 - AWS 인증은 환경 변수만으로 처리하도록 변경
- npx --no-install 옵션을 사용하여 serverless 버전 충돌 문제 해결
There was a problem hiding this comment.
Pull Request Overview
This PR implements a CD pipeline using GitHub Actions to deploy a Serverless application to AWS Lambda while addressing issues related to Serverless framework version compatibility, plugin conflicts, and package size constraints.
- Commented out Serverless dashboard configuration settings (org and app) to avoid login/license issues.
- Added an exclusion rule for pnpm-managed modules in the packaging configuration.
- Introduced a new GitHub Actions workflow for validation, building, and deployment of the application.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| serverless.yml | Disabled dashboard configuration and updated packaging exclusions. |
| .github/workflows/deploy.yml | Added a new workflow to validate, build, and deploy the app to AWS Lambda. |
Files not reviewed (1)
- package.json: Language not supported
Comments suppressed due to low confidence (1)
serverless.yml:7
- Commenting out these serverless plugins prevents local development scenarios from running as expected. Please confirm that these plugins are not required in non-CI environments or consider using conditional inclusion.
# - serverless-offline
.github/workflows/deploy.yml
Outdated
| name: build-artifact | ||
| path: | | ||
| dist/ | ||
| node_modules/ |
There was a problem hiding this comment.
Including the entire node_modules directory in the build artifact may lead to an excessively large deployment package. Consider excluding it if not required for deployment to mitigate potential packaging issues.
Ho-s
left a comment
There was a problem hiding this comment.
빠르고 정확한 작업... 고군 분투의 흔적이 보입니다! 너무 고생하셨어요! 🔥🔥🔥🔥🔥
.github/deploy.yml
Outdated
| run: yarn build | ||
|
|
||
| - name: Upload build artifact | ||
| uses: actions/upload-artifact@v3 |
There was a problem hiding this comment.
빌드 결과물을 저장하고 공유하는 사용합니다!
다른 워크플로우 작업이나 단계에서 빌드 결과물을 공유하기 위해 사용했습니다!
현재 2개 두 개의 별도 작업으로 구성되어 있습니다.
- validate 작업: 코드를 체크아웃하고, 의존성을 설치하고, 빌드하는 작업
- deploy 작업: 빌드된 결과물을 AWS Lambda에 배포하는 작업
.github/deploy.yml
Outdated
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| DB_URL: ${{ secrets.DB_URL }} | ||
| DB_HOST: ${{ secrets.DB_HOST }} |
There was a problem hiding this comment.
기존에는 PORT와 DB_URL 만 쓰고 있습니다!
labyrinth30
left a comment
There was a problem hiding this comment.
서버리스로 CD하는 건 저도 익숙치 않네요. 진행하시면서 엄청 고생하신 것 같습니다!
토요일에 같이 이야기하면 좋을 것 같습니다!
- lambda 환경에서 bcrypt는 호환 이슈가 있어요 ref: kelektiv/node.bcrypt.js#505 (comment)
| "@prisma/client": "^6.5.0", | ||
| "aws-lambda": "^1.0.7", | ||
| "bcrypt": "^5.1.1", | ||
| "bcryptjs": "^3.0.2", |
| return ctx.getContext().req.user; | ||
| (_: unknown, context: ExecutionContext) => { | ||
| const gqlContext = GqlExecutionContext.create(context); | ||
| const { user } = gqlContext.getContext<GraphQLContext>(); |
There was a problem hiding this comment.
제네릭으로 타입 명시하니까 타입 안정성도 높이고, 명확성과 유지보수성도 높아지는 것 같습니다👍
- npx prisma generate 는 삭제 -> yarn install 시 prisma 내부 postinstall 로 shcema에 따라 자동 생성
|
@Ho-s 수정 감사합니다 ! 👍 |
labyrinth30
left a comment
There was a problem hiding this comment.
병호형이 말한 것처럼 @generated만 없어지면 좋을 것 같습니다!
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Run Prisma migrations | ||
| run: npx prisma migrate deploy 2>&1 | grep -v 'Datasource "db":' | grep -v 'PostgreSQL database' |
There was a problem hiding this comment.
덕분에 쉘 명령어 다시 공부했네요ㅋㅋㅋㅋ 불필요한 정보 마스킹하는 것 잘 배워갑니다!
| - 'node_modules/.prisma/client/libquery_engine-rhel-*' | ||
| - '!node_modules/prisma/libquery_engine-*' | ||
| - '!node_modules/@prisma/engines/**' | ||
| - '!node_modules/aws-lambda' |
| @@ -0,0 +1,29 @@ | |||
| name: Run build & test | |||
| @@ -0,0 +1,43 @@ | |||
| name: Deploy serverless application | |||
There was a problem hiding this comment.
cd 과정을 여러 개로 나누는 걸 처음 봤는데, 유연하게 사용할 수 있는 게 큰 장점인 것 같아요 👍
There was a problem hiding this comment.
장단이 있는 것 같습니다.
책임 분리 측면에서는 장점을 가집니다.
기존에 @hye-on 님이 해주신 방식의 경우에는 중복 로직을 제거할 수 있다는 장점을 가졌었죠!
상황에 따라 선택하면 좋아보입니다!
📝 작업 내용
cd 작업했습니다.
💬 리뷰 요구사항(선택)
전체적인 플로우 봐주세요!
더 좋은 문제 해결법이 있을 것 같은데,, 혹시 아는 거 있으면 알려주세요! :)
⛔ serverless 버전4에서는 로그인 필수
Error: You must sign in or use a license key with Serverless Framework V.4 and later versions. Please use "serverless login".=>Serverless Framework v4부터 로그인이나 라이선스 키가 필요
실패한 github action
=> 🔑 3.38.0로 버전 낮춰서 해결
-> 나중에 라이선스 키 받으면 4로 올려도 좋을 것 같아요
⛔ 플러그인 충돌
TypeError: Cannot redefine property: _serverlessExternalPluginName실패한 github action
시도한 방법
https://forum.serverless.com/t/cannot-redefine-property-serverlessexternalpluginname/20666
serverless/serverless#12936
-> 이거 보고 노드 버전 수정해봤는데 해결안되었습니다.
=> 🔑
serverless.yml에서 플러그인 주석 처리해서 해결
CI/CD 배포 단계에서 필요없는 플러그인 인것같아서 주석처리 했는데 문제 없으면 주석 삭제해서 커밋하겠습니다.
⛔ 패키지 사이즈 너무 커서 람다 배포안되는 문제
실패한 github action
=> 🔑
serverless.yml에 - '!node_modules/.pnpm/**' 추가임시방편 인 것 같아서 조금 더 이유를 찾아볼께요.
⛔ 서울 리전 지원안되는 문제
https://www.serverless.com/framework/docs/guides/dashboard/cicd/running-in-your-own-cicd#configure-environment-variables
SERVERLESS_ACCESS_KEY로 하면 대시보드에 엑세스하는데 대시보드 모드가 서울리전이 지원안되는 것 같아요.
실패한 github action
=> 🔑
SERVERLESS_ACCESS_KEY사용안하고 AWS 자격 증명(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)만 사용아래 코드 주석처리 해서 대시보드 기능 비활성화
(혹시 아니면 말해주세욤)
serverless.yml📚 참고할만한 자료(선택)