Skip to content
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

♻️ci: add lambda CI/CD workflow #161

Merged
merged 5 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/lambda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy to Amazon Lambda

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
paths:
- "app/**"
- "public/**"
- "bun.lockb"
- "package.json"
- "yarn.lock"
- "*config.*"
workflow_dispatch:

env:
AWS_REGION: ap-northeast-1
ECR_REPOSITORY: rasnage
LAMBDA_FUNCTION_NAME: rasnage

jobs:
deploy:
if: github.repository == 'OpenUp-LabTakizawa/rasnage'
runs-on: ubuntu-latest

steps:
- name: Checkout
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 .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:21.6.1 as base
FROM node:21.6.2 as base
WORKDIR /app
RUN npm install -g bun

Expand All @@ -15,13 +15,15 @@ RUN bun run build

FROM oven/bun:canary-distroless
WORKDIR /usr/src/app
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.1 /lambda-adapter /opt/extensions/lambda-adapter

ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nonroot:nonroot /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

USER nonroot
EXPOSE 80
ENV PORT 80
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
CMD ["run", "server.js"]
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@happy-dom/global-registrator": "^13.3.8",
"@testing-library/react": "^14.2.1",
"@types/bun": "^1.0.5",
"@types/node": "^20.11.18",
"@types/node": "^20.11.19",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"postcss": "^8.4.35",
Expand Down
158 changes: 79 additions & 79 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: D62CC6F4F2C4FEB5-7924708280739a19-8271F94AA9593AB1-e53be327b4f82b9f
# bun ./bun.lockb --hash: 2CB551630D7F6344-2a1ad0db074f08c6-CDBFDCB65BA1EEED-a333c53c99e666de


"@alloc/quick-lru@^5.2.0":
Expand Down Expand Up @@ -142,55 +142,55 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/env/-/env-14.1.1-canary.55.tgz"
integrity sha512-qZFxjt7CvUbdBr1gpDftMQGkXLcXQoA9qHb8SYt3buPkbd1cSe053CtTLE0pRSiA0WTB+wo8pdH2UeFNmjHxBQ==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.1-canary.55.tgz"
integrity sha512-NDSn045AmJogCqEK9HFlJwpqV22Ll3ASPSoWcxwNLs/fWCXszMpEcQeAmAGp5WoXdVdBUFF5eZdHSp0wHxml1w==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.1-canary.55.tgz"
integrity sha512-o5d1z/2No+ufUh94DjLtMraAm5CfmSu+33j5DhIstCyYcZNUlEUefZy8VvsnYBP1ll8mXU5HxJ6cltlwzU6j+A==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.1-canary.55.tgz"
integrity sha512-XHm/hsl+N2cqcVNgOauryoLSrirj1XYwDrhUAvZPiMjRo4ebu1o7IjWxXWzSSA9WGEA1w7VeVVus73snRjL80w==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.1-canary.55.tgz"
integrity sha512-8h68Rd2O63hPFz6W3bBe+wIRQgHpgwaNKJTer7CEeH6TMl54yY4soLwE/qqK5KHD6+DBiFwdzif1u6iCTwCpqQ==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.1-canary.55.tgz"
integrity sha512-PitwrIY549Fv4GiU2LLJfCa6pw1+8li0bQhSsnkcjy2LEySk05kmrTsg0pXUJIMktYP5S/9ANVyxw9ZbywyFlg==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.1-canary.55.tgz"
integrity sha512-cPqXwiZRMplgbbBrXTTZR5S5K8CMGoWMhh0oqD694Ze/JpkapCGtycoeSzJS9jGnzdGP71c3hLSbUYP/LZqzBA==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.1-canary.55.tgz"
integrity sha512-6il5ojMXhW/o9HAsqq2PGbqTwieZ3GOZ74OBdnWpF/W6/IfK151CcxTDjC/SLbqI9XDT9bd37IwVYAurStWqpQ==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.1-canary.55.tgz"
integrity sha512-K3yDYvK1JO5sdFBIqEQPRoW/Tdcy5f2JKNy74/7gT1h2SL1XMlS9M5bhFeOYhKgi2t+kaZXRCMFxzp3QBIxVcA==

