Merge "Code Improvements-Vnfsdk-refrepo sonar issue fixes"
[vnfsdk/refrepo.git] / vnfmarket-be / deployment / docker / docker-refrepo / src / main / docker / Dockerfile
1 # Copyright 2020 Huawei Technologies Co., Ltd.
2 # Copyright 2020 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # vnf-sdk-marketplace/target/Dockerfile
17 #
18
19 # 10-basebuild.txt
20
21 FROM ubuntu:20.04
22 ARG DEBIAN_FRONTEND=noninteractive
23
24 ENV JAVA_VERSION_MAJOR=11 \
25     JAVA_VERSION_MINOR=08 \
26     JAVA_HOME=/usr/lib/jvm/default-jvm \
27     PATH=${PATH}:/usr/lib/jvm/default-jvm/bin/ \
28     CATALINA_HOME=/service
29
30 # Install required libraries
31 RUN apt-get update && apt-get install -y \
32     curl \
33     g++ \
34     make \
35     nano \
36     nginx \
37     nodejs \
38     npm \
39     software-properties-common \
40     sudo \
41     unzip \
42     wget \
43  && rm -rf /var/lib/apt/lists/*
44
45 # Install Java
46 WORKDIR /service
47 RUN add-apt-repository ppa:openjdk-r/ppa -y && \
48     # update data from repositories
49     apt-get update && \
50     # Make info file about this build
51     printf "Build of java:openjdk-11-jre-headless, date: %s\n"  `date -u +"%Y-%m-%dT%H:%M:%SZ"` > /service/java && \
52     # install application
53     apt-get install -y --no-install-recommends openjdk-11-jre-headless && \
54     # fix default setting
55     ln -s java-11-openjdk-amd64  /usr/lib/jvm/default-jvm && \
56     # remove apt cache from image
57     apt-get clean all && \
58     rm -rf /var/lib/apt/lists/*
59
60 # Download and set up Tomcat
61 WORKDIR /service
62 RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.30/bin/apache-tomcat-8.5.30.tar.gz && \
63     tar --strip-components=1 -xf apache-tomcat-8.5.30.tar.gz && \
64     rm -f apache-tomcat-8.5.30.tar.gz && rm -rf webapps && mkdir -p webapps/ROOT && \
65     echo 'export CATALINA_OPTS="$CATALINA_OPTS -Xms64m -Xmx256m -XX:MaxPermSize=64m"' > /service/bin/setenv.sh
66
67 # Copy artifacts
68 WORKDIR /service
69 COPY nginx.conf /etc/nginx/nginx.conf
70 COPY certgen.sh /service
71 COPY instance-config.sh .
72 COPY instance-init.sh .
73 COPY instance-run.sh .
74 COPY instance-workaround.sh .
75 COPY docker-entrypoint.sh .
76 COPY install-vtp.sh .
77 COPY vtp-tc.sh .
78 COPY LICENSE ./ONAP_LICENSE
79
80 # Configure NGINX
81 RUN mkdir -p /etc/nginx/ssl && \
82     chown -R www-data:www-data /var/lib/nginx
83
84 # Generate certificates
85 RUN chmod +x /service/certgen.sh  && \
86     /service/certgen.sh
87
88 # Set up microservice
89 ADD ./STAGE  /service
90 RUN chmod +x /service/bin/*.sh && \
91     cd /service/webapps/onapui/vnfmarket && \
92     npm install phantomjs-prebuilt@2.1.14 --ignore-scripts && \
93     npm install
94
95 # VTP setup
96 RUN chmod a+x /service/install-vtp.sh && \
97     chmod a+x /service/vtp-tc.sh && \
98     /service/install-vtp.sh
99
100 # Create group and user
101 RUN groupadd -r vnfadmin && useradd -m --no-log-init -r -g vnfadmin vnfadmin && \
102     usermod -aG sudo vnfadmin && echo "vnfadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
103     chmod -R 777 /usr/local/
104
105 USER vnfadmin
106
107 # Define mountable directories.
108 VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx", "/var/www/html"]
109
110 EXPOSE 8702
111 EXPOSE 8703
112 EXPOSE 50051
113
114 ENTRYPOINT ["/service/docker-entrypoint.sh"]