增加打包功能
This commit is contained in:
@@ -1,10 +0,0 @@
|
|||||||
node_modules
|
|
||||||
.next
|
|
||||||
.git
|
|
||||||
.env.local
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
.DS_Store
|
|
||||||
dist
|
|
||||||
coverage
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
FROM node:20-alpine AS runner
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
ENV NODE_ENV production
|
|
||||||
ENV PORT 3000
|
|
||||||
|
|
||||||
# Install OpenSSL for compatibility
|
|
||||||
RUN apk add --no-cache openssl
|
|
||||||
|
|
||||||
# Copy necessary files
|
|
||||||
# Standalone build already includes node_modules
|
|
||||||
COPY .next/standalone ./
|
|
||||||
COPY .next/static ./.next/static
|
|
||||||
COPY public ./public
|
|
||||||
|
|
||||||
# Copy prisma for database migrations
|
|
||||||
COPY prisma ./prisma
|
|
||||||
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
# Run migrations and then start the server
|
|
||||||
CMD ["sh", "-c", "npx prisma db push && node server.js"]
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
services:
|
|
||||||
noteai:
|
|
||||||
image: noteai
|
|
||||||
build: .
|
|
||||||
container_name: noteai
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "4500:3000"
|
|
||||||
volumes:
|
|
||||||
# Persist the database file
|
|
||||||
- ./prisma/dev.db:/app/prisma/dev.db
|
|
||||||
environment:
|
|
||||||
- DATABASE_URL=file:./prisma/dev.db
|
|
||||||
- TZ=Asia/Shanghai
|
|
||||||
@@ -2,7 +2,6 @@ import type { NextConfig } from "next";
|
|||||||
import packageJson from "./package.json";
|
import packageJson from "./package.json";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
|
||||||
env: {
|
env: {
|
||||||
NEXT_PUBLIC_APP_VERSION: packageJson.version,
|
NEXT_PUBLIC_APP_VERSION: packageJson.version,
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3001",
|
"dev": "next dev -p 3001",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"env:init": "node scripts/init-env.mjs",
|
||||||
|
"build:init": "npm run env:init && npm run build",
|
||||||
|
"start": "next start -p 3001",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"test": "node --no-warnings --experimental-strip-types scripts/run-editor-block-ops-tests.mjs",
|
"test": "node --no-warnings --experimental-strip-types scripts/run-editor-block-ops-tests.mjs",
|
||||||
"check": "npm run lint -- --max-warnings=0 && npx tsc --noEmit"
|
"check": "npm run lint -- --max-warnings=0 && npx tsc --noEmit"
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,57 @@
|
|||||||
|
import { randomBytes } from "node:crypto";
|
||||||
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
|
import { resolve } from "node:path";
|
||||||
|
|
||||||
|
const envPath = resolve(process.cwd(), ".env");
|
||||||
|
const envExists = existsSync(envPath);
|
||||||
|
const original = envExists ? readFileSync(envPath, "utf8") : "";
|
||||||
|
const lines = original ? original.split(/\r?\n/) : [];
|
||||||
|
|
||||||
|
const parsed = new Map();
|
||||||
|
for (const line of lines) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
||||||
|
const match = trimmed.match(/^([A-Z0-9_]+)\s*=\s*(.*)$/);
|
||||||
|
if (!match) continue;
|
||||||
|
parsed.set(match[1], match[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const required = [
|
||||||
|
{
|
||||||
|
key: "DATABASE_URL",
|
||||||
|
value: '"file:./dev.db"',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "SESSION_SECRET",
|
||||||
|
value: `"${randomBytes(32).toString("hex")}"`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "INIT_SETUP_TOKEN",
|
||||||
|
value: `"${randomBytes(24).toString("hex")}"`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "INIT_DEFAULT_PASSWORD",
|
||||||
|
value: `"${randomBytes(9).toString("base64url")}"`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const added = [];
|
||||||
|
for (const item of required) {
|
||||||
|
if (!parsed.has(item.key)) {
|
||||||
|
lines.push(`${item.key}=${item.value}`);
|
||||||
|
added.push(item.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!envExists && lines.length === 0) {
|
||||||
|
lines.push("# Generated by scripts/init-env.mjs");
|
||||||
|
}
|
||||||
|
|
||||||
|
const next = `${lines.filter((line, index, arr) => !(line === "" && index === arr.length - 1)).join("\n")}\n`;
|
||||||
|
writeFileSync(envPath, next, "utf8");
|
||||||
|
|
||||||
|
if (added.length === 0) {
|
||||||
|
console.log("init-env: no missing keys, .env unchanged");
|
||||||
|
} else {
|
||||||
|
console.log(`init-env: added ${added.join(", ")}`);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user