Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
SuCicada committed Aug 16, 2024
1 parent 500c91a commit 7f87bde
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 64 deletions.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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/

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ next-env.d.ts
*.iml
package-lock.json
/log.txt
.env
.env*
/.vscode/
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ ADD CONSTRAINT unique_combination UNIQUE (book, chapter, verse);

next build
next start -p 3001


.env.production.local 用于build
.env用于run
其实内容都一样
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
// env: process.env
output: "standalone",
webpack: (config, { dev }) => {
if (dev) {
config.watchOptions = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions scripts/import_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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]
Expand Down
4 changes: 0 additions & 4 deletions src/app/api/bible/[book]/[chapter]/route.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 1 addition & 3 deletions src/app/api/test/route.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
3 changes: 0 additions & 3 deletions src/pages/api/bible1.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
124 changes: 75 additions & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@neondatabase/[email protected]":
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/[email protected]":
version "14.1.0"
resolved "https://registry.npmjs.org/@next/env/-/env-14.1.0.tgz"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -454,13 +444,6 @@ [email protected]:
resolved "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz"
integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==

[email protected]:
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"

[email protected]:
version "1.6.0"
resolved "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz"
Expand Down Expand Up @@ -848,11 +831,6 @@ [email protected]:
"@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"
Expand All @@ -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==

[email protected]:
version "1.0.0"
resolved "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz"
Expand Down Expand Up @@ -916,17 +899,27 @@ [email protected]:
resolved "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz"
integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==

[email protected]:
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==
Expand All @@ -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"
Expand Down Expand Up @@ -1046,23 +1052,50 @@ 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"
integrity sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==
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"
Expand Down Expand Up @@ -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"
Expand All @@ -1338,13 +1376,6 @@ [email protected]:
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==

[email protected]:
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"
Expand Down Expand Up @@ -1380,11 +1411,6 @@ wrap-ansi@^8.1.0:
string-width "^5.0.1"
strip-ansi "^7.0.1"

[email protected]:
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"
Expand Down

0 comments on commit 7f87bde

Please sign in to comment.