-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·44 lines (37 loc) · 1.3 KB
/
deploy.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
#!/bin/bash
# Default mode is not detached
DETACHED=false
# Parse command-line options
while getopts "d" opt; do
case $opt in
d) DETACHED=true ;;
*) echo "Usage: $0 [-d]"; exit 1 ;;
esac
done
# Update codebase with latest version
echo "Pulling latest code..."
git pull origin main || { echo "Failed to pull latest code"; exit 1; }
# Check if Docker is running
if ! docker info >/dev/null 2>&1; then
echo "Docker is not running. Please start Docker and try again. If it is not installed, find details at https://www.docker.com/"
exit 1
fi
# Build and run Docker containers
if [ "$DETACHED" = true ]; then
echo "Running in detached mode..."
docker compose up --build -d || { echo "Failed to build Docker containers"; exit 1; }
else
echo "Running with local docker container..."
docker compose up --build || { echo "Failed to build Docker containers"; exit 1; }
fi
# Navigate to frontend in browser
echo "Application is ready at http://localhost:3000..."
sleep 2 # Allow server to start
# Wait for servers to run if not in detached mode; terminate on user input
if [ "$DETACHED" = false ]; then
echo "Frontend and backend servers are running."
echo "Press Ctrl+C to stop the servers."
wait $FRONTEND_PID $BACKEND_PID
else
echo "Frontend and backend servers are running in detached mode."
fi