chore: add dev containers

This commit is contained in:
BennyKok
2024-01-20 22:38:31 +08:00
parent e400966117
commit e344c3e6a4
7 changed files with 92 additions and 6 deletions
+5
View File
@@ -9,6 +9,11 @@
"recommended": true
}
},
"json": {
"parser": {
"allowComments": true
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
+4 -3
View File
@@ -12,10 +12,11 @@ let sslMode: string | boolean = process.env.SSL || "require";
if (sslMode === "false") sslMode = false;
console.log(migrationsFolderName, sslMode);
let connectionString = process.env.POSTGRES_URL!;
const isDevContainer = process.env.VSCODE_DEV_CONTAINER !== undefined;
if (isDevContainer) connectionString = connectionString.replace("localhost","host.docker.internal")
const connectionString = process.env.POSTGRES_URL!;
console.log(connectionString);
const sql = postgres(connectionString, { max: 1, ssl: sslMode as any });
const db = drizzle(sql, {
logger: true,
+9 -1
View File
@@ -2,10 +2,18 @@ import * as schema from "./schema";
import { neonConfig, Pool } from "@neondatabase/serverless";
import { drizzle as neonDrizzle } from "drizzle-orm/neon-serverless";
const isDevContainer = process.env.REMOTE_CONTAINERS !== undefined;
// if we're running locally
if (process.env.VERCEL_ENV !== "production") {
// Set the WebSocket proxy to work with the local instance
neonConfig.wsProxy = (host) => `${host}:5481/v1`;
if (isDevContainer) {
// Running inside a VS Code devcontainer
neonConfig.wsProxy = (host) => `host.docker.internal:5481/v1`;
} else {
// Not running inside a VS Code devcontainer
neonConfig.wsProxy = (host) => `${host}:5481/v1`;
}
// Disable all authentication and encryption
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;