Use monitor docker hub image for monitor deployment (#284)

This commit is contained in:
Gerardo Nardelli 2020-02-04 02:16:27 -03:00 committed by GitHub
parent 52358d477b
commit bce1e6509e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 21 deletions

@ -1,3 +1,3 @@
---
dependencies:
- { role: common, check_deployed: true, component: 'monitor' }
- { role: common, skip_repo: true, check_deployed: true, component: 'monitor' }

@ -1,5 +1,5 @@
---
- name: Build the containers
shell: docker-compose build
- name: Pull the containers images
shell: docker-compose pull
args:
chdir: "{{ bridge_path }}/monitor"

@ -1,10 +1,46 @@
---
- name: Create configs directory
file:
path: "{{ bridge_path }}/monitor/configs"
state: directory
mode: '0755'
when: skip_task != true
- name: Create responses directory
file:
path: "{{ bridge_path }}/monitor/responses"
state: directory
mode: '0755'
when: skip_task != true
- name: Create scripts directory
file:
path: "{{ bridge_path }}/monitor/scripts"
state: directory
mode: '0755'
when: skip_task != true
- name: Install .env config
template:
src: .env.j2
dest: "{{ bridge_path }}/monitor/.env"
when: skip_task != true
- name: Copy docker-compose file
copy:
src: ../../../../monitor/docker-compose.yml
dest: "{{ bridge_path }}/monitor/docker-compose.yml"
mode: '0755'
when: skip_task != true
- name: Copy script file
copy:
src: ../../../../monitor/scripts/getBridgeStats.sh
dest: "{{ bridge_path }}/monitor/scripts/getBridgeStats.sh"
owner: "{{ compose_service_user }}"
mode: '0755'
when: skip_task != true
- name: Install bridge config env
template:
src: config.env.j2

@ -1,6 +1,5 @@
# This role creates a tokenbridge-monitor service which is designed to manage docker-compose monitor deployment.
# /etc/init.d/tokenbridge-monitor start, status, stop, restart - does what the services usually do in such cases.
# /etc/init.d/tokenbridge-monitor rebuild - builds a new monitor deployment from scratch.
---
- name: "Set the service"
template:

@ -34,14 +34,6 @@ status(){
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose ps
}
rebuild(){
echo "Rebuild TokenBridge Monitor.."
cd $WORKDIR
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach --force-recreate --no-deps --build
}
case "$1" in
@ -63,12 +55,8 @@ case "$1" in
start
;;
rebuild)
rebuild
;;
*)
echo $"Usage: $0 {start|stop|restart|rebuild|status}"
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
;;

@ -2,9 +2,7 @@
version: '2.4'
services:
monitor:
build:
context: ..
dockerfile: monitor/Dockerfile
image: poanetwork/tokenbridge-monitor:latest
ports:
- "${MONITOR_PORT}:${MONITOR_PORT}"
env_file: ./.env

@ -4,7 +4,7 @@ cd $(dirname $0)/..
if /usr/local/bin/docker-compose ps | grep -q -i 'monitor'; then
for file in configs/*.env
do
docker run --rm --env-file $file -v $(pwd)/responses:/mono/monitor/responses monitor_monitor /bin/bash -c 'yarn check-all'
docker run --rm --env-file $file -v $(pwd)/responses:/mono/monitor/responses poanetwork/tokenbridge-monitor:latest /bin/bash -c 'yarn check-all'
done
else
echo "Monitor is not running, skipping checks."