Add complete Docker configuration for containerized deployment: - Multi-stage Dockerfile using official Bun runtime - docker-compose.yml for single-port stack orchestration - Host-mounted database volume with auto-initialization - Custom database init script using bun:sqlite - Entrypoint script for seamless database setup - Environment configuration template - Comprehensive DOCKER.md documentation Key features: - Single exposed port (3001) serving both API and frontend - Database persists in ./data directory on host - Auto-creates database from template on first startup - Health checks for monitoring - Architecture-agnostic (works on x86 and ARM64) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
34 lines
803 B
JavaScript
34 lines
803 B
JavaScript
#!/usr/bin/env bun
|
|
/**
|
|
* Database initialization script
|
|
* Creates the database schema using Drizzle ORM
|
|
*/
|
|
|
|
import Database from 'bun:sqlite';
|
|
import { drizzle } from 'drizzle-orm/bun-sqlite';
|
|
import { migrate } from 'drizzle-orm/bun-sqlite/migrator';
|
|
import * as schema from '../db/schema/index.js';
|
|
import { join } from 'path';
|
|
|
|
const dbPath = join(process.cwd(), 'src/backend/award.db');
|
|
|
|
console.log('Creating database at:', dbPath);
|
|
|
|
// Create SQLite database
|
|
const sqlite = new Database(dbPath);
|
|
sqlite.exec('PRAGMA foreign_keys = ON');
|
|
|
|
const db = drizzle({
|
|
client: sqlite,
|
|
schema,
|
|
});
|
|
|
|
console.log('Running migrations...');
|
|
|
|
// Run migrations
|
|
await migrate(db, { migrationsFolder: join(process.cwd(), 'drizzle') });
|
|
|
|
console.log('✅ Database initialized successfully');
|
|
|
|
sqlite.close();
|