Move lcm certificate to lcm folder in OSM helm chart
[osm/devops.git] / docker / NBI / Dockerfile
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
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
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #######################################################################################
17
18 FROM ubuntu:20.04 as INSTALL
19
20 ARG APT_PROXY
21 RUN if [ ! -z $APT_PROXY ] ; then \
22     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
23     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
24     fi
25
26 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
28     gcc=4:9.3.* \
29     python3=3.8.* \
30     python3-dev=3.8.* \
31     python3-pip=20.0.2* \
32     python3-setuptools=45.2.* \
33     curl=7.68.*
34
35 ARG PYTHON3_OSM_COMMON_URL
36 ARG PYTHON3_OSM_IM_URL
37 ARG PYTHON3_OSM_NBI_URL
38
39 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
40 RUN dpkg -i ./osm_common.deb
41
42 RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
43 RUN dpkg -i ./osm_im.deb
44
45 RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
46 RUN dpkg -i ./osm_nbi.deb
47
48 RUN pip3 install \
49     -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
50     -r /usr/lib/python3/dist-packages/osm_im/requirements.txt \
51     -r /usr/lib/python3/dist-packages/osm_nbi/requirements.txt
52
53 #######################################################################################
54 FROM ubuntu:20.04 as FINAL
55
56 ARG APT_PROXY
57 RUN if [ ! -z $APT_PROXY ] ; then \
58     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
59     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
60     fi
61
62 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
63     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
64     python3-minimal=3.8.* \
65     && rm -rf /var/lib/apt/lists/*
66
67 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
68 COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages  /usr/local/lib/python3.8/dist-packages
69
70 # Creating the user for the app
71 RUN groupadd -g 1000 appuser && \
72     useradd -u 1000 -g 1000 -d /app appuser && \
73     mkdir -p /app/osm_nbi && \
74     mkdir -p /app/storage/kafka && \
75     mkdir /app/log && \
76     chown -R appuser:appuser /app
77
78 WORKDIR /app/osm_nbi
79
80 # Changing the security context
81 USER appuser
82
83 EXPOSE 9999
84
85 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
86 RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
87 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
88
89 # The following ENV can be added with "docker run -e xxx' to configure
90 # server
91 ENV OSMNBI_SOCKET_HOST     0.0.0.0
92 ENV OSMNBI_SOCKET_PORT     9999
93 ENV OSMNBI_SERVER_SSL_CERTIFICATE               /app/osm_nbi/http/cert.pem
94 ENV OSMNBI_SERVER_SSL_PRIVATE_KEY               /app/osm_nbi/http/privkey.pem
95 # storage
96 ENV OSMNBI_STORAGE_PATH    /app/storage
97 # database
98 ENV OSMNBI_DATABASE_DRIVER mongo
99 ENV OSMNBI_DATABASE_URI   mongodb://mongo:27017
100 #ENV OSMNBI_DATABASE_HOST   mongo
101 #ENV OSMNBI_DATABASE_PORT   27017
102
103 # web
104 ENV OSMNBI_STATIC_DIR      /app/osm_nbi/html_public
105 # message
106 ENV OSMNBI_MESSAGE_DRIVER  kafka
107 ENV OSMNBI_MESSAGE_HOST    kafka
108 ENV OSMNBI_MESSAGE_PORT    9092
109 # logs
110 ENV OSMNBI_LOG_FILE        /app/log/nbi.log
111 ENV OSMNBI_LOG_LEVEL       DEBUG
112 # authentication
113 ENV OSMNBI_AUTHENTICATION_BACKEND               internal
114 #ENV OSMNBI_AUTHENTICATION_BACKEND               keystone
115 #ENV OSMNBI_AUTHENTICATION_AUTH_URL              keystone
116 #ENV OSMNBI_AUTHENTICATION_AUTH_PORT             5000
117 #ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME      default
118 #ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME   default
119 #ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME      nbi
120 #ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD      nbi
121 #ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT       service
122 #prometheus
123 ENV OSMNBI_PROMETHEUS_HOST                      prometheus
124 ENV OSMNBI_PROMETHEUS_PORT                      9090
125
126 HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
127   CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
128
129 # Run app.py when the container launches
130 CMD python3 -m osm_nbi.nbi