-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
121 lines (111 loc) · 3.45 KB
/
setup.sh
File metadata and controls
121 lines (111 loc) · 3.45 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
echo "Setting up Grid View Project Companion..."
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "Error: Docker is not installed or not in PATH"
echo "Please install Docker Desktop from https://www.docker.com/products/docker-desktop"
echo "and make sure it is running before continuing."
exit 1
fi
# Create directories
echo "Creating required directories..."
mkdir -p public/uploads public/exports public/backups
# Create .env.example
echo "Creating environment file..."
cat > .env.example << EOL
# OpenAI API Key for voice features (optional)
OPENAI_API_KEY=your_api_key_here
NEXT_PUBLIC_OPENAI_API_KEY=your_api_key_here
EOL
# Copy .env.example to .env.local
echo "Creating .env.local from template..."
cp .env.example .env.local
# Function to validate API key format
validate_api_key() {
local api_key=$1
if [[ $api_key =~ ^sk- ]]; then
return 0
else
return 1
fi
}
# Prompt for API key
echo
read -p "Would you like to add your OpenAI API key for voice features? (y/N) " ADD_KEY
if [[ $ADD_KEY =~ ^[Yy]$ ]]; then
while true; do
echo
echo "Please enter your OpenAI API key:"
echo "(It should start with 'sk-')"
echo "(You can paste it using Ctrl+Shift+V or Command+V)"
read API_KEY
if validate_api_key "$API_KEY"; then
echo
echo "API key format verified."
# Replace placeholder in .env.local with actual API key
sed -i "s/your_api_key_here/$API_KEY/g" .env.local
echo "API key has been added to .env.local"
break
else
echo
echo "Error: The API key format appears to be invalid."
echo "It should start with 'sk-'"
echo
read -p "Would you like to try again? (y/N) " RETRY
if [[ ! $RETRY =~ ^[Yy]$ ]]; then
echo
echo "Continuing without API key..."
break
fi
fi
done
else
echo
echo ".env.local created with placeholder API key."
echo "You can add your API key later by editing .env.local"
fi
# Create docker-compose.yml
echo "Creating docker-compose.yml..."
cat > docker-compose.yml << EOL
version: '3.8'
services:
app:
image: schuttpj1986/grid-view-project-companion:latest
ports:
- "3000:3000"
volumes:
- ./.env.local:/app/.env.local
- ./public/uploads:/app/public/uploads
- ./public/exports:/app/public/exports
- ./public/backups:/app/public/backups
- indexeddb-data:/app/.next/cache/indexeddb
- app-data:/app/data
restart: unless-stopped
volumes:
app-data:
driver: local
indexeddb-data:
driver: local
EOL
echo
echo "Downloading Docker image..."
echo "This might take a few minutes depending on your internet connection..."
if ! docker pull schuttpj1986/grid-view-project-companion:latest; then
echo
echo "Error: Failed to download Docker image."
echo "Please check your internet connection and try again."
exit 1
fi
echo "Docker image downloaded successfully!"
echo
echo "Setup complete!"
if [ -z "$API_KEY" ]; then
echo
echo "Note: Voice features will be disabled. You can enable them later by:"
echo "1. Getting an API key from https://platform.openai.com/api-keys"
echo "2. Adding it to .env.local in this folder"
fi
echo
echo "Next steps:"
echo "1. Run: docker-compose up -d"
echo "2. Open http://localhost:3000 in your browser"