diff --git a/CHANGELOG.md b/CHANGELOG.md index d871ca16..75a5a62f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ 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.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) diff --git a/package.json b/package.json index f7fb898b..548674ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.6.3", + "version": "1.6.4", "private": true, "prisma": { "seed": "bun prisma/seed.ts" diff --git a/scripts/postbuild.js b/scripts/postbuild.js index adb56ed0..41b26d28 100644 --- a/scripts/postbuild.js +++ b/scripts/postbuild.js @@ -38,4 +38,27 @@ if (fs.existsSync(prismaClientSrc)) { 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'); diff --git a/src/lib/prisma.ts b/src/lib/prisma.ts index ac62c007..47db3c82 100644 --- a/src/lib/prisma.ts +++ b/src/lib/prisma.ts @@ -8,6 +8,24 @@ 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