dsql-admin/dsql-app/docker-entrypoint.sh

59 lines
1.4 KiB
Bash
Raw Normal View History

2024-11-05 11:12:42 +00:00
#!/bin/bash
cd /app
2025-01-13 08:00:21 +00:00
2025-01-13 21:25:20 +00:00
echo "Installing Bun Dependencies ..."
2025-01-13 08:00:21 +00:00
bun install
bun update @moduletrace/datasquirel
2025-01-13 21:25:20 +00:00
echo "Bun Dependencies Installed Successfully!"
2024-11-05 11:12:42 +00:00
2024-11-05 18:42:02 +00:00
chmod +x init-sql.sh
2025-01-13 08:00:21 +00:00
bun init/init-sql/index.ts
2024-11-05 11:12:42 +00:00
if [[ $? == 0 ]]; then
echo "Dsql Database config complete"
else
echo "Dsql Database configuration failed. Exiting ..."
exit 1
fi
2025-01-13 08:00:21 +00:00
bun init/init-db/index.ts
2024-11-05 11:12:42 +00:00
2024-11-05 14:18:40 +00:00
if [[ $? == 0 ]]; then
echo "Dsql Schema Setup Complete"
else
echo "Dsql Schema Setup failed. Exiting ..."
exit 1
fi
if [ -n "${NEXT_PUBLIC_DSQL_LOCAL}" ]; then
if [[ "$DSQL_HOST_ENV" == *"dev_dev"* ]]; then
echo "NEXT_PUBLIC_DSQL_LOCAL is set in dev environment."
batchrun
else
echo "NEXT_PUBLIC_DSQL_LOCAL is set. Running Local initialization ..."
2025-01-13 08:00:21 +00:00
bun /app/docker-root-user-init.ts
2024-11-05 14:18:40 +00:00
if [[ $? == 0 ]]; then
echo "First User Setup Complete"
else
echo "First User Setup Failed!. Exiting ..."
exit 1
fi
2025-01-13 08:00:21 +00:00
bun /app/package-shared/shell/mariadb-users/refreshUsersAndGrants.ts
bun run start:local
2024-11-05 14:18:40 +00:00
fi
else
2024-11-05 11:12:42 +00:00
echo "NEXT_PUBLIC_DSQL_LOCAL is not set."
if [ "${DSQL_HOST_ENV}" == "prod_prod" ]; then
echo "Main Production Environment"
2025-01-13 08:00:21 +00:00
bun run build
2025-01-13 21:25:20 +00:00
# nodecid
bun server.ts
2024-11-05 11:12:42 +00:00
else
echo "Dev Environment"
2025-01-13 08:00:21 +00:00
# batchrun
bun dev
2024-11-05 11:12:42 +00:00
fi
fi