From 9567e0b3a051fe4d366648196170d8b6027111d7 Mon Sep 17 00:00:00 2001 From: esc Date: Wed, 28 Jan 2026 02:34:34 +0900 Subject: [PATCH 1/4] =?UTF-8?q?docs:=20issue=20template=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug-template.md | 28 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-template.md | 20 +++++++++++++++ .github/ISSUE_TEMPLATE/refactor-template.md | 26 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-template.md create mode 100644 .github/ISSUE_TEMPLATE/feature-template.md create mode 100644 .github/ISSUE_TEMPLATE/refactor-template.md diff --git a/.github/ISSUE_TEMPLATE/bug-template.md b/.github/ISSUE_TEMPLATE/bug-template.md new file mode 100644 index 0000000..6ccc7ff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-template.md @@ -0,0 +1,28 @@ +--- +name: Bug Template +about: 버그 템플릿 +title: '' +labels: '' +assignees: '' +--- + +## 📝 개요 및 증상 + +- 버그 발생 상황: +- 기대한 동작 + - (어떻게 동작할 것이라고 기대했는지 작성합니다.) +- 실제 동작 + - (실제로 어떻게 동작했는지 작성합니다.) + +
+ +## 📸 스크린샷 (필요 시) + +
+ +## 🐛 버그 재현 방법 + +1. '...'에 간다. +2. '....'를 클릭한다. +3. '....'까지 스크롤을 내린다. +4. 에러를 확인한다. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature-template.md b/.github/ISSUE_TEMPLATE/feature-template.md new file mode 100644 index 0000000..d17fd4b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-template.md @@ -0,0 +1,20 @@ +--- +name: Feature Template +about: 기능 구현 작성 템플릿 +title: '' +labels: '' +assignees: '' +--- + +## 📝 구현 목록 + +- [ ] 작업1 +- [ ] 작업2 + - [ ] 작업 2-1 + - [ ] 작업 2-2 + +
+ +## 💡 참고자료 + +- (없다면 이 항목을 지워주세요.) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/refactor-template.md b/.github/ISSUE_TEMPLATE/refactor-template.md new file mode 100644 index 0000000..fcba6e9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/refactor-template.md @@ -0,0 +1,26 @@ +--- +name: Refactor Template +about: 리팩토링할 기능 템플릿 +title: '' +labels: '' +assignees: '' +--- + +## 🤔 코드 개선 필요성 + +- (코드를 어떤 이유에서 변경하는지) + +
+ +## 📝 구현 목록 + +- [ ] 구현 내용1 + - [ ] 세부 구현 내용 +- [ ] 구현 내용2 + - [ ] 세부 구현 내용 + +
+ +## 💡 참고자료 + +- (없다면 지워도 됩니다!) \ No newline at end of file From b800f952688aa76ed51d3451e35f90ff5d41b439 Mon Sep 17 00:00:00 2001 From: esc Date: Wed, 28 Jan 2026 02:34:54 +0900 Subject: [PATCH 2/4] =?UTF-8?q?docs:=20PR=20template=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..6b34252 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +## 🎯 관련 이슈 +close + +## 🚀 어떤 기능을 개발했나요? +- + +### 🕶️ 어떻게 해결했나요? +- + + From ec0705b2a047334b87c277603c11337bcdf13c96 Mon Sep 17 00:00:00 2001 From: esc Date: Wed, 28 Jan 2026 02:52:03 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20OICD=EB=A1=9C=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-lambda.yaml | 75 ++++++++++++++++++++++++ .github/workflows/dev-deploy-lambda.yaml | 49 ---------------- 2 files changed, 75 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/deploy-lambda.yaml delete mode 100644 .github/workflows/dev-deploy-lambda.yaml diff --git a/.github/workflows/deploy-lambda.yaml b/.github/workflows/deploy-lambda.yaml new file mode 100644 index 0000000..22be398 --- /dev/null +++ b/.github/workflows/deploy-lambda.yaml @@ -0,0 +1,75 @@ +name: Deploy to Lambda (ECR) + +on: + push: + branches: [ "develop", "main" ] + +# OIDC 인증을 위한 권한 설정 +permissions: + id-token: write + contents: read + +jobs: + deploy: + name: Build, Push to ECR, and Deploy to Lambda + runs-on: ubuntu-latest + + # 브랜치에 따라 사용할 환경 선택 + environment: ${{ github.ref == 'refs/heads/main' && 'PROD' || 'DEV' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # AWS 자격 증명 설정 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ vars.AWS_ROLE_ARN }} + aws-region: ${{ vars.AWS_REGION }} + + # Amazon ECR 로그인 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + # Docker 이미지 빌드 및 푸시 + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY_NAME }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f Dockerfile . + + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + + echo "image_uri=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + # Lambda 함수 업데이트 + - name: Deploy new image to AWS Lambda + run: | + aws lambda update-function-code \ + --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} \ + --image-uri ${{ steps.build-image.outputs.image_uri }} + + # 코드 업데이트가 완료될 때까지 대기 + - name: Wait for Lambda function update to complete + run: | + aws lambda wait function-updated \ + --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} + + # Lambda 환경 변수 설정 + - name: Update Lambda Environment Variables + run: | + aws lambda update-function-configuration \ + --function-name ${{ vars.LAMBDA_FUNCTION_NAME }} \ + --environment "Variables={ \ + REGION_NAME=${{ vars.AWS_REGION }}, \ + LAMBDA_FUNCTION_NAME=${{ vars.LAMBDA_FUNCTION_NAME }}, \ + ECR_REPOSITORY_NAME=${{ vars.ECR_REPOSITORY_NAME }}, \ + BUCKET_NAME=${{ vars.BUCKET_NAME }}, \ + RESIZED_BUCKET=${{ vars.RESIZED_BUCKET }} \ + }" \ No newline at end of file diff --git a/.github/workflows/dev-deploy-lambda.yaml b/.github/workflows/dev-deploy-lambda.yaml deleted file mode 100644 index a948a03..0000000 --- a/.github/workflows/dev-deploy-lambda.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: Dev Deploy ECR - -on: - push: - branches: [ "main" ] - -env: - AWS_REGION: ${{ vars.AWS_REGION }} - ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY_NAME }} - LAMBDA_FUNCTION_NAME: ${{ vars.LAMBDA_FUNCTION_NAME }} - -jobs: - deploy: - name: Build, Push to ECR, and Deploy to Lambda - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} - run: | - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest -f Dockerfile . - - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - - echo "image_uri=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT - - - name: Deploy new image to AWS Lambda - run: | - aws lambda update-function-code \ - --function-name $LAMBDA_FUNCTION_NAME \ - --image-uri ${{ steps.build-image.outputs.image_uri }} \ No newline at end of file From 0b77ae0f1800e03314d237c3fb32e68a9eb72149 Mon Sep 17 00:00:00 2001 From: esc Date: Wed, 28 Jan 2026 02:52:41 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20lambda=EA=B0=80=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B3=80=EC=88=98=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lambda_compare.py | 9 +++++---- lambda_function.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lambda_compare.py b/lambda_compare.py index f55aa06..87967e6 100644 --- a/lambda_compare.py +++ b/lambda_compare.py @@ -3,13 +3,14 @@ import base64 import re import time +import os from urllib.parse import quote_plus -REGION_NAME = "ap-northeast-2" -BUCKET_NAME = "snorose-bucket" +REGION_NAME = os.environ.get('REGION_NAME') +BUCKET_NAME = os.environ.get('BUCKET_NAME') TEST_KEY = "post-attachment/1718321/test_video.mp4" -FUNC_CONSOLE = "CreateOptimizedContentAttachment" -FUNC_IMAGE = "CreateOptimizedContentAttachmentECR" +LAMBDA_FUNCTION_NAME = os.environ.get('LAMBDA_FUNCTION_NAME') +ECR_REPOSITORY_NAME = os.environ.get('ECR_REPOSITORY_NAME') client = boto3.client('lambda', region_name=REGION_NAME) diff --git a/lambda_function.py b/lambda_function.py index b7edc47..c4fc961 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -7,7 +7,7 @@ from PIL import Image, ImageOps s3_client = boto3.client('s3') -resized_bucket = 'snorose-bucket-resized' +resized_bucket = os.environ.get('RESIZED_BUCKET') IMG_EXT_LIST = ("jpg","jpeg","png","jfif","bmp","webp") VDO_EXT_LIST = ("mp4","mov")