fix service deployment scripts 89/113289/3
authorKai <lukai@chinamobile.com>
Tue, 29 Sep 2020 03:24:41 +0000 (11:24 +0800)
committerLUKAI <lukai@chinamobile.com>
Tue, 29 Sep 2020 03:48:33 +0000 (03:48 +0000)
Issue-ID: DCAEGEN2-2258
Signed-off-by: Kai Lu <lukai@chinamobile.com>
Change-Id: I74351a6937a05d440aee2e7f322ee573956367bb

components/datalake-handler/des/Dockerfile
components/datalake-handler/des/src/assembly/init_db/scripts/db_init/15_db-adduser
components/datalake-handler/des/src/assembly/init_db/scripts/run.sh [deleted file]
components/datalake-handler/des/src/assembly/run.sh

index 4fcc7ee..e5a0af2 100644 (file)
@@ -22,30 +22,29 @@ MAINTAINER Kai Lu <lukai@chinamobile.com>
 EXPOSE 1681
 
 RUN groupadd -r datalake && useradd -r -g datalake datalake
-RUN mkdir /home/datalake/
+RUN mkdir /home/datalake/ && \
+    mkdir /home/datalake/db_init
 
-USER datalake
 WORKDIR /home/datalake
 
 #add the fat jar
-COPY target/${JAR_FILE} /home/datalake/
-COPY src/assembly/run.sh /home/datalake/
+COPY target/${JAR_FILE} .
+COPY src/assembly/run.sh .
+COPY src/assembly/init_db/db_scripts/init_db.sql .
+COPY src/assembly/init_db/db_scripts/init_db_data.sql .
 
 WORKDIR /home/datalake/db_init
 ADD src/assembly/init_db/scripts/db_init .
-USER root
-RUN chmod 0755 ./*
+
 WORKDIR /home/datalake
-COPY src/assembly/init_db/db_scripts/init_db.sql .
-COPY src/assembly/init_db/db_scripts/init_db_data.sql .
+
+RUN chmod -R 0755 ./* && \
+    chown -R datalake:datalake /home/datalake 
 
 RUN apt update && \
     apt install -y mariadb-client && \
     apt install -y curl
 
-USER datalake
-
+#USER datalake
 CMD ["sh", "run.sh"]
 
-
index 05b5c19..92d2c73 100644 (file)
@@ -24,7 +24,7 @@ fi
 
 echo "Creating datalake user" 1>/tmp/mariadb-datalake-user.log 2>&1
 
-mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -p"$MYSQL_ROOT_PASSWORD" -h "$MYSQL_HOST" -P "$MYSQL_PORT" << 'EOF' || exit 1
+mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -h "$MYSQL_HOST" -P "$MYSQL_PORT" << 'EOF' || exit 1
 CREATE USER IF NOT EXISTS 'dl';
 GRANT USAGE ON *.* TO 'dl'@'%' IDENTIFIED BY 'dl1234';
 GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE, SHOW VIEW ON `datalake`.* TO 'dl'@'%';
diff --git a/components/datalake-handler/des/src/assembly/init_db/scripts/run.sh b/components/datalake-handler/des/src/assembly/init_db/scripts/run.sh
deleted file mode 100644 (file)
index 20b4fc6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# ============LICENSE_START==========================================
-# ===================================================================
-#  Copyright (c) 2020 China Mobile.All rights reserved.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#============LICENSE_END============================================
-
-
-echo "start init db ..."
-
-/bin/run-parts /app/db_init
-
-echo "finish init db"
-
-
-curl -X PUT -H "contain-type:application/json" http://consul:8500/v1/kv/k8s-datalake -d "{\"mysql_host\": \"$MYSQL_HOST\", \"mysql_password\": \"$MYSQL_ROOT_PASSWORD\", \"mysql_port\": \"$MYSQL_PORT\", \"presto_host\": \"$PRESTO_HOST\"}"
-
index 42e6f13..decd97e 100644 (file)
@@ -15,6 +15,7 @@
 #
 # SPDX-License-Identifier: Apache-2.0
 # ============LICENSE_END=====================================================
+
 #!/bin/sh
 
 echo "start init db ..."
@@ -23,19 +24,10 @@ echo "start init db ..."
 
 echo "finish init db"
 
-cmd=`find . -regex  '\./des-[0-9]+\.[0-9]+\.[0-9]+[-SNAPSHOT]+\.jar'`
-cmd1=`find . -regex '\./des-[0-9]+\.[0-9]+\.[0-9]+\.jar'`
-cmd2=`find . -regex '\./des-[0-9]+\.[0-9]+\.[0-9]+[-execute]+\.jar'`
-cmd3=`find . -regex  '\./des-[0-9]+\.[0-9]+\.[0-9]+[-SNAPSHOT]+[-execute]+\.jar'`
+cmd=`find . -name des*-execute.jar`
 
 if [ -n "$cmd" ]; then
     java -jar "$cmd"
-elif [ -n "$cmd1" ]; then
-    java -jar "$cmd1"
-elif [ -n "$cmd2" ]; then
-    java -jar "$cmd2"
-elif [ -n "$cmd3" ]; then
-    java -jar "$cmd3"
 else
     echo "STRING is empty"
     sleep 10000