Switch backend to wait for SQL Server and use direct INSERTs
Replace stored procedure calls with inline INSERT statements and SCOPE_IDENTITY() Add netcat for readiness check in new entrypoint.sh Introduce dedicated SQL Server and init-db services in docker-compose
This commit is contained in:
24
backend/entrypoint.sh
Normal file
24
backend/entrypoint.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# entrypoint.sh – wait for the SQL Server container to become ready
|
||||
# before starting the Go backend binary.
|
||||
|
||||
set -e
|
||||
|
||||
# Default environment variables (can be overridden in docker-compose)
|
||||
: "${DB_SERVER:=sql}"
|
||||
: "${DB_USER:=sa}"
|
||||
: "${DB_PASSWORD:=Ou812@12!@}"
|
||||
|
||||
# Wait until netcat can successfully connect to the SQL Server port
|
||||
while ! nc -z "$DB_SERVER" 1433; do
|
||||
echo "⏳ Waiting for SQL Server at $DB_SERVER:1433..."
|
||||
sleep 1
|
||||
done
|
||||
# Add a short pause after the port is open to let SQL Server finish startup
|
||||
sleep 5
|
||||
# Add a short pause after the port is open to let SQL Server finish startup
|
||||
sleep 2
|
||||
|
||||
echo "✅ SQL Server is ready. Starting backend."
|
||||
exec ./main
|
||||
Reference in New Issue
Block a user