blob: 895747914e74dc54c619eddb462e8c134581a039 [file] [log] [blame]
beierlme7646252022-01-13 10:53:08 -05001#######################################################################################
2# Copyright ETSI Contributors and Others.
calvinosanchbfb77902019-07-31 13:31:16 +00003#
beierlme7646252022-01-13 10:53:08 -05004# 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
calvinosanchbfb77902019-07-31 13:31:16 +00007#
beierlme7646252022-01-13 10:53:08 -05008# http://www.apache.org/licenses/LICENSE-2.0
calvinosanchbfb77902019-07-31 13:31:16 +00009#
10# Unless required by applicable law or agreed to in writing, software
beierlme7646252022-01-13 10:53:08 -050011# 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#######################################################################################
calvinosanchbfb77902019-07-31 13:31:16 +000017
beierlmd7449362022-01-13 10:53:08 -050018FROM ubuntu:20.04 as INSTALL
Mike Marchetti182bd732018-09-05 09:52:42 -040019
beierlme7646252022-01-13 10:53:08 -050020ARG APT_PROXY
21RUN 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
David Garciaa60ec732021-03-17 15:28:47 +010026RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlmd7449362022-01-13 10:53:08 -050028 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.*
Mike Marchetti182bd732018-09-05 09:52:42 -040034
David Garciaa60ec732021-03-17 15:28:47 +010035ARG PYTHON3_OSM_COMMON_URL
36ARG PYTHON3_OSM_IM_URL
37ARG PYTHON3_OSM_NBI_URL
Mike Marchetti182bd732018-09-05 09:52:42 -040038
David Garciaa60ec732021-03-17 15:28:47 +010039RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
40RUN dpkg -i ./osm_common.deb
fonsecajf404b8b2021-02-11 14:08:52 +010041
David Garciaa60ec732021-03-17 15:28:47 +010042RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
43RUN dpkg -i ./osm_im.deb
fonsecajf404b8b2021-02-11 14:08:52 +010044
David Garciaa60ec732021-03-17 15:28:47 +010045RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
46RUN dpkg -i ./osm_nbi.deb
fonsecajf404b8b2021-02-11 14:08:52 +010047
David Garciaa60ec732021-03-17 15:28:47 +010048RUN 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
fonsecajf404b8b2021-02-11 14:08:52 +010052
beierlmd7449362022-01-13 10:53:08 -050053#######################################################################################
54FROM ubuntu:20.04 as FINAL
55
56ARG APT_PROXY
57RUN 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
fonsecajf404b8b2021-02-11 14:08:52 +010061
David Garciaa60ec732021-03-17 15:28:47 +010062RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
beierlmd7449362022-01-13 10:53:08 -050063 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
64 python3-minimal=3.8.* \
garciadeblas6ba74b52021-09-23 17:43:15 +020065 && rm -rf /var/lib/apt/lists/*
fonsecajf404b8b2021-02-11 14:08:52 +010066
Mark Beierle5b9ba62022-09-08 05:44:06 -040067RUN rm -f /etc/apt/apt.conf.d/proxy.conf
68
David Garciaa60ec732021-03-17 15:28:47 +010069COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
beierlmd7449362022-01-13 10:53:08 -050070COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
Mike Marchetti13d76c82018-09-19 15:00:36 -040071
sousaedua8e75d02021-09-30 14:07:57 +010072# Creating the user for the app
73RUN groupadd -g 1000 appuser && \
74 useradd -u 1000 -g 1000 -d /app appuser && \
75 mkdir -p /app/osm_nbi && \
76 mkdir -p /app/storage/kafka && \
77 mkdir /app/log && \
78 chown -R appuser:appuser /app
Mike Marchetti182bd732018-09-05 09:52:42 -040079
Mike Marchetti182bd732018-09-05 09:52:42 -040080WORKDIR /app/osm_nbi
81
sousaedua8e75d02021-09-30 14:07:57 +010082# Changing the security context
83USER appuser
84
Mike Marchetti182bd732018-09-05 09:52:42 -040085EXPOSE 9999
86
Mike Marchetti13d76c82018-09-19 15:00:36 -040087RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
88RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
89RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
90
Mike Marchetti182bd732018-09-05 09:52:42 -040091# The following ENV can be added with "docker run -e xxx' to configure
92# server
93ENV OSMNBI_SOCKET_HOST 0.0.0.0
94ENV OSMNBI_SOCKET_PORT 9999
tierno2c002c92019-09-13 12:57:35 +000095ENV OSMNBI_SERVER_SSL_CERTIFICATE /app/osm_nbi/http/cert.pem
96ENV OSMNBI_SERVER_SSL_PRIVATE_KEY /app/osm_nbi/http/privkey.pem
Mike Marchetti182bd732018-09-05 09:52:42 -040097# storage
98ENV OSMNBI_STORAGE_PATH /app/storage
99# database
100ENV OSMNBI_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300101ENV OSMNBI_DATABASE_URI mongodb://mongo:27017
102#ENV OSMNBI_DATABASE_HOST mongo
103#ENV OSMNBI_DATABASE_PORT 27017
104
Mike Marchetti182bd732018-09-05 09:52:42 -0400105# web
Mike Marchetti13d76c82018-09-19 15:00:36 -0400106ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public
Mike Marchetti182bd732018-09-05 09:52:42 -0400107# message
108ENV OSMNBI_MESSAGE_DRIVER kafka
109ENV OSMNBI_MESSAGE_HOST kafka
110ENV OSMNBI_MESSAGE_PORT 9092
111# logs
112ENV OSMNBI_LOG_FILE /app/log/nbi.log
113ENV OSMNBI_LOG_LEVEL DEBUG
Eduardo Sousae193dfd2018-09-21 11:37:49 +0100114# authentication
115ENV OSMNBI_AUTHENTICATION_BACKEND internal
116#ENV OSMNBI_AUTHENTICATION_BACKEND keystone
117#ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone
118#ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000
119#ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default
120#ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default
121#ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi
122#ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi
123#ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service
vijay.rbdb48022019-05-06 15:38:23 +0530124#prometheus
125ENV OSMNBI_PROMETHEUS_HOST prometheus
126ENV OSMNBI_PROMETHEUS_PORT 9090
Mike Marchetti182bd732018-09-05 09:52:42 -0400127
tierno836e9db2019-07-22 13:23:56 +0000128HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
Mike Marchetti851aac22018-09-20 10:18:01 -0400129 CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
130
Mike Marchetti182bd732018-09-05 09:52:42 -0400131# Run app.py when the container launches
tierno2c002c92019-09-13 12:57:35 +0000132CMD python3 -m osm_nbi.nbi