104 lines
2.5 KiB
Bash
104 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
### Variables de entorno ###
|
|
echo "export DROGON_ENV=tst" | tee -a /etc/profile.d/drogon_variables.sh
|
|
echo "export DB_SERVICE_NAME=tst_drogon_db" | tee -a /etc/profile.d/drogon_variables.sh
|
|
echo "export NETWORK_NAME=tst_drogon_network" | tee -a /etc/profile.d/drogon_variables.sh
|
|
echo "export GIT_BRANCH=testing" | tee -a /etc/profile.d/drogon_variables.sh
|
|
DROGON_ENV=tst
|
|
DB_SERVICE_NAME=tst_drogon_db
|
|
NETWORK_NAME=tst_drogon_network
|
|
GIT_BRANCH=testing
|
|
|
|
###############################################################
|
|
################# INSTALACION DE HERRAMIENTAS #################
|
|
###############################################################
|
|
|
|
apt-get update
|
|
|
|
### Set up de PIP ###
|
|
if ! [ -x "$(command -v pip)" ]; then
|
|
apt-get -y install python3-pip
|
|
fi
|
|
|
|
### Set up de Docker ###
|
|
if ! [ -x "$(command -v docker)" ]; then
|
|
apt-get install apt-transport-https ca-certificates curl software-properties-common
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
|
apt-get update
|
|
apt-get install docker-ce=18.06.0~ce~3-0~ubuntu
|
|
fi
|
|
|
|
### Set up de GIT ###
|
|
if ! [ -x "$(command -v git)" ]; then
|
|
apt-get install git-core
|
|
fi
|
|
|
|
###############################################################
|
|
################# DESPLIEGUE DE CODIGO ########################
|
|
###############################################################
|
|
|
|
# Hacer clone desde remote
|
|
git clone git@gitlab.com:pablomartincalvo/Drogon.git /opt/Drogon
|
|
cd /opt/Drogon
|
|
git checkout ${GIT_BRANCH}
|
|
|
|
|
|
################# DB
|
|
cd db_layer
|
|
|
|
# Build image
|
|
docker build . -t drogon/img_${DB_SERVICE_NAME}:latest
|
|
|
|
# Crear volumen
|
|
docker volume create vol_${DB_SERVICE_NAME}
|
|
|
|
# Crear red
|
|
docker network create net_${NETWORK_NAME}
|
|
|
|
# Levantar maquina de DB
|
|
docker run -d -v vol_${DB_SERVICE_NAME}:/var/lib/mysql \
|
|
-p 3306:3306 \
|
|
--name $DB_SERVICE_NAME \
|
|
-e MYSQL_ROOT_PASSWORD=noesfacilvivirsindrogon \
|
|
--network=net_${NETWORK_NAME} \
|
|
drogon/img_${DB_SERVICE_NAME}:latest
|
|
|
|
# Respiro
|
|
sleep 10s
|
|
|
|
|
|
################# Servicios
|
|
|
|
#Instalar dependencias
|
|
cd ..
|
|
pip3 install requirements.txt
|
|
|
|
#Explorer
|
|
cd ./explorer/
|
|
python3 explorer.py >> explorer_log.log 2>&1 &
|
|
|
|
# Respiro
|
|
sleep 10s
|
|
|
|
#Refresher
|
|
cd ./refresher/
|
|
python3 refresher.py >> refresher_log.log 2>&1 &
|
|
|
|
# Respiro
|
|
sleep 10s
|
|
|
|
#Capturer
|
|
cd ./capturer/
|
|
python3 capturer.py >> capturer_log.log 2>&1 &
|
|
|
|
# Respiro
|
|
sleep 10s
|
|
|
|
#Geocoder
|
|
cd ./geocoder/
|
|
python3 geocoder.py >> geocoder_log.log 2>&1 &
|
|
|