From 092164bf2d4af2ea432f191f79ebc823ada3ea8f Mon Sep 17 00:00:00 2001 From: Rob Mitchell <40571882+robertandremitchell@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:06:47 -0400 Subject: [PATCH] Moving TEFCA DB vars to docker compose (#2613) * Moving TEFCA DB vars to docker compose * removing root user error message * removing root user error message --- containers/tefca-viewer/docker-compose-dev.yaml | 8 +++++--- containers/tefca-viewer/docker-compose.yaml | 11 ++++++----- containers/tefca-viewer/e2e/query_workflow.spec.ts | 2 +- containers/tefca-viewer/src/app/database-service.ts | 4 ++-- containers/tefca-viewer/tefca.env | 7 ------- 5 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 containers/tefca-viewer/tefca.env diff --git a/containers/tefca-viewer/docker-compose-dev.yaml b/containers/tefca-viewer/docker-compose-dev.yaml index 19112fddea..e1eefd1ae2 100644 --- a/containers/tefca-viewer/docker-compose-dev.yaml +++ b/containers/tefca-viewer/docker-compose-dev.yaml @@ -4,10 +4,12 @@ services: image: "postgres:alpine" ports: - "5432:5432" - env_file: - - "./tefca.env" + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=pw + - POSTGRES_DB=tefca_db healthcheck: - test: ["CMD-SHELL", "pg_isready"] + test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 2s timeout: 5s retries: 20 diff --git a/containers/tefca-viewer/docker-compose.yaml b/containers/tefca-viewer/docker-compose.yaml index 70467efbff..a134338a77 100644 --- a/containers/tefca-viewer/docker-compose.yaml +++ b/containers/tefca-viewer/docker-compose.yaml @@ -4,10 +4,12 @@ services: image: "postgres:alpine" ports: - "5432:5432" - env_file: - - "./tefca.env" + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=pw + - POSTGRES_DB=tefca_db healthcheck: - test: ["CMD-SHELL", "pg_isready"] + test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 2s timeout: 5s retries: 20 @@ -31,10 +33,9 @@ services: dockerfile: ./containers/tefca-viewer/Dockerfile ports: - "3000:3000" - env_file: - - "./tefca.env" environment: - NODE_ENV=production + - DATABASE_URL=postgres://postgres:pw@db:5432/tefca_db depends_on: db: condition: service_healthy diff --git a/containers/tefca-viewer/e2e/query_workflow.spec.ts b/containers/tefca-viewer/e2e/query_workflow.spec.ts index 10a0b35cc6..bb831973dc 100644 --- a/containers/tefca-viewer/e2e/query_workflow.spec.ts +++ b/containers/tefca-viewer/e2e/query_workflow.spec.ts @@ -270,7 +270,7 @@ test.describe("Test the user journey of a 'tester'", () => { ); // Check that there are multiple rows in the table - await expect(page.locator("tbody").locator("tr")).toHaveCount(9); + await expect(page.locator("tbody").locator("tr")).toHaveCount(10); // Click on the first patient's "View Record" button await page.locator(':nth-match(:text("View Record"), 1)').click(); diff --git a/containers/tefca-viewer/src/app/database-service.ts b/containers/tefca-viewer/src/app/database-service.ts index 546f015407..2a1414e6bb 100644 --- a/containers/tefca-viewer/src/app/database-service.ts +++ b/containers/tefca-viewer/src/app/database-service.ts @@ -1,6 +1,6 @@ "use server"; import { Pool, PoolConfig, QueryResultRow } from "pg"; -import dotenv from "dotenv"; +// import dotenv from "dotenv"; import { ValueSetItem, valueSetTypeToClincalServiceTypeMap } from "./constants"; const getQuerybyNameSQL = ` @@ -14,7 +14,7 @@ select q.query_name, q.id, qtv.valueset_id, vs.name as valueset_name, vs.author `; // Load environment variables from tefca.env and establish a Pool configuration -dotenv.config({ path: "tefca.env" }); +// dotenv.config({ path: "tefca.env" }); const dbConfig: PoolConfig = { connectionString: process.env.DATABASE_URL, max: 10, // Maximum # of connections in the pool diff --git a/containers/tefca-viewer/tefca.env b/containers/tefca-viewer/tefca.env deleted file mode 100644 index b97646cc03..0000000000 --- a/containers/tefca-viewer/tefca.env +++ /dev/null @@ -1,7 +0,0 @@ -POSTGRES_USER=postgres -PGUSER=postgres -POSTGRES_PASSWORD=pw -POSTGRES_DB=tefca_db -DATABASE_URL=postgres://postgres:pw@db:5432/tefca_db -POSTGRES_PORT=5432 -POSTGRES_HOST=localhost \ No newline at end of file