-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·65 lines (54 loc) · 1.46 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·65 lines (54 loc) · 1.46 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Set color codes for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Parse command line arguments
DEV_MODE=false
while [[ "$#" -gt 0 ]]; do
case $1 in
-d | --dev)
DEV_MODE=true
shift
;;
*)
echo "Unknown parameter: $1"
exit 1
;;
esac
done
echo -e "${GREEN}Starting build process...${NC}"
# Check if .env file exists
if [ ! -f ".env" ]; then
echo -e "${RED}Error: .env file not found in current directory${NC}"
exit 1
fi
# Build and start the container
echo "Building and starting Docker container..."
docker-compose up -d --build
# Wait for container to be ready (adjust sleep time if needed)
echo "Waiting for container to start..."
sleep 5
# Get container ID
CONTAINER_ID=$(docker ps -qf "name=backend-music-downloader-1")
echo "Container ID: ${CONTAINER_ID}"
if [ -z "$CONTAINER_ID" ]; then
echo -e "${RED}Error: Container not found${NC}"
exit 1
fi
# Remove existing project directory in container
echo "Cleaning existing project directory..."
docker exec $CONTAINER_ID rm -rf /app/BeatHarvest
if [ "$DEV_MODE" = true ]; then
echo "Dev mode: Copying local project files..."
docker cp . "${CONTAINER_ID}:/app/BeatHarvest"
else
echo "Production mode: Cloning from repository..."
docker exec $CONTAINER_ID git clone https://github.com/KyleCodes/BeatHarvest.git /app/BeatHarvest
fi
if [ $? -eq 0 ]; then
echo -e "${GREEN}Build process complete!${NC}"
else
echo -e "${RED}Error: Build failed"
exit 1
fi