From a328da679c0a7b2d5b64e8203069c35f9391ac4f Mon Sep 17 00:00:00 2001 From: chamikaJ Date: Fri, 25 Apr 2025 12:30:15 +0530 Subject: [PATCH] Update docker-compose.yml to use bind mount for database initialization and add script execution for dos2unix; modify CORS origin check in app.ts for production environment --- docker-compose.yml | 18 +++++++++++++++++- worklenz-backend/src/app.ts | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 02dab3ee..c80eb976 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,7 +113,23 @@ services: - worklenz volumes: - worklenz_postgres_data:/var/lib/postgresql/data - - ./worklenz-backend/database/:/docker-entrypoint-initdb.d + - type: bind + source: ./worklenz-backend/database + target: /docker-entrypoint-initdb.d + consistency: cached + command: > + bash -c ' + if command -v apt-get >/dev/null 2>&1; then + apt-get update && apt-get install -y dos2unix + elif command -v apk >/dev/null 2>&1; then + apk add --no-cache dos2unix + fi && + find /docker-entrypoint-initdb.d -type f -name "*.sh" -exec sh -c '\'' + dos2unix "{}" 2>/dev/null || true + chmod +x "{}" + '\'' \; && + exec docker-entrypoint.sh postgres + ' volumes: worklenz_postgres_data: diff --git a/worklenz-backend/src/app.ts b/worklenz-backend/src/app.ts index 4fead2d9..28ed9095 100644 --- a/worklenz-backend/src/app.ts +++ b/worklenz-backend/src/app.ts @@ -69,7 +69,7 @@ const allowedOrigins = [ app.use(cors({ origin: (origin, callback) => { - if (!origin || allowedOrigins.includes(origin)) { + if (!isProduction() || !origin || allowedOrigins.includes(origin)) { callback(null, true); } else { console.log("Blocked origin:", origin, process.env.NODE_ENV);