首次发布git
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
# Deploy Script
|
||||
param (
|
||||
# automatically determine root relative to this script (scripts/ folder)
|
||||
[string]$ProjectRoot = (Resolve-Path "$PSScriptRoot/..").Path
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$DockerAppDir = Join-Path $ProjectRoot "dockerapp"
|
||||
$NextDir = Join-Path $ProjectRoot ".next"
|
||||
$PublicDir = Join-Path $ProjectRoot "public"
|
||||
$PrismaDir = Join-Path $ProjectRoot "prisma"
|
||||
|
||||
Write-Host "📦 Starting Dockerapp Packaging..." -ForegroundColor Cyan
|
||||
Write-Host " Project Root: $ProjectRoot"
|
||||
|
||||
# 1. Clean dockerapp (Keep Dockerfile & docker-compose.yml)
|
||||
Write-Host " Cleaning previous build artifacts..."
|
||||
Get-ChildItem -Path $DockerAppDir -Exclude Dockerfile, docker-compose.yml | Remove-Item -Recurse -Force
|
||||
|
||||
# 2. Copy Standalone (Exclude node_modules because Dockerfile reinstalls them)
|
||||
Write-Host " Copying Standalone build (skipping node_modules)..."
|
||||
if (!(Test-Path "$NextDir/standalone")) {
|
||||
Write-Error "❌ .next/standalone not found! Run 'npm run build' first."
|
||||
}
|
||||
# Copy everything inside standalone EXCEPT node_modules
|
||||
Get-ChildItem -Path "$NextDir/standalone" -Exclude "node_modules" | Copy-Item -Destination $DockerAppDir -Recurse -Force
|
||||
|
||||
# 3. Copy Static Assets (Crucial!)
|
||||
Write-Host " Copying Static assets..."
|
||||
$DestStatic = Join-Path $DockerAppDir ".next/static"
|
||||
New-Item -ItemType Directory -Path $DestStatic -Force | Out-Null
|
||||
Copy-Item -Path "$NextDir/static/*" -Destination $DestStatic -Recurse -Force
|
||||
|
||||
# 4. Copy Public Assets
|
||||
Write-Host " Copying Public folder..."
|
||||
Copy-Item -Path $PublicDir -Destination $DockerAppDir -Recurse -Force
|
||||
|
||||
# 5. Copy Prisma
|
||||
Write-Host " Copying Prisma..."
|
||||
Copy-Item -Path $PrismaDir -Destination $DockerAppDir -Recurse -Force
|
||||
|
||||
Write-Host "✅ Packaging Complete!" -ForegroundColor Green
|
||||
Write-Host " Location: $DockerAppDir"
|
||||
Write-Host " Next Step: Upload 'dockerapp' folder to server and run 'docker-compose up -d --build'"
|
||||
@@ -0,0 +1,33 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const { scrypt, randomBytes } = require('crypto');
|
||||
const { promisify } = require('util');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const scryptAsync = promisify(scrypt);
|
||||
|
||||
async function hashPassword(password) {
|
||||
const salt = randomBytes(16).toString("hex");
|
||||
const derivedKey = await scryptAsync(password, salt, 64);
|
||||
return `${salt}:${derivedKey.toString("hex")}`;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const count = await prisma.globalSettings.count();
|
||||
if (count === 0) {
|
||||
console.log("Initializing default settings...");
|
||||
const hashedPassword = await hashPassword("admin");
|
||||
await prisma.globalSettings.create({
|
||||
data: {
|
||||
id: "default",
|
||||
password: hashedPassword,
|
||||
},
|
||||
});
|
||||
console.log("Done.");
|
||||
} else {
|
||||
console.log("Settings already exist.");
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(e => console.error(e))
|
||||
.finally(async () => await prisma.$disconnect());
|
||||
@@ -0,0 +1,38 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const { scrypt, randomBytes } = require('crypto');
|
||||
const { promisify } = require('util');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const scryptAsync = promisify(scrypt);
|
||||
|
||||
async function hashPassword(password) {
|
||||
const salt = randomBytes(16).toString("hex");
|
||||
const derivedKey = await scryptAsync(password, salt, 64);
|
||||
return `${salt}:${derivedKey.toString("hex")}`;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("Resetting password to 'admin'...");
|
||||
const hashedPassword = await hashPassword("admin");
|
||||
const settings = await prisma.globalSettings.findFirst();
|
||||
|
||||
if (settings) {
|
||||
await prisma.globalSettings.update({
|
||||
where: { id: settings.id },
|
||||
data: { password: hashedPassword }
|
||||
});
|
||||
console.log("Password reset successfully.");
|
||||
} else {
|
||||
await prisma.globalSettings.create({
|
||||
data: {
|
||||
id: "default",
|
||||
password: hashedPassword,
|
||||
},
|
||||
});
|
||||
console.log("Settings created with default password.");
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch(e => console.error(e))
|
||||
.finally(async () => await prisma.$disconnect());
|
||||
Reference in New Issue
Block a user