d32c7120e7eff11c50978e26191c848ca63ade94
[osm/devops.git] / docker / NBI / Dockerfile
1 ##
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
19 FROM ubuntu:18.04 as INSTALL
20
21 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
22     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
23     gcc=4:7.4.0-1ubuntu2.3 \
24     python3=3.6.7-1~18.04 \
25     python3-dev=3.6.7-1~18.04 \
26     python3-setuptools=39.0.1-2 \
27     curl=7.58.0-2ubuntu3.13 && \
28     python3 -m easy_install pip==21.0.1
29
30 ARG PYTHON3_OSM_COMMON_URL
31 ARG PYTHON3_OSM_IM_URL
32 ARG PYTHON3_OSM_NBI_URL
33
34 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
35 RUN dpkg -i ./osm_common.deb
36
37 RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb
38 RUN dpkg -i ./osm_im.deb
39
40 RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb
41 RUN dpkg -i ./osm_nbi.deb
42
43 RUN 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
47
48 FROM ubuntu:18.04 as FINAL
49
50 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
51     DEBIAN_FRONTEND=noninteractive apt-get --yes install python3-minimal=3.6.7-1~18.04
52
53 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
54 COPY --from=INSTALL /usr/local/lib/python3.6/dist-packages  /usr/local/lib/python3.6/dist-packages
55
56 RUN mkdir -p /app/storage/kafka && mkdir -p /app/log
57
58 WORKDIR /app/osm_nbi
59
60 EXPOSE 9999
61
62 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public
63 RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/
64 RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/
65
66 # Used for local storage
67 VOLUME /app/storage
68 # Used for logs
69 VOLUME /app/log
70
71 # The following ENV can be added with "docker run -e xxx' to configure
72 # server
73 ENV OSMNBI_SOCKET_HOST     0.0.0.0
74 ENV OSMNBI_SOCKET_PORT     9999
75 ENV OSMNBI_SERVER_SSL_CERTIFICATE               /app/osm_nbi/http/cert.pem
76 ENV OSMNBI_SERVER_SSL_PRIVATE_KEY               /app/osm_nbi/http/privkey.pem
77 # storage
78 ENV OSMNBI_STORAGE_PATH    /app/storage
79 # database
80 ENV OSMNBI_DATABASE_DRIVER mongo
81 ENV OSMNBI_DATABASE_URI   mongodb://mongo:27017
82 #ENV OSMNBI_DATABASE_HOST   mongo
83 #ENV OSMNBI_DATABASE_PORT   27017
84
85 # web
86 ENV OSMNBI_STATIC_DIR      /app/osm_nbi/html_public
87 # message
88 ENV OSMNBI_MESSAGE_DRIVER  kafka
89 ENV OSMNBI_MESSAGE_HOST    kafka
90 ENV OSMNBI_MESSAGE_PORT    9092
91 # logs
92 ENV OSMNBI_LOG_FILE        /app/log/nbi.log
93 ENV OSMNBI_LOG_LEVEL       DEBUG
94 # authentication
95 ENV OSMNBI_AUTHENTICATION_BACKEND               internal
96 #ENV OSMNBI_AUTHENTICATION_BACKEND               keystone
97 #ENV OSMNBI_AUTHENTICATION_AUTH_URL              keystone
98 #ENV OSMNBI_AUTHENTICATION_AUTH_PORT             5000
99 #ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME      default
100 #ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME   default
101 #ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME      nbi
102 #ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD      nbi
103 #ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT       service
104 #prometheus
105 ENV OSMNBI_PROMETHEUS_HOST                      prometheus
106 ENV OSMNBI_PROMETHEUS_PORT                      9090
107
108 HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
109   CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1
110
111 # Run app.py when the container launches
112 CMD python3 -m osm_nbi.nbi
113