From 175d40f9f66838825208cd213b53de207294694b Mon Sep 17 00:00:00 2001 From: yangyan Date: Wed, 4 Mar 2020 10:41:23 +0800 Subject: Change svnfm of huawei pod startup to non root Change-Id: Iafe6f0dee6f89a34a76b403d4ded0f5d8e03f744 Issue-ID: VFC-1637 Signed-off-by: yangyan --- .../VnfmadapterService/docker/Dockerfile | 56 ++------------------- .../VnfmadapterService/docker/docker-env-config.sh | 57 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 52 deletions(-) create mode 100644 huawei/vnfmadapter/VnfmadapterService/docker/docker-env-config.sh (limited to 'huawei/vnfmadapter') diff --git a/huawei/vnfmadapter/VnfmadapterService/docker/Dockerfile b/huawei/vnfmadapter/VnfmadapterService/docker/Dockerfile index 56b9c30a..a257f9e5 100644 --- a/huawei/vnfmadapter/VnfmadapterService/docker/Dockerfile +++ b/huawei/vnfmadapter/VnfmadapterService/docker/Dockerfile @@ -1,62 +1,14 @@ -# -# This file was auto-generated by gen-all-dockerfiles.sh; do not modify manually. -# -# nfvo-driver-vnfm-huawei/target/Dockerfile -# - -# 10-basebuild.txt - FROM centos:7 ARG PKG_VERSION - -RUN sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf -RUN sed -i 's|#baseurl=http://mirror.centos.org/centos|baseurl=http://mirrors.ocf.berkeley.edu/centos|' /etc/yum.repos.d/*.repo -RUN yum update -y - -RUN yum install -y wget unzip socat java-1.8.0-openjdk-headless -RUN sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/jre/lib/security/java.security ENV JAVA_HOME /usr/lib/jvm/jre - +ENV CATALINA_HOME /service +ADD . /service WORKDIR /service - -# 20-mysq.txt - -# Set up mysql -RUN wget -q http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm && rpm -ivh mysql-community-release-el7-5.noarch.rpm && rm -f mysql-community-release-el7-5.noarch.rpm -RUN yum -y update -RUN yum -y install -y mysql-server -RUN mysql_install_db --user=mysql --datadir=/var/lib/mysql - +RUN bash docker-env-config.sh VOLUME /var/lib/mysql -COPY init-mysql.sh . -# 30-tomcat.txt - AUTOGENERATED, DO NOT MODIFY MANUALLY -# Set up tomcat -RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz && tar --strip-components=1 -xf apache-tomcat-8.5.30.tar.gz && rm -f apache-tomcat-8.5.30.tar.gz && rm -rf webapps && mkdir -p webapps/ROOT -RUN echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh -ENV CATALINA_HOME /service - -# 50-microservice.txt - AUTOGENERATED, DO NOT MODIFY MANUALLY - -# Set up microservice - -RUN wget -q -O nfvo-driver-vnfm-huawei.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.huawei.vnfmadapter&a=hw-vnfmadapter-deployment&v=${PKG_VERSION}-SNAPSHOT&e=zip" && unzip -q -o -B nfvo-driver-vnfm-huawei.zip && rm -f nfvo-driver-vnfm-huawei.zip -# Set permissions -RUN find . -type d -exec chmod o-w {} \; -RUN find . -name "*.sh" -exec chmod +x {} \; EXPOSE 8482 - -# 90-entrypoint.txt - -RUN yum clean all - -COPY instance-config.sh . -COPY instance-init.sh . -COPY instance-run.sh . -COPY instance-workaround.sh . -COPY docker-entrypoint.sh . +USER onap ENTRYPOINT /service/docker-entrypoint.sh - -COPY LICENSE ./ONAP_LICENSE diff --git a/huawei/vnfmadapter/VnfmadapterService/docker/docker-env-config.sh b/huawei/vnfmadapter/VnfmadapterService/docker/docker-env-config.sh new file mode 100644 index 00000000..1fd6e5fc --- /dev/null +++ b/huawei/vnfmadapter/VnfmadapterService/docker/docker-env-config.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +install_sf(){ + + sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf + sed -i 's|#baseurl=http://mirror.centos.org/centos|baseurl=http://mirrors.ocf.berkeley.edu/centos|' /etc/yum.repos.d/*.repo + yum -y update + + yum -y install wget unzip socat java-1.8.0-openjdk-headless + sed -i 's|#networkaddress.cache.ttl=-1|networkaddress.cache.ttl=10|' /usr/lib/jvm/jre/lib/security/java.security + + # Set up mysql + wget -q http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm && \ + rpm -ivh mysql-community-release-el7-5.noarch.rpm && \ + rm -f mysql-community-release-el7-5.noarch.rpm + yum -y update + yum -y install mysql-server + mysql_install_db --user=mysql --datadir=/var/lib/mysql + + # Set up tomcat + wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz && \ + tar --strip-components=1 -xf apache-tomcat-8.5.30.tar.gz && \ + rm -f apache-tomcat-8.5.30.tar.gz && \ + rm -rf webapps && \ + mkdir -p webapps/ROOT + echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh + + # Set up microservice + wget -q -O nfvo-driver-vnfm-huawei.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.vfc.nfvo.driver.vnfm.svnfm.hu +awei.vnfmadapter&a=hw-vnfmadapter-deployment&v=${PKG_VERSION}-SNAPSHOT&e=zip" && \ + unzip -q -o -B nfvo-driver-vnfm-huawei.zip && \ + rm -f nfvo-driver-vnfm-huawei.zip + + # Set permissions + find . -type d -exec chmod o-w {} \; + find . -name "*.sh" -exec chmod +x {} \; +} + +add_user(){ + + useradd onap + yum -y install sudo + chmod u+x /etc/sudoers + sed -i '/Same thing without a password/a\onap ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers + chmod u-x /etc/sudoers + chown onap:onap -R /service +} + +clean_sf_cache(){ + + yum clean all +} + +install_sf +wait +add_user +clean_sf_cache -- cgit 1.2.3-korg