-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·51 lines (41 loc) · 1.28 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Example usage:
# ./start.sh /path/to/project
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/project"
exit 1
fi
PROJECT_PATH=$(realpath "$1")
export PROJECT_PATH
echo "Project path: $PROJECT_PATH"
# Check if Docker is running on macOS
if ! docker info >/dev/null 2>&1; then
echo "Docker is not running. Starting Docker..."
open --background -a Docker
while ! docker info >/dev/null 2>&1; do
echo "Waiting for Docker to start..."
sleep 1
done
echo "Docker started."
else
echo "Docker is already running."
fi
# Retrieve and export Git user name and email
export GIT_USER_NAME=$(git config --global user.name)
export GIT_USER_EMAIL=$(git config --global user.email)
if [ -z "$GIT_USER_NAME" ] || [ -z "$GIT_USER_EMAIL" ]; then
echo "Git user.name and/or user.email not set in .gitconfig"
exit 1
fi
echo "Git user name: $GIT_USER_NAME"
echo "Git user email: $GIT_USER_EMAIL"
# Check if package.json or bun.lockb have changed
if git diff --quiet HEAD -- package.json bun.lockb; then
echo "No changes in package.json or bun.lockb. Using cached dependencies."
BUILD_ARG="--build"
else
echo "Changes detected in package.json or bun.lockb. Rebuilding with no cache."
BUILD_ARG="--build --no-cache"
fi
# Build and start the containers
docker-compose up $BUILD_ARG