Fix bug 1706 - Adding non-root user to run MON 64/11264/6
authorsousaedu <eduardo.sousa@canonical.com>
Thu, 14 Oct 2021 12:37:51 +0000 (13:37 +0100)
committerbeierlm <mark.beierl@canonical.com>
Fri, 19 Nov 2021 17:44:43 +0000 (18:44 +0100)
Change-Id: I66e7cab3f4707dbe05e17749abd154e05c852888
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
docker/MON/Dockerfile
installers/docker/osm_pods/mon.yaml

index 719d633..a9b95fc 100644 (file)
@@ -67,7 +67,22 @@ COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
 COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
 COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
 
-COPY scripts/ scripts/
+COPY scripts/ /app/osm_mon/scripts/
+
+# Creating the user for the app
+RUN groupadd -g 1000 appuser && \
+    useradd -u 1000 -g 1000 -d /app appuser && \
+    mkdir -p /app/osm_mon && \
+    mkdir -p /app/storage/kafka && \
+    mkdir /app/log && \
+    chown -R appuser:appuser /app
+
+WORKDIR /app/osm_mon
+
+# Changing the security context
+USER appuser
+
+########################################################################
 
 ENV OSMMON_MESSAGE_DRIVER kafka
 ENV OSMMON_MESSAGE_HOST kafka
index 7f2ef74..dff0114 100644 (file)
@@ -64,10 +64,3 @@ spec:
         envFrom:
         - secretRef:
            name: mon-secret
-        volumeMounts:
-        - name: mon-storage
-          mountPath: /app/database
-      volumes:
-      - name: mon-storage
-        hostPath:
-         path: /var/lib/osm/osm_mon_db/_data