4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
17 ########################################################################
19 FROM ubuntu:20.04 as INSTALL
21 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
22 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
27 python3-setuptools=45.2.* \
30 ARG PYTHON3_OSM_COMMON_URL
31 ARG PYTHON3_OSM_IM_URL
32 ARG PYTHON3_OSM_NBI_URL
34 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
35 RUN dpkg -i ./osm_common.deb
37 RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
38 RUN dpkg -i ./osm_im.deb
40 RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
41 RUN dpkg -i ./osm_nbi.deb
44 -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
45 -r /usr/lib/python3/dist-packages/osm_im/requirements.txt \
46 -r /usr/lib/python3/dist-packages/osm_nbi/requirements.txt
48 #######################################################################################
49 FROM ubuntu:20.04 as FINAL
52 RUN if [ ! -z $APT_PROXY ] ; then \
53 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
54 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
57 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
58 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
59 python3-minimal=3.8.* \
60 && rm -rf /var/lib/apt/lists/*
62 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
63 COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
65 # Creating the user for the app
66 RUN groupadd -g 1000 appuser && \
67 useradd -u 1000 -g 1000 -d /app appuser && \
68 mkdir -p /app/osm_nbi && \
69 mkdir -p /app/storage/kafka && \
71 chown -R appuser:appuser /app
75 # Changing the security context
80 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
81 RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
82 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
84 # The following ENV can be added with "docker run -e xxx' to configure
86 ENV OSMNBI_SOCKET_HOST 0.0.0.0
87 ENV OSMNBI_SOCKET_PORT 9999
88 ENV OSMNBI_SERVER_SSL_CERTIFICATE /app/osm_nbi/http/cert.pem
89 ENV OSMNBI_SERVER_SSL_PRIVATE_KEY /app/osm_nbi/http/privkey.pem
91 ENV OSMNBI_STORAGE_PATH /app/storage
93 ENV OSMNBI_DATABASE_DRIVER mongo
94 ENV OSMNBI_DATABASE_URI mongodb://mongo:27017
95 #ENV OSMNBI_DATABASE_HOST mongo
96 #ENV OSMNBI_DATABASE_PORT 27017
99 ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public
101 ENV OSMNBI_MESSAGE_DRIVER kafka
102 ENV OSMNBI_MESSAGE_HOST kafka
103 ENV OSMNBI_MESSAGE_PORT 9092
105 ENV OSMNBI_LOG_FILE /app/log/nbi.log
106 ENV OSMNBI_LOG_LEVEL DEBUG
108 ENV OSMNBI_AUTHENTICATION_BACKEND internal
109 #ENV OSMNBI_AUTHENTICATION_BACKEND keystone
110 #ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone
111 #ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000
112 #ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default
113 #ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default
114 #ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi
115 #ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi
116 #ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service
118 ENV OSMNBI_PROMETHEUS_HOST prometheus
119 ENV OSMNBI_PROMETHEUS_PORT 9090
121 HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
122 CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
124 # Run app.py when the container launches
125 CMD python3 -m osm_nbi.nbi