-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: docker compose failing to build and spark failing to start
- moved isTestMode from the tests.ts library to the server.ts library to circumvent any import errors. - programmatically import in-memory database only if the server has been detected to be running in test mode. - fix creation of citext extension on the in-memory database by including a statement before migration. - programmatically import the redis memory server only if the server is running in the test mode. - added build-essential to the Dockerfile to allow for the make command to work when installing dependencies. - made the spark docker container depend on the database and keydb containers. - created a postgres spark user for spark related tasks instead of using the root/postgres user.
- Loading branch information
Showing
7 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,31 @@ | ||
import { PGlite as testClient } from '@electric-sql/pglite'; // for unit tests use | ||
import { drizzle as prodDrizzle } from 'drizzle-orm/node-postgres'; // for production use | ||
import { drizzle as testDrizzle } from 'drizzle-orm/pglite'; // for unit tests use | ||
import { Client as prodClient } from 'pg'; // for production use | ||
import * as schema from './schema'; // get all the schema | ||
|
||
export const prodDbClient = new prodClient({ | ||
connectionString: process.env.DATABASE_URL as string | ||
}); | ||
|
||
export const db = | ||
process.env.NODE_ENV !== 'test' | ||
? prodDrizzle(prodDbClient, { schema }) // we want to use a real database | ||
: testDrizzle(new testClient(), { schema }); // we want to use a in-memory database | ||
import { NodePgDatabase } from 'drizzle-orm/node-postgres'; | ||
import { PgliteDatabase } from 'drizzle-orm/pglite'; | ||
|
||
let db: | ||
| (NodePgDatabase<typeof schema> & { $client: prodClient }) | ||
| (PgliteDatabase<typeof schema> & { $client: any }); | ||
|
||
if (process.env.NODE_ENV !== 'test') { | ||
db = prodDrizzle(prodDbClient, { schema }); // we want to use a real database | ||
} else { | ||
import('@electric-sql/pglite').then(({ PGlite: testClient }) => { | ||
import('drizzle-orm/pglite').then(({ drizzle: testDrizzle }) => { | ||
// @ts-ignore - TODO: fix later | ||
import('@electric-sql/pglite/contrib/citext').then(({ citext }) => { | ||
db = testDrizzle(new testClient({ extensions: { citext } }), { | ||
schema | ||
}); // we want to use an in-memory database | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
export { db }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters