Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Thumbs.db
*.truststore
secrets/
credentials/
.atl

# Application configs
application-local.yml
Expand Down
42 changes: 42 additions & 0 deletions scripts/dev-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# ================================================================
# dev-start.sh — Start local development environment
# Usage: ./script/dev-start.sh
# ================================================================

# Move to project root regardless of where script is called from
cd "$(dirname "$0")/.." || exit 1

# 1. Load .env FIRST — Docker Compose needs these variables to start
# set -a exports ALL variables defined after it
# source .env reads the file
# set +a stops auto-exporting
if [ ! -f .env ]; then
echo "ERROR: .env file not found. Copy .env.example and fill in your values."
exit 1
fi
set -a && source .env && set +a
echo "Environment variables loaded."

# 2. Start PostgreSQL container
echo "Starting PostgreSQL..."
docker compose up -d postgres

# 3. Wait for PostgreSQL to be healthy (uses healthcheck defined in docker-compose.yml)
echo "Waiting for PostgreSQL to be ready..."
until docker compose exec -T postgres pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB" 2>/dev/null; do
sleep 1
done
echo "PostgreSQL is ready."

# 4. Start Spring Boot with dev profile (background + PID)
# WHY background + PID file: allows dev-stop.sh to kill only THIS process,
# not any other Java project running on the same machine.
echo "Starting Spring Boot on port ${SERVER_PORT:-8080}..."
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev &
SPRING_PID=$!
echo "$SPRING_PID" > .spring-boot.pid
echo "Spring Boot PID: $SPRING_PID (saved to .spring-boot.pid)"

# Wait keeps the script alive so you can see logs — Ctrl+C to stop
wait
28 changes: 28 additions & 0 deletions scripts/dev-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# ================================================================
# dev-stop.sh — Stop local development environment
# Usage: ./script/dev-stop.sh
# ================================================================

cd "$(dirname "$0")/.." || exit 1

# 1. Stop Spring Boot using PID file
# WHY PID file instead of pkill: isolates THIS project — won't kill other Java apps.
echo "Stopping Spring Boot..."
if [ -f .spring-boot.pid ]; then
PID=$(cat .spring-boot.pid)
if kill "$PID" 2>/dev/null; then
echo "Spring Boot stopped (PID $PID)."
else
echo "Spring Boot process (PID $PID) was not running."
fi
rm -f .spring-boot.pid
else
echo "No .spring-boot.pid found. Spring Boot may not be running."
fi

echo "Stopping PostgreSQL container..."
docker compose stop postgres
echo "PostgreSQL stopped."

echo "Done. All services stopped."
Loading