blob: f7d823da0ef32d381ec5157aed7f6270920d55aa [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
Mark Beierl02feb8e2023-05-10 11:44:11 -040018FROM ubuntu:22.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 \
Mark Beierl02feb8e2023-05-10 11:44:11 -040028 gcc=4:11.* \
29 python3=3.10.* \
30 python3-dev=3.10.* \
31 python3-pip=22.0.* \
32 curl=7.81.* \
33 && rm -rf /var/lib/apt/lists/*
34
35#######################################################################################
garciadeblas21503ab2023-06-28 14:31:27 +020036# End of common preparation
Mike Marchetti182bd732018-09-05 09:52:42 -040037
garciadeblas2fc3deb2025-11-25 17:26:14 +010038RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
39 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
40 git \
41 && rm -rf /var/lib/apt/lists/*
42
43ARG COMMON_GERRIT_REFSPEC=master
44RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \
45 cd /tmp/osm-common && \
46 git fetch origin ${COMMON_GERRIT_REFSPEC} && \
47 git checkout FETCH_HEAD && \
48 cd - && \
49 pip install --no-cache-dir -r /tmp/osm-common/requirements.txt && \
50 pip install /tmp/osm-common
51
David Garciaa60ec732021-03-17 15:28:47 +010052ARG PYTHON3_OSM_IM_URL
53ARG PYTHON3_OSM_NBI_URL
Mike Marchetti182bd732018-09-05 09:52:42 -040054
David Garciaa60ec732021-03-17 15:28:47 +010055RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
56RUN dpkg -i ./osm_im.deb
fonsecajf404b8b2021-02-11 14:08:52 +010057
David Garciaa60ec732021-03-17 15:28:47 +010058RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
59RUN dpkg -i ./osm_nbi.deb
fonsecajf404b8b2021-02-11 14:08:52 +010060
David Garciaa60ec732021-03-17 15:28:47 +010061RUN pip3 install \
David Garciaa60ec732021-03-17 15:28:47 +010062 -r /usr/lib/python3/dist-packages/osm_im/requirements.txt \
63 -r /usr/lib/python3/dist-packages/osm_nbi/requirements.txt
fonsecajf404b8b2021-02-11 14:08:52 +010064
beierlmd7449362022-01-13 10:53:08 -050065#######################################################################################
Mark Beierl02feb8e2023-05-10 11:44:11 -040066FROM ubuntu:22.04 as FINAL
beierlmd7449362022-01-13 10:53:08 -050067
68ARG APT_PROXY
69RUN if [ ! -z $APT_PROXY ] ; then \
70 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
71 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
72 fi
fonsecajf404b8b2021-02-11 14:08:52 +010073
David Garciaa60ec732021-03-17 15:28:47 +010074RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
beierlmd7449362022-01-13 10:53:08 -050075 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
Mark Beierl02feb8e2023-05-10 11:44:11 -040076 python3-minimal=3.10.* \
garciadeblas6ba74b52021-09-23 17:43:15 +020077 && rm -rf /var/lib/apt/lists/*
fonsecajf404b8b2021-02-11 14:08:52 +010078
David Garciaa60ec732021-03-17 15:28:47 +010079COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
Mark Beierl02feb8e2023-05-10 11:44:11 -040080COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
81
82#######################################################################################
garciadeblas21503ab2023-06-28 14:31:27 +020083# End of common preparation
Mark Beierl02feb8e2023-05-10 11:44:11 -040084
85RUN rm -f /etc/apt/apt.conf.d/proxy.conf
Mike Marchetti13d76c82018-09-19 15:00:36 -040086
sousaedua8e75d02021-09-30 14:07:57 +010087# Creating the user for the app
88RUN groupadd -g 1000 appuser && \
89 useradd -u 1000 -g 1000 -d /app appuser && \
90 mkdir -p /app/osm_nbi && \
91 mkdir -p /app/storage/kafka && \
92 mkdir /app/log && \
93 chown -R appuser:appuser /app
Mike Marchetti182bd732018-09-05 09:52:42 -040094
Mike Marchetti182bd732018-09-05 09:52:42 -040095WORKDIR /app/osm_nbi
96
sousaedua8e75d02021-09-30 14:07:57 +010097# Changing the security context
98USER appuser
99
Mike Marchetti182bd732018-09-05 09:52:42 -0400100EXPOSE 9999
101
Mike Marchetti13d76c82018-09-19 15:00:36 -0400102RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
103RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
104RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
jegan0f0ab772024-10-31 08:05:07 +0000105RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/templates /app/osm_nbi/templates
Mike Marchetti13d76c82018-09-19 15:00:36 -0400106
Mike Marchetti182bd732018-09-05 09:52:42 -0400107# The following ENV can be added with "docker run -e xxx' to configure
108# server
109ENV OSMNBI_SOCKET_HOST 0.0.0.0
110ENV OSMNBI_SOCKET_PORT 9999
111# storage
112ENV OSMNBI_STORAGE_PATH /app/storage
113# database
114ENV OSMNBI_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300115ENV OSMNBI_DATABASE_URI mongodb://mongo:27017
116#ENV OSMNBI_DATABASE_HOST mongo
117#ENV OSMNBI_DATABASE_PORT 27017
118
Mike Marchetti182bd732018-09-05 09:52:42 -0400119# web
Mike Marchetti13d76c82018-09-19 15:00:36 -0400120ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public
Mike Marchetti182bd732018-09-05 09:52:42 -0400121# message
122ENV OSMNBI_MESSAGE_DRIVER kafka
123ENV OSMNBI_MESSAGE_HOST kafka
124ENV OSMNBI_MESSAGE_PORT 9092
125# logs
126ENV OSMNBI_LOG_FILE /app/log/nbi.log
127ENV OSMNBI_LOG_LEVEL DEBUG
Eduardo Sousae193dfd2018-09-21 11:37:49 +0100128# authentication
129ENV OSMNBI_AUTHENTICATION_BACKEND internal
130#ENV OSMNBI_AUTHENTICATION_BACKEND keystone
131#ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone
132#ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000
133#ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default
134#ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default
135#ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi
136#ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi
137#ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service
vijay.rbdb48022019-05-06 15:38:23 +0530138#prometheus
139ENV OSMNBI_PROMETHEUS_HOST prometheus
140ENV OSMNBI_PROMETHEUS_PORT 9090
Mike Marchetti182bd732018-09-05 09:52:42 -0400141
tierno836e9db2019-07-22 13:23:56 +0000142HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
Mike Marchetti851aac22018-09-20 10:18:01 -0400143 CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
144
Mike Marchetti182bd732018-09-05 09:52:42 -0400145# Run app.py when the container launches
tierno2c002c92019-09-13 12:57:35 +0000146CMD python3 -m osm_nbi.nbi