From 2b484d866c4f6da6aa9caaed201923e52faab2d2 Mon Sep 17 00:00:00 2001 From: hekeguang Date: Tue, 7 Sep 2021 10:10:45 +0800 Subject: UUI needs to use integration-java 11:9.0.0 image. Issue-ID: USECASEUI-604 Change-Id: Ic1f04b1a5c98a5d460fc2abe08c8cbe14575164c Signed-off-by: hekeguang --- standalone/src/main/assembly/Dockerfile | 55 ++++++++++------------ .../src/main/assembly/bin/docker-env-config.sh | 3 +- standalone/src/main/assembly/bin/run.sh | 5 +- standalone/src/main/assembly/bin/stop.sh | 2 +- .../src/main/assembly/resources/bin/initDB.sh | 2 +- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/standalone/src/main/assembly/Dockerfile b/standalone/src/main/assembly/Dockerfile index 68062b39..81e1e944 100644 --- a/standalone/src/main/assembly/Dockerfile +++ b/standalone/src/main/assembly/Dockerfile @@ -1,40 +1,39 @@ -FROM nexus3.onap.org:10001/ubuntu:20.04 +FROM nexus3.onap.org:10001/onap/integration-java11:9.0.0 MAINTAINER "Lu Ji" # Expose the Usecase-UI backend port and postgreSQL port EXPOSE 8082 # set env parameters -ENV PG_HOME=/etc/postgresql \ - PG_VERSION=9.5 \ +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 -# Add the PostgreSQL PGP key to verify their Debian packages -RUN apt -y update && apt -y install gnupg && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 -# Add PostgreSQL's repository -RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list - -# Update the Ubuntu and install tools -RUN apt-get update && \ -# apt-get install -y python-software-properties && \ - apt-get install -y software-properties-common && \ - add-apt-repository -y ppa:openjdk-r/ppa && \ - apt-get update && \ - apt-get install -y openjdk-11-jdk && \ - apt-get install -y gcc && \ - apt-get install -y curl && \ - apt-get install -y vim && \ - apt-get install -y build-essential && \ - apt-get install -y libssl-dev && \ - apt-get install -y libffi-dev && \ - apt-get -y -q install postgresql-${PG_VERSION} postgresql-client-${PG_VERSION} postgresql-contrib-${PG_VERSION} +#Install PostgreSQL as user root, Common users do not have permission to perform the installation +USER root +RUN apk update && apk add postgresql # Adjust PostgreSQL configuration -RUN echo "host all all 0.0.0.0/0 md5" >> ${PG_HOME}/${PG_VERSION}/main/pg_hba.conf -RUN echo "listen_addresses='*'" >> ${PG_HOME}/${PG_VERSION}/main/postgresql.conf - +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}"] @@ -42,18 +41,14 @@ VOLUME ["${PG_HOME}", "${PG_VAR_LIB}", "${PG_LOGDIR}"] # 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 -RUN sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/java-11-*/conf/security/java.security -ENV JAVA_HOME /usr/lib/jvm/java-11-* -ENV PATH $PATH:/usr/lib/jvm/java-11-*/bin ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib -ENV JRE_HOME ${JAVA_HOME}/jre #Add Usecase-UI server related resources to the docker image RUN mkdir /home/uui WORKDIR /home/uui ADD usecase-ui-server-*-linux64.tar.gz /home/uui/ -RUN bash /home/uui/bin/docker-env-config.sh +RUN source /home/uui/bin/docker-env-config.sh USER postgres WORKDIR /home/uui ENTRYPOINT /home/uui/bin/run.sh diff --git a/standalone/src/main/assembly/bin/docker-env-config.sh b/standalone/src/main/assembly/bin/docker-env-config.sh index 04559ba3..8e583b10 100644 --- a/standalone/src/main/assembly/bin/docker-env-config.sh +++ b/standalone/src/main/assembly/bin/docker-env-config.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright 2020 CMCC Corporation. # @@ -31,6 +31,7 @@ modify_owner() { 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..." } diff --git a/standalone/src/main/assembly/bin/run.sh b/standalone/src/main/assembly/bin/run.sh index bb0789b9..42249fa4 100644 --- a/standalone/src/main/assembly/bin/run.sh +++ b/standalone/src/main/assembly/bin/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright 2016-2017 ZTE Corporation. # @@ -19,7 +19,8 @@ main_path="/home/uui" echo @main_path@ $main_path echo "Starting postgreSQL..." -service postgresql start +#service postgresql start +postmaster -D /usr/share/postgresql/data & sleep 10 echo "usecase-ui database init script start..." diff --git a/standalone/src/main/assembly/bin/stop.sh b/standalone/src/main/assembly/bin/stop.sh index 598f976b..10b4d550 100644 --- a/standalone/src/main/assembly/bin/stop.sh +++ b/standalone/src/main/assembly/bin/stop.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright 2018 CMCC Corporation. # diff --git a/standalone/src/main/assembly/resources/bin/initDB.sh b/standalone/src/main/assembly/resources/bin/initDB.sh index cdfa4b5c..ff5d4152 100644 --- a/standalone/src/main/assembly/resources/bin/initDB.sh +++ b/standalone/src/main/assembly/resources/bin/initDB.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright (C) 2019 CMCC, Inc. and others. All rights reserved. # -- cgit 1.2.3-korg