Move lcm certificate to lcm folder in OSM helm chart
[osm/devops.git] / docker / MON / Dockerfile
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
4 # 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
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,
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 #######################################################################################
17
18 FROM ubuntu:22.04 as INSTALL
19
20 ARG APT_PROXY
21 RUN 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
26 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
28     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 #######################################################################################
36 # End of common preparation
37
38 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
39     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
40     openssh-client=1:8.*
41
42 ARG PYTHON3_OSM_COMMON_URL
43 ARG PYTHON3_OSM_MON_URL
44 ARG PYTHON3_N2VC_URL
45
46 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
47 RUN dpkg -i ./osm_common.deb
48
49 RUN curl $PYTHON3_N2VC_URL -o n2vc.deb
50 RUN dpkg -i ./n2vc.deb
51
52 RUN curl $PYTHON3_OSM_MON_URL -o osm_mon.deb
53 RUN dpkg -i ./osm_mon.deb
54
55 RUN pip3 install \
56     -r /usr/lib/python3/dist-packages/n2vc/requirements.txt \
57     -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
58     -r /usr/lib/python3/dist-packages/osm_mon/requirements.txt
59
60 #######################################################################################
61 #######################################################################################
62 FROM ubuntu:22.04 as FINAL
63
64 ARG APT_PROXY
65 RUN if [ ! -z $APT_PROXY ] ; then \
66     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
67     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
68     fi
69
70 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
71     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
72     python3-minimal=3.10.* \
73     && rm -rf /var/lib/apt/lists/*
74
75 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
76 COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages  /usr/local/lib/python3.10/dist-packages
77
78 #######################################################################################
79 # End of common preparation
80
81 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
82     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
83     ca-certificates \
84     && rm -rf /var/lib/apt/lists/*
85
86 RUN rm -f /etc/apt/apt.conf.d/proxy.conf
87
88 COPY --from=INSTALL /usr/bin/osm* /usr/bin/
89 COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
90 COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
91 COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
92 COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
93 COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
94
95 COPY scripts/ /app/osm_mon/scripts/
96
97 # Creating the user for the app
98 RUN groupadd -g 1000 appuser && \
99     useradd -u 1000 -g 1000 -d /app appuser && \
100     mkdir -p /app/osm_mon && \
101     mkdir -p /app/storage/kafka && \
102     mkdir /app/log && \
103     chown -R appuser:appuser /app
104
105 WORKDIR /app/osm_mon
106
107 # Changing the security context
108 USER appuser
109
110 ########################################################################
111
112 ENV OSMMON_MESSAGE_DRIVER kafka
113 ENV OSMMON_MESSAGE_HOST kafka
114 ENV OSMMON_MESSAGE_PORT 9092
115
116 ENV OSMMON_DATABASE_DRIVER mongo
117 ENV OSMMON_DATABASE_URI mongodb://mongo:27017
118
119 ENV OSMMON_SQL_DATABASE_URI sqlite:///mon_sqlite.db
120 ENV OSMMON_OPENSTACK_DEFAULT_GRANULARITY 300
121 ENV OSMMON_GLOBAL_REQUEST_TIMEOUT 10
122 ENV OSMMON_GLOBAL_LOGLEVEL INFO
123 ENV OSMMON_VCA_HOST localhost
124 ENV OSMMON_VCA_SECRET secret
125 ENV OSMMON_VCA_USER admin
126 ENV OSMMON_VCA_CACERT cacert
127 ENV OSMMON_DATABASE_COMMONKEY changeme
128 ENV OSMMON_COLLECTOR_INTERVAL 30
129 ENV OSMMON_EVALUATOR_INTERVAL 30
130 ENV OSMMON_PROMETHEUS_URL http://prometheus:9090
131 ENV OSMMON_GRAFANA_URL http://grafana:3000
132 ENV OSMMON_GRAFANA_USER admin
133 ENV OSMMON_GRAFANA_PASSWORD admin
134
135 EXPOSE 8000
136
137 HEALTHCHECK --start-period=120s --interval=5s --timeout=2s --retries=12\
138   CMD osm-mon-healthcheck || exit 1
139
140 CMD /bin/bash scripts/start.sh