From 8912db8ac35239c00559127f5a82d0ad8aac331c Mon Sep 17 00:00:00 2001
From: George Sedov <george.sedov@desy.de>
Date: Tue, 13 Jun 2023 17:30:14 +0200
Subject: [PATCH] fix standalone monitoring

---
 .gitlab-ci.yml                               | 15 ++++++++-------
 deploy/asapo_services_light/Dockerfile       |  6 ++++++
 deploy/asapo_services_light/monitoring.json  |  2 +-
 deploy/asapo_services_light/supervisord.conf |  9 ++++++++-
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index cdb8e71ff..90ded2514 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -330,18 +330,19 @@ build-front:
   stage: deploy
   script:
     - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
-    - cd $CI_PROJECT_DIR/build/deploy/asapo_services_light
-    - ./prepare-docker.sh
-    - /kaniko/executor --cache=false --single-snapshot --context $CI_PROJECT_DIR/build/deploy/asapo_services_light --dockerfile $CI_PROJECT_DIR/build/deploy/asapo_services_light/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-standalone${CONTAINER_TAG} --destination $CI_REGISTRY_IMAGE/asapo-standalone${CONTAINER_TAG_LATEST}
     - services="broker authorizer discovery receiver file-transfer"
     - >
       for service in $services; do
           service_dir=${service//"-"/"_"}
-          /kaniko/executor --cache=false --context $CI_PROJECT_DIR/build/${service_dir} --dockerfile $CI_PROJECT_DIR/build/${service_dir}/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-${service}${CONTAINER_TAG}
+          /kaniko/executor --cleanup --cache=false --context $CI_PROJECT_DIR/build/${service_dir} --dockerfile $CI_PROJECT_DIR/build/${service_dir}/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-${service}${CONTAINER_TAG}
       done
-    - /kaniko/executor --cache=false --context $CI_PROJECT_DIR/build/monitoring/monitoring_server --dockerfile $CI_PROJECT_DIR/monitoring/monitoring_server/docker/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-monitoring-server${CONTAINER_TAG}
-    - /kaniko/executor --cache=false --context $CI_PROJECT_DIR/monitoring/monitoring_ui --dockerfile $CI_PROJECT_DIR/monitoring/monitoring_ui/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-monitoring-ui${CONTAINER_TAG}
-    - /kaniko/executor --cache=false --context $CI_PROJECT_DIR/build/deploy/asapo_services --dockerfile $CI_PROJECT_DIR/build/deploy/asapo_services/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-cluster${CONTAINER_TAG} --destination $CI_REGISTRY_IMAGE/asapo-cluster${CONTAINER_TAG_LATEST}
+    - /kaniko/executor --cleanup --cache=false --context $CI_PROJECT_DIR/build/monitoring/monitoring_server --dockerfile $CI_PROJECT_DIR/monitoring/monitoring_server/docker/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-monitoring-server${CONTAINER_TAG}
+    - /kaniko/executor --cleanup --cache=false --context $CI_PROJECT_DIR/monitoring/monitoring_ui --dockerfile $CI_PROJECT_DIR/monitoring/monitoring_ui/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-monitoring-ui${CONTAINER_TAG}
+    - /kaniko/executor --cleanup --cache=false --context $CI_PROJECT_DIR/build/deploy/asapo_services --dockerfile $CI_PROJECT_DIR/build/deploy/asapo_services/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-cluster${CONTAINER_TAG} --destination $CI_REGISTRY_IMAGE/asapo-cluster${CONTAINER_TAG_LATEST}
+    - cd $CI_PROJECT_DIR/build/deploy/asapo_services_light
+    - ./prepare-docker.sh
+    - /kaniko/executor --cache=false --single-snapshot --context $CI_PROJECT_DIR/build/deploy/asapo_services_light --dockerfile $CI_PROJECT_DIR/build/deploy/asapo_services_light/Dockerfile --destination $CI_REGISTRY_IMAGE/asapo-standalone${CONTAINER_TAG} --destination $CI_REGISTRY_IMAGE/asapo-standalone${CONTAINER_TAG_LATEST}
+
   tags:
     - kubernetes-executor
   dependencies:
diff --git a/deploy/asapo_services_light/Dockerfile b/deploy/asapo_services_light/Dockerfile
index 005422859..8a3b94927 100644
--- a/deploy/asapo_services_light/Dockerfile
+++ b/deploy/asapo_services_light/Dockerfile
@@ -21,13 +21,18 @@ RUN set -eux; \
 
 RUN curl -fsSL https://pgp.mongodb.com/server-6.0.pub | gpg --dearmor > /usr/share/keyrings/mongodb-server-6.0.gpg
 RUN curl -fsSL https://repos.influxdata.com/influxdata-archive_compat.key | gpg --dearmor > /usr/share/keyrings/influxdb.gpg
+RUN curl -fsSL https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key | gpg --dearmor > /usr/share/keyrings/getenvoy.gpg 
+
 
 RUN echo "deb [signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" > /etc/apt/sources.list.d/mongodb-org-6.0.list
 RUN echo "deb [signed-by=/usr/share/keyrings/influxdb.gpg] https://repos.influxdata.com/debian bullseye stable" > /etc/apt/sources.list.d/influxdb.list
+RUN echo "deb [signed-by=/usr/share/keyrings/getenvoy.gpg] https://deb.dl.getenvoy.io/public/deb/debian bullseye main" > /etc/apt/sources.list.d/getenvoy.list
+
 RUN set -eux; \
 	apt-get update; \
 	DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
 	    influxdb \
+	    getenvoy-envoy \
 	    mongodb-org; \
 	rm -rf /var/lib/apt/lists/*
 
@@ -44,6 +49,7 @@ COPY *.json /
 COPY *.key /
 
 COPY nginx.conf /etc/nginx/nginx.conf
+COPY envoy.yaml /etc/envoy/envoy.yaml
 COPY supervisord.conf /etc/
 
 COPY front-dist /usr/share/nginx/html
diff --git a/deploy/asapo_services_light/monitoring.json b/deploy/asapo_services_light/monitoring.json
index 6149979e8..ed5241dff 100644
--- a/deploy/asapo_services_light/monitoring.json
+++ b/deploy/asapo_services_light/monitoring.json
@@ -1,6 +1,6 @@
 {
     "ThisClusterName": "asapo",
-    "ServerPort": 8420,
+    "ServerPort": 8422,
     "LogLevel": "debug",
     "InfluxDbUrl":"http://localhost:8400/influxdb",
     "InfluxDbDatabase": "asapo_monitoring"
diff --git a/deploy/asapo_services_light/supervisord.conf b/deploy/asapo_services_light/supervisord.conf
index 7ab869306..51e1371c9 100644
--- a/deploy/asapo_services_light/supervisord.conf
+++ b/deploy/asapo_services_light/supervisord.conf
@@ -5,7 +5,7 @@ logfile_maxbytes=50MB                           ; maximum size of logfile before
 logfile_backups=10                              ; number of backed up logfiles
 loglevel=info                                   ; info, debug, warn, trace
 childlogdir=/var/log/supervisord/               ; where child log files will live
-use=root
+user=root
 
 [program:mongo]
 command=/usr/bin/mongod --bind_ip_all --dbpath /var/lib/mongodb/
@@ -70,3 +70,10 @@ stderr_logfile=/tmp/monitoring_err.log
 stderr_logfile_maxbytes = 0
 stdout_logfile=/tmp/monitoring_out.log
 stdout_logfile_maxbytes = 0
+
+[program:envoyproxy]
+command=envoy -c /etc/envoy/envoy.yaml
+stderr_logfile=/tmp/envoy_err.log
+stderr_logfile_maxbytes = 0
+stdout_logfile=/tmp/envoy_out.log
+stdout_logfile_maxbytes = 0
-- 
GitLab