diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dbf64f6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +/node_modules +/.pnp +.pnp.js +/.next/ +/out/ +/build +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.vercel +next-env.d.ts +.idea +*.iml +.env* +#!.env +!.env.production.local +/.vscode/ + diff --git a/.gitignore b/.gitignore index 3bbdacf..d19e054 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,5 @@ next-env.d.ts *.iml package-lock.json /log.txt -.env +.env* /.vscode/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cef90a9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM node:18-alpine as base +FROM base AS builder + +WORKDIR /app + +# 复制 package.json 和 yarn.lock 以利用 Docker 缓存 +COPY package.json yarn.lock ./ + +# 安装依赖 +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# 复制剩余的项目文件 +COPY . . +#COPY .env.production.local .env + +RUN yarn build + + +FROM base AS runner +WORKDIR /app + +COPY --from=builder /app/public ./public +#COPY --from=builder /app/package.json /app/yarn.lock ./ +#COPY --from=builder /app/.next ./.next +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +#COPY prisma ./prisma/ + +EXPOSE 9084 + +ENV NODE_ENV production +ENV PORT 9084 + +CMD ["node", "server.js"] diff --git a/README.md b/README.md index bd1deac..51cb9bb 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,8 @@ ADD CONSTRAINT unique_combination UNIQUE (book, chapter, verse); next build next start -p 3001 + + +.env.production.local 用于build +.env用于run +其实内容都一样 diff --git a/next.config.mjs b/next.config.mjs index a96d9dd..ec6401f 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -3,6 +3,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { // env: process.env + output: "standalone", webpack: (config, { dev }) => { if (dev) { config.watchOptions = { diff --git a/package.json b/package.json index 542c1b9..7c29fcc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@prisma/client": "^5.10.2", - "@vercel/postgres": "^0.7.2", + "@types/pg": "^8.11.6", "dotenv": "^16.4.4", "dotenv-cli": "^7.3.0", "next": "14.1.0", diff --git a/scripts/import_db.ts b/scripts/import_db.ts index cadc064..f372bd2 100644 --- a/scripts/import_db.ts +++ b/scripts/import_db.ts @@ -6,7 +6,6 @@ import dotenv from "dotenv"; import {Bible} from "@/app/bible/data"; import {getJapaneseFurigana} from "@/app/utils/service"; -import {Client} from "pg"; import {Prisma, PrismaClient} from "@prisma/client"; @@ -101,10 +100,10 @@ async function split_multi(book: string, chapter: number, multi_words: string) { (async () => { let book = ` - エフェソの信徒への手紙 6 + マルコによる福音書 14 `.trim() let multi_words = ` - 10最後に言う。主に依り頼み、その偉大な力によって強くなりなさい。 11悪魔の策略に対抗して立つことができるように、神の武具を身に着けなさい。 12わたしたちの戦いは、血肉を相手にするものではなく、支配と権威、暗闇の世界の支配者、天にいる悪の諸霊を相手にするものなのです。 13だから、邪悪な日によく抵抗し、すべてを成し遂げて、しっかりと立つことができるように、神の武具を身に着けなさい。 14立って、真理を帯として腰に締め、正義を胸当てとして着け、 15平和の福音を告げる準備を履物としなさい。 16なおその上に、信仰を盾として取りなさい。それによって、悪い者の放つ火の矢をことごとく消すことができるのです。 17また、救いを兜としてかぶり、霊の剣、すなわち神の言葉を取りなさい。 18どのような時にも、“霊”に助けられて祈り、願い求め、すべての聖なる者たちのために、絶えず目を覚まして根気よく祈り続けなさい。 + 38誘惑に陥らぬよう、目を覚まして祈っていなさい。心は燃えても、肉体は弱い。」 ` let chapter = parseInt(book.split(' ')[1]) book = book.split(' ')[0] diff --git a/src/app/api/bible/[book]/[chapter]/route.ts b/src/app/api/bible/[book]/[chapter]/route.ts index 0c998a0..e134476 100644 --- a/src/app/api/bible/[book]/[chapter]/route.ts +++ b/src/app/api/bible/[book]/[chapter]/route.ts @@ -1,7 +1,3 @@ -// no-config -import { sql } from '@vercel/postgres'; - -import { createPool } from '@vercel/postgres'; import { NextResponse } from "next/server"; export const dynamic = 'force-dynamic' diff --git a/src/app/api/test/route.ts b/src/app/api/test/route.ts index d130df5..176a58f 100644 --- a/src/app/api/test/route.ts +++ b/src/app/api/test/route.ts @@ -1,8 +1,6 @@ // no-config -import { sql } from '@vercel/postgres'; - -import { createPool } from '@vercel/postgres'; import {NextResponse} from "next/server"; +import {sql} from "@/app/utils/db"; export const dynamic = 'force-dynamic' // async function getServerSideProps() { // const result = await db.query.documents.findFirst(); diff --git a/src/pages/api/bible1.ts b/src/pages/api/bible1.ts index 2dea1c5..cc987b8 100644 --- a/src/pages/api/bible1.ts +++ b/src/pages/api/bible1.ts @@ -1,7 +1,4 @@ // no-config -import { sql } from '@vercel/postgres'; - -import { createPool } from '@vercel/postgres'; import {NextResponse} from "next/server"; import {getServerSideProps} from "next/dist/build/templates/pages"; import {NextApiResponse} from "next"; diff --git a/yarn.lock b/yarn.lock index e51782d..616679b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,13 +66,6 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@neondatabase/serverless@0.7.2": - version "0.7.2" - resolved "https://registry.npmjs.org/@neondatabase/serverless/-/serverless-0.7.2.tgz" - integrity sha512-wU3WA2uTyNO7wjPs3Mg0G01jztAxUxzd9/mskMmtPwPTjf7JKWi9AW5/puOGXLxmZ9PVgRFeBVRVYq5nBPhsCg== - dependencies: - "@types/pg" "8.6.6" - "@next/env@14.1.0": version "14.1.0" resolved "https://registry.npmjs.org/@next/env/-/env-14.1.0.tgz" @@ -296,21 +289,28 @@ resolved "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz" integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== -"@types/node@*", "@types/node@^20": +"@types/node@*": + version "22.3.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.3.0.tgz#7f8da0e2b72c27c4f9bd3cb5ef805209d04d4f9e" + integrity sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g== + dependencies: + undici-types "~6.18.2" + +"@types/node@^20": version "20.11.18" resolved "https://registry.npmjs.org/@types/node/-/node-20.11.18.tgz" integrity sha512-ABT5VWnnYneSBcNWYSCuR05M826RoMyMSGiFivXGx6ZUIsXb9vn4643IEwkg2zbEOSgAiSogtapN2fgc4mAPlw== dependencies: undici-types "~5.26.4" -"@types/pg@8.6.6": - version "8.6.6" - resolved "https://registry.npmjs.org/@types/pg/-/pg-8.6.6.tgz" - integrity sha512-O2xNmXebtwVekJDD+02udOncjVcMZQuTEQEMpKJ0ZRf5E7/9JJX3izhKUcUifBkyKpljyUM6BTgy2trmviKlpw== +"@types/pg@^8.11.6": + version "8.11.6" + resolved "https://registry.yarnpkg.com/@types/pg/-/pg-8.11.6.tgz#a2d0fb0a14b53951a17df5197401569fb9c0c54b" + integrity sha512-/2WmmBXHLsfRqzfHW7BNZ8SbYzE8OSk7i3WjFYvfgRHj7S1xj+16Je5fUKv3lVdVzk/zn9TXOqf+avFCFIE0yQ== dependencies: "@types/node" "*" pg-protocol "*" - pg-types "^2.2.0" + pg-types "^4.0.1" "@types/prop-types@*": version "15.7.11" @@ -338,16 +338,6 @@ resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz" integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A== -"@vercel/postgres@^0.7.2": - version "0.7.2" - resolved "https://registry.npmjs.org/@vercel/postgres/-/postgres-0.7.2.tgz" - integrity sha512-IqR/ZAvoPGcPaXl9eWWB5KaA+w/81RzZa/18P4izQRHpNBkTGt9HwGfYi9+wut5UgxNq4QSX9A7HIQR6QDvX2Q== - dependencies: - "@neondatabase/serverless" "0.7.2" - bufferutil "4.0.8" - utf-8-validate "6.0.3" - ws "8.14.2" - acorn-walk@^8.1.1: version "8.3.2" resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz" @@ -454,13 +444,6 @@ buffer-writer@2.0.0: resolved "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz" integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw== -bufferutil@4.0.8: - version "4.0.8" - resolved "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz" - integrity sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw== - dependencies: - node-gyp-build "^4.3.0" - busboy@1.6.0: version "1.6.0" resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz" @@ -848,11 +831,6 @@ next@14.1.0: "@next/swc-win32-ia32-msvc" "14.1.0" "@next/swc-win32-x64-msvc" "14.1.0" -node-gyp-build@^4.3.0: - version "4.8.0" - resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz" - integrity sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og== - node-releases@^2.0.14: version "2.0.14" resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz" @@ -878,6 +856,11 @@ object-hash@^3.0.0: resolved "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz" integrity sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw== +obuf@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" + integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== + packet-reader@1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz" @@ -916,17 +899,27 @@ pg-int8@1.0.1: resolved "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz" integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw== +pg-numeric@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pg-numeric/-/pg-numeric-1.0.2.tgz#816d9a44026086ae8ae74839acd6a09b0636aa3a" + integrity sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw== + pg-pool@^3.6.1: version "3.6.1" resolved "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.1.tgz" integrity sha512-jizsIzhkIitxCGfPRzJn1ZdcosIt3pz9Sh3V01fm1vZnbnCMgmGl5wvGGdNN2EL9Rmb0EcFoCkixH4Pu+sP9Og== -pg-protocol@*, pg-protocol@^1.6.0: +pg-protocol@*: + version "1.6.1" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.1.tgz#21333e6d83b01faaebfe7a33a7ad6bfd9ed38cb3" + integrity sha512-jPIlvgoD63hrEuihvIg+tJhoGjUsLPn6poJY9N5CnlPd91c2T18T/9zBtLxZSb1EhYxBRoZJtzScCaWlYLtktg== + +pg-protocol@^1.6.0: version "1.6.0" resolved "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz" integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== -pg-types@^2.1.0, pg-types@^2.2.0: +pg-types@^2.1.0: version "2.2.0" resolved "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz" integrity sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA== @@ -937,6 +930,19 @@ pg-types@^2.1.0, pg-types@^2.2.0: postgres-date "~1.0.4" postgres-interval "^1.1.0" +pg-types@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-4.0.2.tgz#399209a57c326f162461faa870145bb0f918b76d" + integrity sha512-cRL3JpS3lKMGsKaWndugWQoLOCoP+Cic8oseVcbr0qhPzYD5DWXK+RZ9LY9wxRf7RQia4SCwQlXk0q6FCPrVng== + dependencies: + pg-int8 "1.0.1" + pg-numeric "1.0.2" + postgres-array "~3.0.1" + postgres-bytea "~3.0.0" + postgres-date "~2.1.0" + postgres-interval "^3.0.0" + postgres-range "^1.1.1" + pg@^8.11.3: version "8.11.3" resolved "https://registry.npmjs.org/pg/-/pg-8.11.3.tgz" @@ -1046,16 +1052,33 @@ postgres-array@~2.0.0: resolved "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz" integrity sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA== +postgres-array@~3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-3.0.2.tgz#68d6182cb0f7f152a7e60dc6a6889ed74b0a5f98" + integrity sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog== + postgres-bytea@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz" integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w== +postgres-bytea@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-3.0.0.tgz#9048dc461ac7ba70a6a42d109221619ecd1cb089" + integrity sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw== + dependencies: + obuf "~1.1.2" + postgres-date@~1.0.4: version "1.0.7" resolved "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz" integrity sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q== +postgres-date@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-2.1.0.tgz#b85d3c1fb6fb3c6c8db1e9942a13a3bf625189d0" + integrity sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA== + postgres-interval@^1.1.0: version "1.2.0" resolved "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz" @@ -1063,6 +1086,16 @@ postgres-interval@^1.1.0: dependencies: xtend "^4.0.0" +postgres-interval@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-3.0.0.tgz#baf7a8b3ebab19b7f38f07566c7aab0962f0c86a" + integrity sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw== + +postgres-range@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/postgres-range/-/postgres-range-1.1.4.tgz#a59c5f9520909bcec5e63e8cf913a92e4c952863" + integrity sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w== + prisma@^5.10.2: version "5.10.2" resolved "https://registry.npmjs.org/prisma/-/prisma-5.10.2.tgz" @@ -1325,6 +1358,11 @@ undici-types@~5.26.4: resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== +undici-types@~6.18.2: + version "6.18.2" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.18.2.tgz#8b678cf939d4fc9ec56be3c68ed69c619dee28b0" + integrity sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ== + update-browserslist-db@^1.0.13: version "1.0.13" resolved "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz" @@ -1338,13 +1376,6 @@ use-sync-external-store@1.2.0: resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== -utf-8-validate@6.0.3: - version "6.0.3" - resolved "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-6.0.3.tgz" - integrity sha512-uIuGf9TWQ/y+0Lp+KGZCMuJWc3N9BHA+l/UmHd/oUHwJJDeysyTRxNQVkbzsIWfGFbRe3OcgML/i0mvVRPOyDA== - dependencies: - node-gyp-build "^4.3.0" - util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" @@ -1380,11 +1411,6 @@ wrap-ansi@^8.1.0: string-width "^5.0.1" strip-ansi "^7.0.1" -ws@8.14.2: - version "8.14.2" - resolved "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz" - integrity sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g== - xtend@^4.0.0: version "4.0.2" resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz"