diff --git a/app/web/Makefile b/app/web/Makefile index dad283ef1..448469189 100644 --- a/app/web/Makefile +++ b/app/web/Makefile @@ -39,12 +39,17 @@ PORT ?= 8080 LOG_FILE ?= privacypal-run.log PRIVACYPAL_AUTH_MANAGER ?= cognito PRIVACYPAL_DEBUG ?= true -DATABASE_URL = postgresql://privacypal:password@localhost:5432/privacypal PRIVACYPAL_LAMBDA_NAME ?= processVideoContainer PRIVACYPAL_TMP_BUCKET ?= privacypal-input PRIVACYPAL_OUTPUT_BUCKET ?= privacypal-output +DATABASE ?= privacypal +DATABASE_USER ?= privacypal +DATABASE_PASSWORD ?= password +DATABASE_HOSTNAME ?= localhost +DATABASE_PORT ?= 5432 + .PHONY: run run: ## Run the web server as a standalone container. $(IMAGE_BUILDER) run --name "$(CONTAINER_NAME)" \ @@ -63,7 +68,11 @@ run: ## Run the web server as a standalone container. -e PRIVACYPAL_DEBUG="$(PRIVACYPAL_DEBUG)" \ -e PRIVACYPAL_AUTH_SECRET="$$(openssl rand -base64 32)" \ -e PRIVACYPAL_COOKIE_NAME="privacypal" \ - -e DATABASE_URL="$(DATABASE_URL)" \ + -e PRIVACYPAL_POSTGRES_USERNAME=$(DATABASE_USER) \ + -e PRIVACYPAL_POSTGRES_PASSWORD=$(DATABASE_PASSWORD) \ + -e PRIVACYPAL_POSTGRES_HOST=$(DATABASE_HOSTNAME) \ + -e PRIVACYPAL_POSTGRES_PORT=$(DATABASE_PORT) \ + -e PRIVACYPAL_POSTGRES_DATABASE=$(DATABASE) \ -e PRIVACYPAL_LAMBDA_NAME="$(PRIVACYPAL_LAMBDA_NAME)" \ -e PRIVACYPAL_OUTPUT_BUCKET="$(PRIVACYPAL_OUTPUT_BUCKET)" \ -e PRIVACYPAL_TMP_BUCKET="$(PRIVACYPAL_TMP_BUCKET)" \ diff --git a/app/web/env.tpl b/app/web/env.tpl index 7179f8e4b..768bebeb5 100644 --- a/app/web/env.tpl +++ b/app/web/env.tpl @@ -10,7 +10,11 @@ PRIVACYPAL_AUTH_MANAGER=cognito PRIVACYPAL_DEBUG=true PRIVACYPAL_AUTH_SECRET="0Fa2BOJrd3958qaZUa7pf1jEREoo6tU5rsx430bUp/k=" PRIVACYPAL_COOKIE_NAME="privacypal" -DATABASE_URL=postgresql://privacypal:password@localhost:5432/privacypal +PRIVACYPAL_POSTGRES_USERNAME=privacypal +PRIVACYPAL_POSTGRES_PASSWORD=password +PRIVACYPAL_POSTGRES_HOST=localhost +PRIVACYPAL_POSTGRES_PORT=5432 +PRIVACYPAL_POSTGRES_DATABASE=privacypal PRIVACYPAL_LAMBDA_NAME=processVideoContainer PRIVACYPAL_OUTPUT_BUCKET=privacypal-output PRIVACYPAL_TMP_BUCKET=privacypal-input diff --git a/app/web/src/lib/db.ts b/app/web/src/lib/db.ts index 96138998c..a3642b6a6 100644 --- a/app/web/src/lib/db.ts +++ b/app/web/src/lib/db.ts @@ -17,7 +17,19 @@ import { PrismaClient } from "@prisma/client"; import { IS_PRODUCTION } from "./config"; const prismaClientSingleton = () => { - return new PrismaClient(); + const userName = process.env.PRIVACYPAL_POSTGRES_USERNAME; + const host = process.env.PRIVACYPAL_POSTGRES_HOST; + const port = process.env.PRIVACYPAL_POSTGRES_PORT; + const database = process.env.PRIVACYPAL_POSTGRES_DATABASE; + const password = process.env.PRIVACYPAL_POSTGRES_PASSWORD; + + return new PrismaClient({ + datasources: { + db: { + url: `postgresql://${userName}:${password}@${host}:${port}/${database}` + } + } + }); }; type PrismaClientSingleton = ReturnType;