blob: 8ed8f5ed66083073fa8e83a09d6a7a09d985193e [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
74
David Garciaa60ec732021-03-17 15:28:47 +010075COPY --from=INSTALL /usr/bin/osm* /usr/bin/
beierlm241be2c2021-04-16 16:01:06 -040076COPY --from=INSTALL /usr/bin/mysql /usr/bin/
beierlm023e83c2021-04-14 10:12:58 -040077COPY --from=INSTALL /usr/bin/mysqladmin /usr/bin/
beierlm241be2c2021-04-16 16:01:06 -040078COPY --from=INSTALL /usr/bin/mysqlshow /usr/bin/
79COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/libedit.so.2 /usr/lib/x86_64-linux-gnu/
80COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/libbsd.so.0 /usr/lib/x86_64-linux-gnu/
Mike Marchettidc8ea9c2018-09-21 11:36:05 -040081
sousaeduce5d7042021-10-14 15:16:59 +010082COPY scripts/ /app/osm_pol/scripts/
83
84# Creating the user for the app
85RUN groupadd -g 1000 appuser && \
86 useradd -u 1000 -g 1000 -d /app appuser && \
87 mkdir -p /app/osm_pol && \
88 mkdir -p /app/storage/kafka && \
89 mkdir /app/log && \
90 chown -R appuser:appuser /app
91
92WORKDIR /app/osm_pol
93
94# Changing the security context
95USER appuser
96
97########################################################################
Benjamin Diaz04560882019-02-26 17:25:07 -030098
Eduardo Sousa280ccc72018-09-21 16:34:29 +010099ENV OSMPOL_MESSAGE_DRIVER kafka
100ENV OSMPOL_MESSAGE_HOST kafka
101ENV OSMPOL_MESSAGE_PORT 9092
102
103ENV OSMPOL_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300104ENV OSMPOL_DATABASE_URI mongodb://mongo:27017
Eduardo Sousa280ccc72018-09-21 16:34:29 +0100105
106ENV OSMPOL_SQL_DATABASE_URI sqlite:///mon_sqlite.db
107
Benjamin Diaze6f7b452019-02-07 12:09:57 -0300108ENV OSMPOL_GLOBAL_LOG_LEVEL INFO
Eduardo Sousa280ccc72018-09-21 16:34:29 +0100109
sritharan05ee8ab2023-04-28 05:38:10 +0000110ENV OSMPOL_AUTOHEAL_ENABLED True
111
112ENV OSMPOL_AUTOSCALE_ENABLED True
113
tierno836e9db2019-07-22 13:23:56 +0000114HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \
Benjamin Diazdeb99f32019-05-27 17:01:06 -0300115 CMD osm-pol-healthcheck || exit 1
116
Benjamin Diaz04560882019-02-26 17:25:07 -0300117CMD /bin/bash scripts/start.sh