-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathsetup
More file actions
executable file
·77 lines (66 loc) · 1.8 KB
/
setup
File metadata and controls
executable file
·77 lines (66 loc) · 1.8 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
#!/usr/bin/env bash
# Detect the operating system
detect_os() {
case "$(uname -s)" in
Darwin*)
echo "mac"
;;
Linux*)
echo "linux"
;;
CYGWIN*|MINGW*|MSYS*|Windows*)
echo "windows"
;;
*)
echo "unknown"
;;
esac
}
# Function to create .env file
create_env_file() {
if [ "$(detect_os)" = "windows" ]; then
# Windows-style file creation
echo "VITE_API_URL=http://localhost:8080/v1" > .env
echo "VITE_ENVIRONMENT=self-hosted" >> .env
else
# Unix-style file creation
cat > .env << EOL
VITE_API_URL=http://localhost:8080/v1
VITE_ENVIRONMENT=self-hosted
EOL
fi
echo "Created .env file with required configuration"
}
# Function to check Docker installation
check_docker() {
if [ "$(detect_os)" = "windows" ]; then
if ! command -v docker.exe >/dev/null 2>&1; then
echo "Docker is not installed. Please install Docker Desktop for Windows first."
exit 1
fi
else
if ! command -v docker >/dev/null 2>&1; then
echo "Docker is not installed. Please install Docker first."
exit 1
fi
fi
}
# Function to build and run Docker
docker_build_and_run() {
echo "Building Docker image..."
docker build -t flexprice-front .
echo "Running Docker container..."
docker run -d -p 3000:3000 flexprice-front
}
# Main execution
echo "Starting FlexPrice Frontend Setup..."
# Detect OS and show message
OS_TYPE=$(detect_os)
echo "Detected operating system: $OS_TYPE"
# Create .env file
create_env_file
# Check Docker installation
check_docker
# Build and run Docker
docker_build_and_run
echo "Setup completed! The application should be running at http://localhost:3000"