Skip to content

Commit 0174026

Browse files
authored
Merge pull request #40 from strangest-quark/master
Brew changes #39
2 parents 9e37266 + a80395a commit 0174026

File tree

3 files changed

+166
-2
lines changed

3 files changed

+166
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Stackbox helps you create app stacks loaded with all your favourite clients, ser
3232
# Get Started
3333
## Run
3434

35-
`sh stack_box.sh`
35+
`sh stackbox.sh`
3636

3737
Follow the menu options to select clients and services for your stack.
3838

@@ -53,7 +53,7 @@ The following is a list of example stacks you could spin-up using Stackbox and q
5353
### 1. Flask-Vue-Mysql-Elasticsearch
5454
#### Run
5555

56-
`sh stack_box.sh`
56+
`sh stackbox.sh`
5757

5858
Choose vue for frontend, flask for backend. Choose mysql and elasticsearch (with/without kibana) for services.
5959

stackbox-brew.sh

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#!/bin/bash
2+
3+
echo " _ _ _"
4+
echo " ___| |_ __ _ ___| | _| |__ _____ __"
5+
echo "/ __| __/ _ |/ __| |/ / '_ \ / _ \ \/ /"
6+
echo "\__ \ || (_| | (__| <| |_) | (_) > <"
7+
echo '|___/\__\__,_|\___|_|\_\_.__/ \___/_/\_\'
8+
echo "\n"
9+
10+
echo "######## SELECT YOUR STACK #############\n"
11+
12+
stack=()
13+
14+
PS3='Select your frontend: '
15+
16+
echo "FRONTEND OPTIONS:"
17+
18+
frontend_options=("Vue")
19+
select opt in "${frontend_options[@]}"
20+
do
21+
case $opt in
22+
"Vue")
23+
echo "You've chosen Vue"
24+
stack+=("vue")
25+
break;
26+
;;
27+
*) echo "Invalid option $REPLY";;
28+
esac
29+
done
30+
31+
PS3='Select your backend: '
32+
33+
echo "BACKEND OPTIONS:"
34+
35+
backend_options=("Flask" "Rails")
36+
select opt in "${backend_options[@]}"
37+
do
38+
case $opt in
39+
"Flask")
40+
echo "You've chosen Flask"
41+
stack+=("flask")
42+
break;
43+
;;
44+
"Rails")
45+
echo "You've chosen Rails"
46+
stack+=("rubyonrails")
47+
break;
48+
;;
49+
*) echo "Invalid option $REPLY";;
50+
esac
51+
done
52+
53+
printf "\n"
54+
PS3='Add your services. Choose 5 to finish adding: '
55+
56+
echo "SERVICE OPTIONS:"
57+
service_options=("MySQL" "Kafka" "Elasticsearch" "Nginx" "Done")
58+
select opt in "${service_options[@]}"
59+
do
60+
case $opt in
61+
"MySQL")
62+
echo "You've chosen MySQL"
63+
stack+=("mysql")
64+
continue;
65+
;;
66+
"Kafka")
67+
echo "You've chosen Kafka. Zookeper will also be set up."
68+
stack+=("kafka")
69+
stack+=("zookeeper")
70+
continue;
71+
;;
72+
"Elasticsearch")
73+
echo "You've chosen Elasticsearch"
74+
stack+=("elasticsearch")
75+
# shellcheck disable=SC2162
76+
read -p "Do you want Kibana as well? (y/n)" yn
77+
case $yn in
78+
[Yy]* )
79+
echo "You've chosen Kibana + Elasticsearch"
80+
stack+=("kibana")
81+
continue;;
82+
[Nn]* )
83+
echo "You've chosen Elasticsearch without Kibana"
84+
continue;;
85+
* ) echo "Please answer yes or no.";;
86+
esac
87+
;;
88+
"Nginx")
89+
echo "You've chosen Nginx"
90+
stack+=("nginx")
91+
continue;
92+
;;
93+
"Done")
94+
break
95+
;;
96+
*) echo "Invalid option $REPLY";;
97+
esac
98+
done
99+
100+
printf "\n"
101+
printf "The services you've chosen are: "
102+
echo "${stack[*]}"
103+
printf "\n"
104+
105+
echo "######## BUILDING YOUR STACK ###############\n"
106+
107+
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
108+
109+
python_version=$(python --version)
110+
python3_version=$(python3 --version)
111+
112+
if beginswith "Python 3" "$python_version" ;
113+
then
114+
var="$(pip --disable-pip-version-check install -r ../requirements.txt) > /dev/null "
115+
python ../stack.py ${stack[*]}
116+
elif beginswith "Python 3" "$python3_version";
117+
then
118+
var="$(pip3 --disable-pip-version-check install -r ../requirements.txt) > /dev/null"
119+
python3 ../stack.py ${stack[*]}
120+
else
121+
echo "Unable to find a python 3 installation"
122+
fi
123+
124+
docker-compose -f ../docker-compose.yml down 2> /dev/null > logs/docker-compose-down-log.txt
125+
docker-compose -f ../docker-compose.yml build > logs/docker-compose-build-log.txt
126+
127+
echo "\n######## DEPLOYING YOUR STACK ##############\n"
128+
129+
docker-compose -f ../docker-compose.yml up -d --remove-orphans
130+
131+
sleep 5
132+
133+
echo "\n######## YOUR STACK ########################\n"
134+
135+
containers=$(docker ps --format '{{.Names}}')
136+
ports="$(docker ps --format '{{.Ports}}')"
137+
138+
service_ports=()
139+
140+
for port in $ports;
141+
do
142+
if beginswith "0.0.0.0" "$port";
143+
then
144+
port1=$(echo "$port" | awk -F[:-] '{print $2}')
145+
service_ports+=("$port1")
146+
fi
147+
done
148+
149+
i=-1
150+
151+
for container in $containers;
152+
do
153+
i=$i+1
154+
if [ "$container" != "registry" ];
155+
then
156+
if beginswith "stackbox" "$container";
157+
then
158+
tmp=${container%"_1"}
159+
echo ${tmp#"stackbox_"} is up at http://localhost:${service_ports[i]}
160+
fi
161+
fi
162+
done
163+
164+
echo "\n"
File renamed without changes.

0 commit comments

Comments
 (0)