"@next/[email protected].55":
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.1-canary.55.tgz"
integrity sha512-FDxSggTRKiDA2m8+v8Uz5x5NtBqh2OTBR0OGa7TRb6yVTYnnToxjYt+PzLmaGe8UGBCHCkObMBLI9Tct/bgM2Q==
"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/env/-/env-14.1.1-canary.56.tgz"
integrity sha512-2C+38wg1ZTb9N3HagtLZIjhPg0cbB97PmbgAKLMg+QOttyjmBiVjb231XWHKjqoEhY9u/ILWNbzgQ8gD5JplkA==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.1.1-canary.56.tgz"
integrity sha512-xqCZidAakgTw0iQaWK3IRgbu1o8i2dRFjLkvAF1QPZruVFlSaCIKoSo3GUebJcrvzcHVzRkDKnr+FlWLmES5zA==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.1.1-canary.56.tgz"
integrity sha512-febsltDU+jnNhK3qZriJ58FSmyZtJkOtih5t0VDusgM8MdfwVfcfv0kMVSZOygdWrJLhml5OKBC4XdX4BDGpEw==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.1.1-canary.56.tgz"
integrity sha512-4Zj09znOpXxU6y2BBVEo5jfa4aeiJVg5d4dbcAnuDL7n26xzQL62UOXflSLdijZ8842qcIUN5SQa1kqZlixj+w==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.1.1-canary.56.tgz"
integrity sha512-CfDodJ/hjqdYYDpVZ0Jxjab8lmrl74Z3Y1tp12lzZA3jnrjXq66Wj8ckQ81H+Omn4ObovpMD+DRL8/xKXdC7HQ==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.1.1-canary.56.tgz"
integrity sha512-tHUaCQOaFxuUWR/7tvnFQTNOVKmmtKE2SdNfh5rzYz00JjYhVf3aR9hqOvCBmck0LJ77FmZK+8pBwUb8Jouz9g==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.1.1-canary.56.tgz"
integrity sha512-OEdHeNFb7BM+byb6JrpLF9/na2oCpxNbC6n+zQHcM/CV/y2OBniz9JDngckJG3esfnD6q9aCjEEt6LF9/LKZyw==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.1.1-canary.56.tgz"
integrity sha512-qWVDIia8BJ8209XUVw4QNPi4mup2OwRZVLlrD1WZwAmDGy5p/gwFqGCvQ5BeiCUl8Et9xWsVwou1/n5mobj0Dw==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.1.1-canary.56.tgz"
integrity sha512-e26LjHCGlg/X6iS5iqILGykgAFM+hLoNP1HTpsEXebn8iOaAJ4w2YEyk5+CGk4aImM9YwXGsquPWq/S+SwVMaQ==

"@next/[email protected].56":
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.1.1-canary.56.tgz"
integrity sha512-ylkY6s0wXjS8V7e7fFLtkT+VY0oLfZUDDdLPBL1hDxjh3m4H2kKB+Hq67fkRem7DoF3zn1pqCjbz4Gby/nXisg==

"@nodelib/[email protected]":
version "2.1.5"
Expand Down Expand Up @@ -266,10 +266,10 @@
dependencies:
bun-types "1.0.26"

"@types/node@*", "@types/node@^20.11.18", "@types/node@~20.11.3":
version "20.11.18"
resolved "https://registry.npmjs.org/@types/node/-/node-20.11.18.tgz"
integrity sha512-ABT5VWnnYneSBcNWYSCuR05M826RoMyMSGiFivXGx6ZUIsXb9vn4643IEwkg2zbEOSgAiSogtapN2fgc4mAPlw==
"@types/node@*", "@types/node@^20.11.19", "@types/node@~20.11.3":
version "20.11.19"
resolved "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz"
integrity sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -1038,27 +1038,27 @@ nanoid@^3.3.6, nanoid@^3.3.7:
integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==

