generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
概要
DSQL + Drizzle移行(#94)により prisma generate が不要になり、ネイティブバイナリへの依存がなくなる。async-jobとmigration-runnerを DockerImageFunction から NodejsFunction に変更することで、ビルド時間の短縮とデプロイパッケージの軽量化が実現できる。
webappはNext.js standalone + Lambda Web Adapterの構成上 DockerImageFunction を維持する。starter-kitとして DockerImageFunction と NodejsFunction の両パターンを示すことで、ユーザーが用途に応じて使い分ける参考になる。
現状
現在、async-jobとmigration-runnerは job.Dockerfile を使用している。Prismaのネイティブバイナリ生成(prisma generate)のためにDockerマルチステージビルドが必要:
# job.Dockerfile(現在)
FROM public.ecr.aws/lambda/nodejs:22 AS builder
WORKDIR /build
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY ./ ./
RUN npx prisma generate
RUN npx esbuild src/jobs/*.ts --bundle --outdir=dist --platform=node --charset=utf8 --external:@prisma/client
FROM public.ecr.aws/lambda/nodejs:22 AS runner
COPY package*.json ./
COPY prisma ./prisma
RUN --mount=type=cache,target=/root/.npm npm ci --omit=dev
RUN npx prisma generate --generator client
COPY --from=builder /build/dist/. ./変更内容
async-job、migration-runner → NodejsFunction
Drizzle移行後はPrisma依存がなくなるため、NodejsFunction の bundling オプション(esbuild)で十分にバンドルできる。
// 変更後のイメージ
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
const handler = new NodejsFunction(this, "Handler", {
entry: join("..", "apps", "async-job", "src", "index.ts"),
handler: "handler",
runtime: Runtime.NODEJS_22_X,
architecture: Architecture.ARM_64,
bundling: {
format: OutputFormat.ESM,
},
// ...その他のプロパティは既存と同様
});job.Dockerfile の削除
async-jobとmigration-runnerが NodejsFunction 化すれば job.Dockerfile は不要になる。
webapp は変更なし
Next.js standalone + Lambda Web Adapterの構成は DockerImageFunction を維持する。
検証方法
- async-job、migration-runnerが
NodejsFunctionとしてデプロイ・実行できること - ビルド時間が
DockerImageFunction比で短縮されること
依存関係
- DSQL + Drizzle移行が前提(Prisma依存の除去が必要)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request