File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import { BunSqliteDialect } from 'kysely-bun-worker/normal'
1010import type { Address } from 'viem'
1111
12+ import { isDocker } from '../docker'
1213import { migrator } from './migrator'
1314
1415interface ChainRow {
@@ -57,8 +58,9 @@ export type Tables = {
5758async function createDatabase ( ) {
5859 const db = new Kysely < Tables > ( {
5960 dialect : new BunSqliteDialect ( {
60- url : '/app/data/db.sqlite' ,
61+ url : isDocker ( ) ? '/app/data/db.sqlite' : ' db.sqlite',
6162 } ) ,
63+ plugins : [ new CamelCasePlugin ( ) ] ,
6264 } )
6365
6466 await sql `PRAGMA foreign_keys = ON` . execute ( db )
Original file line number Diff line number Diff line change 1+ import { readFileSync , statSync } from 'node:fs'
2+
3+ let isDockerCached : boolean
4+
5+ function hasDockerEnv ( ) {
6+ try {
7+ statSync ( '/.dockerenv' )
8+ return true
9+ } catch {
10+ return false
11+ }
12+ }
13+
14+ function hasDockerCGroup ( ) {
15+ try {
16+ return readFileSync ( '/proc/self/cgroup' , 'utf8' ) . includes ( 'docker' )
17+ } catch {
18+ return false
19+ }
20+ }
21+
22+ export function isDocker ( ) {
23+ if ( isDockerCached === undefined ) {
24+ isDockerCached = hasDockerEnv ( ) || hasDockerCGroup ( )
25+ }
26+
27+ return isDockerCached
28+ }
You can’t perform that action at this time.
0 commit comments