updated install script to wait until db is online

This commit is contained in:
Kai Ritthaler 2025-06-14 21:30:05 +02:00 committed by Rudi Regentonne
parent 8cbbbb8cc1
commit d2b90bf9a4
4 changed files with 9 additions and 16 deletions

View file

@ -16,7 +16,6 @@
"jsonwebtoken": "^9.0.2",
"minio": "^8.0.5",
"multer": "^2.0.0",
"node": "^22.15.0",
"pg": "^8.15.6",
"readline-sync": "^1.4.10",
"swagger-jsdoc": "^6.2.8",
@ -37,7 +36,7 @@
"typescript": "^5.8.3"
},
"scripts": {
"start-containers": "docker-compose -f ../db/docker-compose.yaml --env-file .env up -d",
"start-containers": "docker compose -f ../db/docker-compose.yaml --env-file .env up -d --wait",
"stop-containers": "docker-compose down",
"start": "yarn start-containers && nodemon src/server.ts",
"start-no-docker": "nodemon src/server.ts",

View file

@ -75,6 +75,7 @@ if (fs.existsSync(".env")) {
console.error("Error writing to file:", err);
}
}
let failed: boolean = false;
// running the commands from the JSON file
// The commands are executed in the order they are defined in the JSON file
(async () => {
@ -87,6 +88,7 @@ if (fs.existsSync(".env")) {
console.log(stdout); // Print the output of the command`);
} catch (error: any) {
console.log(`error: ${error.message}`);
failed = true;
break; // Stop execution if an error occurs
}
}
@ -104,6 +106,6 @@ if (fs.existsSync(".env")) {
console.log("Bucket 'images' created successfully.");
}
console.log("Installation complete");
console.log(failed?"installation failed":"Installation complete");
process.exit(0); // Exit the process after all commands are executed
})();

View file

@ -1178,18 +1178,6 @@ negotiator@^1.0.0:
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-1.0.0.tgz#b6c91bb47172d69f93cfd7c357bbb529019b5f6a"
integrity sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==
node-bin-setup@^1.0.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/node-bin-setup/-/node-bin-setup-1.1.3.tgz#d45d5220e3b2ecc3a94263a56116f727f6c1bb14"
integrity sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==
node@^22.15.0:
version "22.15.0"
resolved "https://registry.yarnpkg.com/node/-/node-22.15.0.tgz#dbc02391e8db6891fb42de5e1a184630f1d38f78"
integrity sha512-qrOEL83lNt+Jbh9pekl5xQrZK+QRJz51m2IGGCu2NENgbG6Go0D1QUBvjbejP8jB2eokQpX1AorDLbKQ/FxuYA==
dependencies:
node-bin-setup "^1.0.0"
nodemon@^3.1.10:
version "3.1.10"
resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.1.10.tgz#5015c5eb4fffcb24d98cf9454df14f4fecec9bc1"

View file

@ -10,7 +10,11 @@ services:
POSTGRES_DB: prisma
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 5s
timeout: 3s
retries: 5
minio:
image: quay.io/minio/minio
container_name: minio