From 70dc46866c2b854b1daef3cd4a684265bde4af45 Mon Sep 17 00:00:00 2001 From: Junyi Date: Tue, 9 Aug 2022 12:44:54 +0800 Subject: change application.properties $ standalone for separate postgres Issue-ID: USECASEUI-405 Signed-off-by: Junyi Du Change-Id: Icad7ec5441f71819ee27a23c2cb1b79ef8d45517 --- standalone/src/main/assembly/Dockerfile | 44 +--- .../src/main/assembly/bin/docker-env-config.sh | 39 ---- standalone/src/main/assembly/bin/run.sh | 11 +- .../src/main/assembly/resources/bin/initDB.sh | 59 ------ .../resources/dbscripts/postgres/uui_create_db.sql | 26 --- .../dbscripts/postgres/uui_create_table.sql | 224 --------------------- .../resources/dbscripts/postgres/uui_init_data.sql | 35 ---- 7 files changed, 5 insertions(+), 433 deletions(-) delete mode 100644 standalone/src/main/assembly/bin/docker-env-config.sh delete mode 100644 standalone/src/main/assembly/resources/bin/initDB.sh delete mode 100644 standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_db.sql delete mode 100644 standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql delete mode 100644 standalone/src/main/assembly/resources/dbscripts/postgres/uui_init_data.sql (limited to 'standalone/src/main') diff --git a/standalone/src/main/assembly/Dockerfile b/standalone/src/main/assembly/Dockerfile index 06c035c0..5524911f 100644 --- a/standalone/src/main/assembly/Dockerfile +++ b/standalone/src/main/assembly/Dockerfile @@ -1,45 +1,9 @@ FROM nexus3.onap.org:10001/onap/integration-java11:9.0.0 MAINTAINER "Lu Ji" -# Expose the Usecase-UI backend port and postgreSQL port +# Expose the Usecase-UI backend port EXPOSE 8082 -# set env parameters -ENV PG_HOME=/usr/share/postgresql \ - PG_VERSION=13.4 \ - PG_VAR_LIB=/var/lib/postgresql \ - PG_USR_LIB=/usr/lib/postgresql \ - PG_LOGDIR=/var/log/postgresql - -#Install PostgreSQL as user root, Common users do not have permission to perform the installation -USER root -RUN apk update && apk add postgresql && apk add bash - -# Adjust PostgreSQL configuration -RUN cp ${PG_HOME}/pg_hba.conf.sample ${PG_HOME}/pg_hba.conf && \ - echo "host all all 0.0.0.0/0 md5" >> ${PG_HOME}/pg_hba.conf && \ - cp ${PG_HOME}/postgresql.conf.sample ${PG_HOME}/postgresql.conf && \ - cp ${PG_HOME}/pg_ident.conf.sample ${PG_HOME}/pg_ident.conf && \ - echo "listen_addresses='*'" >> ${PG_HOME}/postgresql.conf && \ - echo "data_directory = '/usr/share/postgresql/data'" >> ${PG_HOME}/postgresql.conf && \ - echo "hba_file = '/usr/share/postgresql/pg_hba.conf'" >> ${PG_HOME}/postgresql.conf && \ - echo "ident_file = '/usr/share/postgresql/pg_ident.conf'" >> ${PG_HOME}/postgresql.conf && \ - mkdir ${PG_HOME}/data && \ - mkdir /run/postgresql && \ - chown -R postgres:postgres ${PG_HOME} && \ - chown -R postgres:postgres /run/postgresql - -#init databases,Use the non-root user -USER postgres -RUN initdb -D /usr/share/postgresql/data - -USER root -# Add VOLUMEs to allow backup of config, logs and databases -VOLUME ["${PG_HOME}", "${PG_VAR_LIB}", "${PG_LOGDIR}"] - -# Set the default command to run postgreSQL when starting the container -# CMD ["${PG_USR_LIB}/${PG_VERSION}/bin/postgres", "-D", "${PG_VAR_LIB}/${PG_VERSION}/main", "-c", "config_file=${PG_HOME}/${PG_VERSION}/main/postgresql.conf"] - #Configure Java SDK ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib @@ -47,8 +11,8 @@ ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib RUN mkdir /home/uui WORKDIR /home/uui ADD usecase-ui-server-*-linux64.tar.gz /home/uui/ +RUN addgroup -S uui && adduser -S uui -G uui && chown -R uui:uui /home/uui -RUN source /home/uui/bin/docker-env-config.sh -USER postgres +USER uui WORKDIR /home/uui -ENTRYPOINT /home/uui/bin/run.sh +ENTRYPOINT /home/uui/bin/run.sh \ No newline at end of file diff --git a/standalone/src/main/assembly/bin/docker-env-config.sh b/standalone/src/main/assembly/bin/docker-env-config.sh deleted file mode 100644 index 8e583b10..00000000 --- a/standalone/src/main/assembly/bin/docker-env-config.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# Copyright 2020 CMCC Corporation. -# -# 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. -# - -main_path="/home/uui" - -add_user() { - #useradd postgres - echo "add_user postgres..." - chown -R postgres:postgres $main_path -} - -modify_owner() { - dbScript="$main_path/resources/bin/initDB.sh" - chmod 755 $dbScript - chown -R postgres:postgres /var/run/postgresql - chown -R postgres:postgres $PG_HOME - chown -R postgres:postgres $PG_VAR_LIB - chown -R postgres:postgres $PG_USR_LIB - chown -R postgres:postgres $PG_LOGDIR - chmod -R 0700 $PG_HOME - echo "modify files owner..." -} - -add_user -modify_owner diff --git a/standalone/src/main/assembly/bin/run.sh b/standalone/src/main/assembly/bin/run.sh index 42249fa4..faa079ef 100644 --- a/standalone/src/main/assembly/bin/run.sh +++ b/standalone/src/main/assembly/bin/run.sh @@ -18,15 +18,6 @@ main_path="/home/uui" echo @main_path@ $main_path -echo "Starting postgreSQL..." -#service postgresql start -postmaster -D /usr/share/postgresql/data & -sleep 10 - -echo "usecase-ui database init script start..." -dbScript="$main_path/resources/bin/initDB.sh" -source $dbScript 127.0.0.1 5432 postgres uui -echo "usecase-ui database init script finished normally..." JAVA_PATH="$JAVA_HOME/bin/java" JAVA_OPTS="-Xms50m -Xmx128m" @@ -37,4 +28,4 @@ jar_path="$main_path/usecase-ui-server.jar" echo @jar_path@ $jar_path echo "Starting usecase-ui-server..." -$JAVA_PATH $JAVA_OPTS -classpath $jar_path -jar $jar_path +$JAVA_PATH $JAVA_OPTS -classpath $jar_path -jar $jar_path $SPRING_OPTS diff --git a/standalone/src/main/assembly/resources/bin/initDB.sh b/standalone/src/main/assembly/resources/bin/initDB.sh deleted file mode 100644 index ff5d4152..00000000 --- a/standalone/src/main/assembly/resources/bin/initDB.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2019 CMCC, Inc. and others. 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. -# - -echo "setting database init parameters" -main_path="/home/uui" -host=$1 -port=$2 -user_pg=$3 -user_uui=$4 - -echo "setting postgres database password" -#su - $user_pg <