blob: f264fba993c663b8d15f833ef70b325378fca3a1 [file] [log] [blame]
beierlme7646252022-01-13 10:53:08 -05001#######################################################################################
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#
Mike Marchetti13d76c82018-09-19 15:00:36 -040010# 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#######################################################################################
Mike Marchetti13d76c82018-09-19 15:00:36 -040017
Mark Beierl02feb8e2023-05-10 11:44:11 -040018FROM ubuntu:22.04 as INSTALL
Mike Marchetti13d76c82018-09-19 15:00:36 -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#######################################################################################
36# End of common prepration
beierlmd7449362022-01-13 10:53:08 -050037
garciadeblas10285302022-02-10 00:49:51 +010038RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
39 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlmd7449362022-01-13 10:53:08 -050040 mysql-client-core-8.0=8.0.*
Mike Marchetti13d76c82018-09-19 15:00:36 -040041
David Garciaa60ec732021-03-17 15:28:47 +010042ARG PYTHON3_OSM_COMMON_URL
43ARG PYTHON3_OSM_POLICY_MODULE_URL
palsus96872072021-02-25 20:16:19 +000044
David Garciaa60ec732021-03-17 15:28:47 +010045RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
46RUN dpkg -i ./osm_common.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040047
David Garciaa60ec732021-03-17 15:28:47 +010048RUN curl $PYTHON3_OSM_POLICY_MODULE_URL -o osm_policy_module.deb
49RUN dpkg -i ./osm_policy_module.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040050
David Garciaa60ec732021-03-17 15:28:47 +010051RUN pip3 install \
52 -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
53 -r /usr/lib/python3/dist-packages/osm_policy_module/requirements.txt
Mike Marchettidc8ea9c2018-09-21 11:36:05 -040054
beierlmd7449362022-01-13 10:53:08 -050055#######################################################################################
Mark Beierl02feb8e2023-05-10 11:44:11 -040056FROM ubuntu:22.04 as FINAL
Mike Marchettidc8ea9c2018-09-21 11:36:05 -040057
beierlmd7449362022-01-13 10:53:08 -050058ARG APT_PROXY
59RUN if [ ! -z $APT_PROXY ] ; then \
60 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
61 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
62 fi
63
David Garciaa60ec732021-03-17 15:28:47 +010064RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
beierlmd7449362022-01-13 10:53:08 -050065 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
Mark Beierl02feb8e2023-05-10 11:44:11 -040066 python3-minimal=3.10.* \
garciadeblas6ba74b52021-09-23 17:43:15 +020067 && rm -rf /var/lib/apt/lists/*
David Garciaa60ec732021-03-17 15:28:47 +010068
69COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
Mark Beierl02feb8e2023-05-10 11:44:11 -040070COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
71
72#######################################################################################
73# End of common prepration
Gulsum Atici41170ea2023-06-07 16:18:15 +030074RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
75 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
76 libmd0 \
77 && rm -rf /var/lib/apt/lists/*
Mark Beierl02feb8e2023-05-10 11:44:11 -040078
David Garciaa60ec732021-03-17 15:28:47 +010079COPY --from=INSTALL /usr/bin/osm* /usr/bin/
beierlm241be2c2021-04-16 16:01:06 -040080COPY --from=INSTALL /usr/bin/mysql /usr/bin/
beierlm023e83c2021-04-14 10:12:58 -040081COPY --from=INSTALL /usr/bin/mysqladmin /usr/bin/
beierlm241be2c2021-04-16 16:01:06 -040082COPY --from=INSTALL /usr/bin/mysqlshow /usr/bin/
83COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/libedit.so.2 /usr/lib/x86_64-linux-gnu/
84COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/libbsd.so.0 /usr/lib/x86_64-linux-gnu/
Mike Marchettidc8ea9c2018-09-21 11:36:05 -040085
sousaeduce5d7042021-10-14 15:16:59 +010086COPY scripts/ /app/osm_pol/scripts/
87
88# Creating the user for the app
89RUN groupadd -g 1000 appuser && \
90 useradd -u 1000 -g 1000 -d /app appuser && \
91 mkdir -p /app/osm_pol && \
92 mkdir -p /app/storage/kafka && \
93 mkdir /app/log && \
94 chown -R appuser:appuser /app
95
96WORKDIR /app/osm_pol
97
98# Changing the security context
99USER appuser
100
101########################################################################
Benjamin Diaz04560882019-02-26 17:25:07 -0300102
Eduardo Sousa280ccc72018-09-21 16:34:29 +0100103ENV OSMPOL_MESSAGE_DRIVER kafka
104ENV OSMPOL_MESSAGE_HOST kafka
105ENV OSMPOL_MESSAGE_PORT 9092
106
107ENV OSMPOL_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300108ENV OSMPOL_DATABASE_URI mongodb://mongo:27017
Eduardo Sousa280ccc72018-09-21 16:34:29 +0100109
110ENV OSMPOL_SQL_DATABASE_URI sqlite:///mon_sqlite.db
111
Benjamin Diaze6f7b452019-02-07 12:09:57 -0300112ENV OSMPOL_GLOBAL_LOG_LEVEL INFO
Eduardo Sousa280ccc72018-09-21 16:34:29 +0100113
sritharan05ee8ab2023-04-28 05:38:10 +0000114ENV OSMPOL_AUTOHEAL_ENABLED True
115
116ENV OSMPOL_AUTOSCALE_ENABLED True
117
tierno836e9db2019-07-22 13:23:56 +0000118HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
Benjamin Diazdeb99f32019-05-27 17:01:06 -0300119 CMD osm-pol-healthcheck || exit 1
120
Benjamin Diaz04560882019-02-26 17:25:07 -0300121CMD /bin/bash scripts/start.sh