From bce1e6509e37d30cff5ee02eea280e35ea515205 Mon Sep 17 00:00:00 2001 From: Gerardo Nardelli Date: Tue, 4 Feb 2020 02:16:27 -0300 Subject: [PATCH] Use monitor docker hub image for monitor deployment (#284) --- deployment/roles/monitor/meta/main.yml | 2 +- deployment/roles/monitor/tasks/jumpbox.yml | 4 +-- deployment/roles/monitor/tasks/pre_config.yml | 36 +++++++++++++++++++ .../roles/monitor/tasks/servinstall.yml | 1 - .../monitor/templates/tokenbridge-monitor.j2 | 14 +------- monitor/docker-compose.yml | 4 +-- monitor/scripts/getBridgeStats.sh | 2 +- 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/deployment/roles/monitor/meta/main.yml b/deployment/roles/monitor/meta/main.yml index c981746d..a3c7f2db 100644 --- a/deployment/roles/monitor/meta/main.yml +++ b/deployment/roles/monitor/meta/main.yml @@ -1,3 +1,3 @@ --- dependencies: - - { role: common, check_deployed: true, component: 'monitor' } + - { role: common, skip_repo: true, check_deployed: true, component: 'monitor' } diff --git a/deployment/roles/monitor/tasks/jumpbox.yml b/deployment/roles/monitor/tasks/jumpbox.yml index 9374257a..5e230b79 100644 --- a/deployment/roles/monitor/tasks/jumpbox.yml +++ b/deployment/roles/monitor/tasks/jumpbox.yml @@ -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" diff --git a/deployment/roles/monitor/tasks/pre_config.yml b/deployment/roles/monitor/tasks/pre_config.yml index cc76e62b..4ef7c155 100644 --- a/deployment/roles/monitor/tasks/pre_config.yml +++ b/deployment/roles/monitor/tasks/pre_config.yml @@ -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 diff --git a/deployment/roles/monitor/tasks/servinstall.yml b/deployment/roles/monitor/tasks/servinstall.yml index 888d571e..3cafae4b 100644 --- a/deployment/roles/monitor/tasks/servinstall.yml +++ b/deployment/roles/monitor/tasks/servinstall.yml @@ -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: diff --git a/deployment/roles/monitor/templates/tokenbridge-monitor.j2 b/deployment/roles/monitor/templates/tokenbridge-monitor.j2 index 7ff4b688..0198acda 100644 --- a/deployment/roles/monitor/templates/tokenbridge-monitor.j2 +++ b/deployment/roles/monitor/templates/tokenbridge-monitor.j2 @@ -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 ;; diff --git a/monitor/docker-compose.yml b/monitor/docker-compose.yml index 993c0903..8d0661e9 100644 --- a/monitor/docker-compose.yml +++ b/monitor/docker-compose.yml @@ -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 diff --git a/monitor/scripts/getBridgeStats.sh b/monitor/scripts/getBridgeStats.sh index 556c3b63..5a90b882 100755 --- a/monitor/scripts/getBridgeStats.sh +++ b/monitor/scripts/getBridgeStats.sh @@ -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."