forked from SakshamHaryana-SE/enketo
-
Notifications
You must be signed in to change notification settings - Fork 28
/
setup.sh
63 lines (48 loc) · 1.81 KB
/
setup.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
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
read -r -p "Is Docker, Node, Python installed on your system? [y/n]: " response
# If response is No then ask them to install else Go further
if [[ "$response" =~ ^[Nn]$ ]]; then
echo -e "Please install the required packages:-\n 1. Docker\n 2. Node\n 3. Python"
else
# Run docker containers and build the packages
docker-compose up -d --build
# Check if docker-compose command was successful
if [ $? -eq 0 ]; then
echo "Success: Docker containers built successfully."
# Get the ID of the 'wrapper' container
wrapper_id=$(docker ps -aqf "name=wrapper")
echo "Wrapper Container ID = $wrapper_id"
# Stop and remove wrapper container
docker stop "$wrapper_id" >/dev/null && docker rm "$wrapper_id" >/dev/null
echo "Success: Wrapper Container stopped and removed."
# Change directory app/wrapper
cd apps/wrapper
# Add env to the .env file
{
echo "REACT_APP_ENKETO_URL=http://localhost:8065"
echo "REACT_APP_FORM_MANAGER_URL=http://localhost:3006"
echo "REACT_APP_HASURA_URL=http://localhost:8080"
} >>.env
echo "Created .env file in apps/wrapper directory."
# Check if pnpm is installed or not
if ! command -v pnpm &>/dev/null; then
echo "pnpm is not installed. Installing pnpm..."
# Install pnpm using npm
npm install -g pnpm
if [ $? -eq 0 ]; then
echo "pnpm installed successfully."
else
echo "Error: Failed to install pnpm."
exit 1
fi
else
echo "pnpm is already installed."
fi
# Installing dependencies
pnpm i
echo "Success: All dependencies are installed."
echo -e "\n Success: All dependencies are installed. \nRun this command to start the live server \n pnpm run start\n"
else
echo "Error: Failed to build Docker containers."
fi
fi