diff --git a/Dockerfile b/Dockerfile index e07b5c6..be95449 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine +FROM node:20-alpine AS builder WORKDIR /usr/src/app @@ -14,6 +14,18 @@ RUN npm ci --prefix server COPY . . ARG VERSION +ENV NEXT_PUBLIC_COGNITO_POOL_ENDPOINT=http://localhost:5000 +ENV NEXT_PUBLIC_COGNITO_POOL_ID=ap-northeast-1_randomPoolId +ENV NEXT_PUBLIC_COGNITO_CLIENT_ID=random-client-id +ENV DATABASE_URL=file:../../data/app.db + +RUN npm run batch:writeVersion -- $VERSION +RUN npm run build + +FROM node:20-alpine + +WORKDIR /usr/src/app + ENV NEXT_PUBLIC_COGNITO_POOL_ENDPOINT=http://localhost:5000 ENV NEXT_PUBLIC_COGNITO_POOL_ID=ap-northeast-1_randomPoolId ENV NEXT_PUBLIC_COGNITO_CLIENT_ID=random-client-id @@ -26,9 +38,20 @@ ENV SMTP_PORT=2500 ENV SMTP_USER=fake_mail_user ENV SMTP_PASS=fake_mail_password -RUN npm run batch:writeVersion -- $VERSION -RUN npm run build +COPY --from=builder /usr/src/app/client/.next ./client/.next +COPY client/package.json client/package-lock.json ./client/ +RUN npm ci --omit=dev --prefix client + +COPY server/package.json server/package-lock.json ./server/ +RUN npm ci --omit=dev --prefix server + +COPY --from=builder /usr/src/app/server/index.js ./server/index.js +COPY --from=builder /usr/src/app/server/node_modules/.prisma ./server/node_modules/.prisma +COPY --from=builder /usr/src/app/server/prisma ./server/prisma +COPY package.json . +RUN npm install -g npm-run-all RUN apk --no-cache add curl +COPY --from=builder /usr/src/app/data ./data HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f $API_ORIGIN/health && curl -f $CORS_ORIGIN || exit 1 diff --git a/client/package-lock.json b/client/package-lock.json index c52988d..8d6643d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -15,7 +15,8 @@ "jotai": "^2.8.0", "next": "^14.2.3", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "zod": "^3.23.8" }, "devDependencies": { "@types/react": "^18.3.1", @@ -23,8 +24,7 @@ "dotenv": "^16.4.5", "happy-css-modules": "^2.1.2", "notios": "^0.4.1", - "pathpida": "^0.22.0", - "zod": "^3.23.6" + "pathpida": "^0.22.0" }, "engines": { "node": ">=20.0.0" @@ -7717,10 +7717,9 @@ } }, "node_modules/zod": { - "version": "3.23.6", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.6.tgz", - "integrity": "sha512-RTHJlZhsRbuA8Hmp/iNL7jnfc4nZishjsanDAfEY1QpDQZCahUp3xDzl+zfweE9BklxMUcgBgS1b7Lvie/ZVwA==", - "dev": true, + "version": "3.23.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/client/package.json b/client/package.json index 7d42faa..c7aadd1 100644 --- a/client/package.json +++ b/client/package.json @@ -31,7 +31,8 @@ "jotai": "^2.8.0", "next": "^14.2.3", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "zod": "^3.23.8" }, "devDependencies": { "@types/react": "^18.3.1", @@ -39,8 +40,7 @@ "dotenv": "^16.4.5", "happy-css-modules": "^2.1.2", "notios": "^0.4.1", - "pathpida": "^0.22.0", - "zod": "^3.23.6" + "pathpida": "^0.22.0" }, "engines": { "node": ">=20.0.0" diff --git a/server/service/sendMail.ts b/server/service/sendMail.ts index cfb6ce2..1887ad5 100644 --- a/server/service/sendMail.ts +++ b/server/service/sendMail.ts @@ -1,6 +1,5 @@ import { APP_NAME } from 'api/@constants'; import assert from 'assert'; -import { InbucketAPIClient } from 'inbucket-js-client'; import { createTransport } from 'nodemailer'; import type Mail from 'nodemailer/lib/mailer'; import { ulid } from 'ulid'; @@ -30,10 +29,11 @@ export const sendMail = async (options: { if (import.meta.vitest) { const { test, expect } = import.meta.vitest; - assert(process.env.INBUCKET_URL); - const inbucketClient = new InbucketAPIClient(process.env.INBUCKET_URL); - test('sendMail', async () => { + assert(process.env.INBUCKET_URL); + + const { InbucketAPIClient } = await import('inbucket-js-client'); + const inbucketClient = new InbucketAPIClient(process.env.INBUCKET_URL); const toAddress = `${ulid()}@example.com`; const text = 'aaa';