Skip to content

Commit

Permalink
Updating the setup script to handle sample data import for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
Suyash878 committed Nov 18, 2024
1 parent bba5d82 commit 30adcd8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#!/bin/bash

npm run import:sample-data

30 changes: 30 additions & 0 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,36 @@ async function main(): Promise<void> {
console.log(
"\nCongratulations! Talawa API has been successfully setup! 🥂🎉",
);

/* Performing the sample data import for docker */

if (isDockerInstallation) {
console.log("Starting the sample data import for docker now...");

const entryPointScript = `
#!/bin/bash
npm run import:sample-data
`;

fs.writeFileSync("entrypoint.sh", entryPointScript, { mode: 0o755 });

exec("./entrypoint.sh", (error, stdout, stderr) => {
if (error) {
console.log(`Error importing the sample data: ${error.message}`);
// console.error(stdout); // Logs the standard output of the script
// console.error(stderr); // Logs the error output of the script
return;
}

if (stderr) {
console.error(`stderr: ${stderr}`);
}

console.log(`stdout: ${stdout}`);
console.log("Sample data import complete.");
});
}
}

main();

0 comments on commit 30adcd8

Please sign in to comment.