Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df5d1aad48 | |||
| a6588818b5 | |||
| 58e1afaa45 | |||
| 250b7c5261 |
@@ -2,6 +2,15 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||
|
||||
## [1.6.5](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.4...v1.6.5) (2026-03-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* error koneksi Prisma - DATABASE_URL tidak loaded di ([a658881](https://wibugit.wibudev.com/wibu/hipmi/commit/a6588818b5d8018b3a634e0ae0846e309569d370))
|
||||
|
||||
## [1.6.4](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.3...v1.6.4) (2026-03-03)
|
||||
|
||||
## [1.6.3](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.2...v1.6.3) (2026-03-03)
|
||||
|
||||
## [1.6.2](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.6.1...v1.6.2) (2026-02-25)
|
||||
|
||||
@@ -3,12 +3,20 @@ const nextConfig = {
|
||||
reactStrictMode: false,
|
||||
experimental: {
|
||||
serverActions: true,
|
||||
serverComponentsExternalPackages: ['@prisma/client'],
|
||||
},
|
||||
output: "standalone",
|
||||
staticPageGenerationTimeout: 180, // tingkatkan menjadi 3 menit
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
webpack: (config, { isServer }) => {
|
||||
if (isServer) {
|
||||
config.externals = config.externals || [];
|
||||
config.externals.push('@prisma/client');
|
||||
}
|
||||
return config;
|
||||
},
|
||||
// async headers() {
|
||||
// return [
|
||||
// {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hipmi",
|
||||
"version": "1.6.3",
|
||||
"version": "1.6.5",
|
||||
"private": true,
|
||||
"prisma": {
|
||||
"seed": "bun prisma/seed.ts"
|
||||
|
||||
64
scripts/postbuild.js
Normal file
64
scripts/postbuild.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const standaloneDir = path.join(__dirname, '../.next/standalone');
|
||||
const prismaDir = path.join(__dirname, '../node_modules/.prisma');
|
||||
|
||||
console.log('🚀 Running postbuild script...');
|
||||
|
||||
// Copy Prisma binaries ke standalone output
|
||||
if (fs.existsSync(prismaDir)) {
|
||||
const dest = path.join(standaloneDir, 'node_modules/.prisma');
|
||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||
fs.cpSync(prismaDir, dest, { recursive: true });
|
||||
console.log('✓ Prisma binaries copied to standalone output');
|
||||
} else {
|
||||
console.warn('⚠ Prisma binaries directory not found, skipping...');
|
||||
}
|
||||
|
||||
// Copy schema.prisma jika diperlukan
|
||||
const schemaSrc = path.join(__dirname, '../prisma/schema.prisma');
|
||||
const schemaDest = path.join(standaloneDir, 'prisma/schema.prisma');
|
||||
if (fs.existsSync(schemaSrc)) {
|
||||
fs.mkdirSync(path.dirname(schemaDest), { recursive: true });
|
||||
fs.copyFileSync(schemaSrc, schemaDest);
|
||||
console.log('✓ schema.prisma copied to standalone output');
|
||||
} else {
|
||||
console.warn('⚠ schema.prisma not found, skipping...');
|
||||
}
|
||||
|
||||
// Copy prisma client dari node_modules/@prisma/client
|
||||
const prismaClientSrc = path.join(__dirname, '../node_modules/@prisma/client');
|
||||
const prismaClientDest = path.join(standaloneDir, 'node_modules/@prisma/client');
|
||||
if (fs.existsSync(prismaClientSrc)) {
|
||||
fs.mkdirSync(path.dirname(prismaClientDest), { recursive: true });
|
||||
fs.cpSync(prismaClientSrc, prismaClientDest, { recursive: true });
|
||||
console.log('✓ @prisma/client copied to standalone output');
|
||||
} else {
|
||||
console.warn('⚠ @prisma/client not found, skipping...');
|
||||
}
|
||||
|
||||
// Copy .env file jika ada (untuk production)
|
||||
const envSrc = path.join(__dirname, '../.env');
|
||||
const envDest = path.join(standaloneDir, '.env');
|
||||
if (fs.existsSync(envSrc)) {
|
||||
fs.copyFileSync(envSrc, envDest);
|
||||
console.log('✓ .env file copied to standalone output');
|
||||
} else {
|
||||
console.warn('⚠ .env file not found, skipping...');
|
||||
console.warn(' Pastikan DATABASE_URL di-set di system environment server!');
|
||||
}
|
||||
|
||||
// Copy .env-local file jika ada (opsional)
|
||||
const envLocalSrc = path.join(__dirname, '../.env-local');
|
||||
const envLocalDest = path.join(standaloneDir, '.env-local');
|
||||
if (fs.existsSync(envLocalSrc)) {
|
||||
fs.copyFileSync(envLocalSrc, envLocalDest);
|
||||
console.log('✓ .env-local file copied to standalone output');
|
||||
}
|
||||
|
||||
console.log('✅ Postbuild script completed!');
|
||||
console.log('');
|
||||
console.log('📋 Penting untuk Production:');
|
||||
console.log(' - Pastikan DATABASE_URL tersedia di environment server, ATAU');
|
||||
console.log(' - File .env sudah ter-copy ke /app/.env di server');
|
||||
@@ -8,15 +8,43 @@ declare global {
|
||||
|
||||
let prisma: PrismaClient;
|
||||
|
||||
// Validasi DATABASE_URL sebelum inisialisasi
|
||||
if (!process.env.DATABASE_URL) {
|
||||
console.error('❌ ERROR: DATABASE_URL tidak ditemukan di environment variables!');
|
||||
console.error('');
|
||||
console.error('Current working directory:', process.cwd());
|
||||
console.error('Available environment variables:', Object.keys(process.env).sort().join(', '));
|
||||
console.error('');
|
||||
console.error('Solusi:');
|
||||
console.error(' 1. Pastikan file .env ada dan berisi DATABASE_URL, ATAU');
|
||||
console.error(' 2. Set DATABASE_URL di system environment:');
|
||||
console.error(' export DATABASE_URL="postgresql://user:pass@host:port/dbname"');
|
||||
console.error(' 3. Jika menggunakan systemd service, tambahkan di file service:');
|
||||
console.error(' [Service]');
|
||||
console.error(' Environment=DATABASE_URL=postgresql://...');
|
||||
console.error('');
|
||||
throw new Error('DATABASE_URL is required but not found in environment variables');
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
prisma = new PrismaClient({
|
||||
// Reduce logging in production to improve performance
|
||||
log: ['error', 'warn'],
|
||||
datasources: {
|
||||
db: {
|
||||
url: process.env.DATABASE_URL,
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
if (!global.prisma) {
|
||||
global.prisma = new PrismaClient({
|
||||
log: ['error', 'warn', 'info', 'query'], // More verbose logging in development
|
||||
datasources: {
|
||||
db: {
|
||||
url: process.env.DATABASE_URL,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
prisma = global.prisma;
|
||||
|
||||
Reference in New Issue
Block a user