blob: f128f7355c8c21b7edbfa3ccc31ea3ad4f11708f [file] [log] [blame]
calvinosanchbfb77902019-07-31 13:31:16 +00001##
2# Copyright 2019 ETSI
3#
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
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, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15##
16
17########################################################################
18
beierlm5a6d1122022-01-26 10:18:21 -050019FROM ubuntu:20.04 as INSTALL
Mike Marchetti182bd732018-09-05 09:52:42 -040020
David Garciaa60ec732021-03-17 15:28:47 +010021RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
22 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlm5a6d1122022-01-26 10:18:21 -050023 gcc=4:9.3.* \
24 python3=3.8.* \
25 python3-dev=3.8.* \
26 python3-pip=20.0.2* \
27 python3-setuptools=45.2.* \
28 curl=7.68.*
Mike Marchetti182bd732018-09-05 09:52:42 -040029
David Garciaa60ec732021-03-17 15:28:47 +010030ARG PYTHON3_OSM_COMMON_URL
31ARG PYTHON3_OSM_IM_URL
32ARG PYTHON3_OSM_NBI_URL
Mike Marchetti182bd732018-09-05 09:52:42 -040033
David Garciaa60ec732021-03-17 15:28:47 +010034RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
35RUN dpkg -i ./osm_common.deb
fonsecajf404b8b2021-02-11 14:08:52 +010036
David Garciaa60ec732021-03-17 15:28:47 +010037RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
38RUN dpkg -i ./osm_im.deb
fonsecajf404b8b2021-02-11 14:08:52 +010039
David Garciaa60ec732021-03-17 15:28:47 +010040RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
41RUN dpkg -i ./osm_nbi.deb
fonsecajf404b8b2021-02-11 14:08:52 +010042
David Garciaa60ec732021-03-17 15:28:47 +010043RUN pip3 install \
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
fonsecajf404b8b2021-02-11 14:08:52 +010047
beierlm5a6d1122022-01-26 10:18:21 -050048#######################################################################################
49FROM ubuntu:20.04 as FINAL
50
51ARG APT_PROXY
52RUN 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 ;\
55 fi
fonsecajf404b8b2021-02-11 14:08:52 +010056
David Garciaa60ec732021-03-17 15:28:47 +010057RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
beierlm5a6d1122022-01-26 10:18:21 -050058 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
59 python3-minimal=3.8.* \
garciadeblasd992a952021-09-23 17:43:15 +020060 && rm -rf /var/lib/apt/lists/*
fonsecajf404b8b2021-02-11 14:08:52 +010061
David Garciaa60ec732021-03-17 15:28:47 +010062COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
beierlm5a6d1122022-01-26 10:18:21 -050063COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
Mike Marchetti13d76c82018-09-19 15:00:36 -040064
beierlme259b322022-02-15 11:30:56 -050065# Creating the user for the app
66RUN 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 && \
70 mkdir /app/log && \
71 chown -R appuser:appuser /app
Mike Marchetti182bd732018-09-05 09:52:42 -040072
Mike Marchetti182bd732018-09-05 09:52:42 -040073WORKDIR /app/osm_nbi
74
beierlme259b322022-02-15 11:30:56 -050075# Changing the security context
76USER appuser
77
Mike Marchetti182bd732018-09-05 09:52:42 -040078EXPOSE 9999
79
Mike Marchetti13d76c82018-09-19 15:00:36 -040080RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
81RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
82RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
83
Mike Marchetti182bd732018-09-05 09:52:42 -040084# The following ENV can be added with "docker run -e xxx' to configure
85# server
86ENV OSMNBI_SOCKET_HOST 0.0.0.0
87ENV OSMNBI_SOCKET_PORT 9999
tierno2c002c92019-09-13 12:57:35 +000088ENV OSMNBI_SERVER_SSL_CERTIFICATE /app/osm_nbi/http/cert.pem
89ENV OSMNBI_SERVER_SSL_PRIVATE_KEY /app/osm_nbi/http/privkey.pem
Mike Marchetti182bd732018-09-05 09:52:42 -040090# storage
91ENV OSMNBI_STORAGE_PATH /app/storage
92# database
93ENV OSMNBI_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -030094ENV OSMNBI_DATABASE_URI mongodb://mongo:27017
95#ENV OSMNBI_DATABASE_HOST mongo
96#ENV OSMNBI_DATABASE_PORT 27017
97
Mike Marchetti182bd732018-09-05 09:52:42 -040098# web
Mike Marchetti13d76c82018-09-19 15:00:36 -040099ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public
Mike Marchetti182bd732018-09-05 09:52:42 -0400100# message
101ENV OSMNBI_MESSAGE_DRIVER kafka
102ENV OSMNBI_MESSAGE_HOST kafka
103ENV OSMNBI_MESSAGE_PORT 9092
104# logs
105ENV OSMNBI_LOG_FILE /app/log/nbi.log
106ENV OSMNBI_LOG_LEVEL DEBUG
Eduardo Sousae193dfd2018-09-21 11:37:49 +0100107# authentication
108ENV 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
vijay.rbdb48022019-05-06 15:38:23 +0530117#prometheus
118ENV OSMNBI_PROMETHEUS_HOST prometheus
119ENV OSMNBI_PROMETHEUS_PORT 9090
Mike Marchetti182bd732018-09-05 09:52:42 -0400120
tierno836e9db2019-07-22 13:23:56 +0000121HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
Mike Marchetti851aac22018-09-20 10:18:01 -0400122 CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
123
Mike Marchetti182bd732018-09-05 09:52:42 -0400124# Run app.py when the container launches
tierno2c002c92019-09-13 12:57:35 +0000125CMD python3 -m osm_nbi.nbi