drogon/deployer.sh

106 lines
2.4 KiB
Bash
Raw Normal View History

2018-10-23 23:18:12 +02:00
#!/bin/bash
set -x
2018-10-23 23:18:12 +02:00
### Variables de entorno ###
echo "DROGON_ENV=tst" >> /etc/profile.d/drogon_variables
echo "DB_SERVICE_NAME=tst_drogon_db" >> /etc/profile.d/drogon_variables
echo "NETWORK_NAME=tst_drogon_network" >> /etc/profile.d/drogon_variables
DROGON_ENV=tst
DB_SERVICE_NAME=tst_drogon_db
NETWORK_NAME=tst_drogon_network
2018-10-23 23:18:12 +02:00
###############################################################
################# INSTALACION DE HERRAMIENTAS #################
###############################################################
2018-10-23 23:18:12 +02:00
apt-get update
### Set up de PIP ###
if ! [ -x "$(command -v pip)" ]; then
apt-get -y install python3-pip
2018-10-23 23:18:12 +02:00
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
2018-10-23 23:18:12 +02:00
### Set up de GIT ###
if ! [ -x "$(command -v git)" ]; then
apt-get install git-core
fi
2018-10-23 23:18:12 +02:00
###############################################################
################# DESPLIEGUE DE CODIGO ########################
###############################################################
# Hacer clone desde remote
git clone git@gitlab.com:pablomartincalvo/Drogon.git /opt/Drogon
cd /opt/Drogon
git checkout testing
################# 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
2018-10-23 23:18:12 +02:00
#Geocoder
cd ./geocoder/
python3 geocoder.py >> geocoder_log.log 2>&1 &
2018-10-23 23:18:12 +02:00