next@canary:
version "14.1.1-canary.55"
resolved "https://registry.npmjs.org/next/-/next-14.1.1-canary.55.tgz"
integrity sha512-FeZM5/eq+tEYzsuB36KM1gFxk/OgarUSxESHRAi3qQx4SGbHb52ADwpxwItFAQ+xZn/b18BUFsJNFw/Ym3ZcoQ==
version "14.1.1-canary.56"
resolved "https://registry.npmjs.org/next/-/next-14.1.1-canary.56.tgz"
integrity sha512-/rqfqDzofP3xoOlGsRZXSc9eDBRn+f6UTIrJepappiFIJ2Bk54xVgQV+0HWG7szQoYt1tf+ZYCK1+h46/y5/oA==
dependencies:
"@next/env" "14.1.1-canary.55"
"@next/env" "14.1.1-canary.56"
"@swc/helpers" "0.5.5"
busboy "1.6.0"
caniuse-lite "^1.0.30001579"
graceful-fs "^4.2.11"
postcss "8.4.31"
styled-jsx "5.1.1"
optionalDependencies:
"@next/swc-darwin-arm64" "14.1.1-canary.55"
"@next/swc-darwin-x64" "14.1.1-canary.55"
"@next/swc-linux-arm64-gnu" "14.1.1-canary.55"
"@next/swc-linux-arm64-musl" "14.1.1-canary.55"
"@next/swc-linux-x64-gnu" "14.1.1-canary.55"
"@next/swc-linux-x64-musl" "14.1.1-canary.55"
"@next/swc-win32-arm64-msvc" "14.1.1-canary.55"
"@next/swc-win32-ia32-msvc" "14.1.1-canary.55"
"@next/swc-win32-x64-msvc" "14.1.1-canary.55"
"@next/swc-darwin-arm64" "14.1.1-canary.56"
"@next/swc-darwin-x64" "14.1.1-canary.56"
"@next/swc-linux-arm64-gnu" "14.1.1-canary.56"
"@next/swc-linux-arm64-musl" "14.1.1-canary.56"
"@next/swc-linux-x64-gnu" "14.1.1-canary.56"
"@next/swc-linux-x64-musl" "14.1.1-canary.56"
"@next/swc-win32-arm64-msvc" "14.1.1-canary.56"
"@next/swc-win32-ia32-msvc" "14.1.1-canary.56"
"@next/swc-win32-x64-msvc" "14.1.1-canary.56"

normalize-path@^3.0.0, normalize-path@~3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -1217,20 +1217,20 @@ queue-microtask@^1.2.2:
resolved "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==

"[email protected]f0e808e5b-20240214", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", react@^18.0.0, react@^18.2.0, react@canary:
version "18.3.0-canary-f0e808e5b-20240214"
resolved "https://registry.npmjs.org/react/-/react-18.3.0-canary-f0e808e5b-20240214.tgz"
integrity sha512-LE0h6oDDPUCsl9CXmDyembvCNQTKKQ28HbQku4F7pYW/Pa8DST/YaMOAQSBzNUAS+6eNaoEgSkypQ68ho1iqHw==
"[email protected]2e470a788-20240214", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", react@^18.0.0, react@^18.2.0, react@canary:
version "18.3.0-canary-2e470a788-20240214"
resolved "https://registry.npmjs.org/react/-/react-18.3.0-canary-2e470a788-20240214.tgz"
integrity sha512-yAKIu2SdFpKjw21QaLzT6hDLCHBBKbSq/28yLraOAUR/y5jXxu6u5CzKU5lRIIy2ZAB7MnO8gjHRH39ssnOkJw==
dependencies:
loose-envify "^1.1.0"

react-dom@^18.0.0, react-dom@^18.2.0, react-dom@canary:
version "18.3.0-canary-f0e808e5b-20240214"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.3.0-canary-f0e808e5b-20240214.tgz"
integrity sha512-6oUH75HV23vOblZ49a8Q9hLeaRwjNnwRJWt11oYARwFTmUCuw+Kp/B+jpR5ZCJUPAfBVqpNo/VA4NwVb3VNkkA==
version "18.3.0-canary-2e470a788-20240214"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-18.3.0-canary-2e470a788-20240214.tgz"
integrity sha512-NC6NkyJxgF45vRqqPthcIl3ZPgc6jKH3bzyVG99pWV6DL9RM+y81qaRXm3PK0K96BdwKB+HkIkzKlZe8LYNSFQ==
dependencies:
loose-envify "^1.1.0"
scheduler "0.24.0-canary-f0e808e5b-20240214"
scheduler "0.24.0-canary-2e470a788-20240214"

react-is@^17.0.1:
version "17.0.2"
Expand Down Expand Up @@ -1287,10 +1287,10 @@ run-parallel@^1.1.9:
dependencies:
queue-microtask "^1.2.2"

"[email protected]f0e808e5b-20240214":
version "0.24.0-canary-f0e808e5b-20240214"
resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.24.0-canary-f0e808e5b-20240214.tgz"
integrity sha512-atwW6jzZNABeMiSZqarJDu/Tq5df/ewah//OfAEoddqYzoWZx95PPrDyDvbNjDuDlDLcNBFxcXGvs9l472mE0w==
"[email protected]2e470a788-20240214":
version "0.24.0-canary-2e470a788-20240214"
resolved "https://registry.npmjs.org/scheduler/-/scheduler-0.24.0-canary-2e470a788-20240214.tgz"
integrity sha512-9KARZ5unFpeX2YVL8kWQz4E/HqghewAoI2yhXITKpIVNyM8ZbeIklaUcQpFuVJ39T3M5pOGhMl3Mp9YNXWOsXA==
dependencies:
loose-envify "^1.1.0"

Expand Down
Loading