| beierlm | e764625 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 1 | ####################################################################################### |
| 2 | # Copyright ETSI Contributors and Others. |
| calvinosanch | bfb7790 | 2019-07-31 13:31:16 +0000 | [diff] [blame] | 3 | # |
| beierlm | e764625 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 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 |
| calvinosanch | bfb7790 | 2019-07-31 13:31:16 +0000 | [diff] [blame] | 7 | # |
| beierlm | e764625 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| calvinosanch | bfb7790 | 2019-07-31 13:31:16 +0000 | [diff] [blame] | 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| beierlm | e764625 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 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 | ####################################################################################### |
| calvinosanch | bfb7790 | 2019-07-31 13:31:16 +0000 | [diff] [blame] | 17 | |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 18 | FROM ubuntu:22.04 as INSTALL |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 19 | |
| beierlm | e764625 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 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 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 26 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 27 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 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 | ####################################################################################### |
| garciadeblas | 21503ab | 2023-06-28 14:31:27 +0200 | [diff] [blame] | 36 | # End of common preparation |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 37 | |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 38 | RUN 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 | |
| 43 | ARG COMMON_GERRIT_REFSPEC=master |
| garciadeblas | 87a45b7 | 2025-12-09 20:01:03 +0100 | [diff] [blame] | 44 | RUN pip3 install -U pip build |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 45 | RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \ |
| 46 | cd /tmp/osm-common && \ |
| 47 | git fetch origin ${COMMON_GERRIT_REFSPEC} && \ |
| 48 | git checkout FETCH_HEAD && \ |
| 49 | cd - && \ |
| garciadeblas | 87a45b7 | 2025-12-09 20:01:03 +0100 | [diff] [blame] | 50 | pip3 install --no-cache-dir -r /tmp/osm-common/requirements.txt && \ |
| 51 | pip3 install /tmp/osm-common |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 52 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 53 | ARG PYTHON3_OSM_IM_URL |
| 54 | ARG PYTHON3_OSM_NBI_URL |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 55 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 56 | RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb |
| 57 | RUN dpkg -i ./osm_im.deb |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 58 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 59 | RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb |
| 60 | RUN dpkg -i ./osm_nbi.deb |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 61 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 62 | RUN pip3 install \ |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 63 | -r /usr/lib/python3/dist-packages/osm_im/requirements.txt \ |
| 64 | -r /usr/lib/python3/dist-packages/osm_nbi/requirements.txt |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 65 | |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 66 | ####################################################################################### |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 67 | FROM ubuntu:22.04 as FINAL |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 68 | |
| 69 | ARG APT_PROXY |
| 70 | RUN if [ ! -z $APT_PROXY ] ; then \ |
| 71 | echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\ |
| 72 | echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\ |
| 73 | fi |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 74 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 75 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 76 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 77 | python3-minimal=3.10.* \ |
| garciadeblas | 6ba74b5 | 2021-09-23 17:43:15 +0200 | [diff] [blame] | 78 | && rm -rf /var/lib/apt/lists/* |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 79 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 80 | COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 81 | COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages |
| 82 | |
| 83 | ####################################################################################### |
| garciadeblas | 21503ab | 2023-06-28 14:31:27 +0200 | [diff] [blame] | 84 | # End of common preparation |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 85 | |
| 86 | RUN rm -f /etc/apt/apt.conf.d/proxy.conf |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 87 | |
| sousaedu | a8e75d0 | 2021-09-30 14:07:57 +0100 | [diff] [blame] | 88 | # Creating the user for the app |
| 89 | RUN groupadd -g 1000 appuser && \ |
| 90 | useradd -u 1000 -g 1000 -d /app appuser && \ |
| 91 | mkdir -p /app/osm_nbi && \ |
| 92 | mkdir -p /app/storage/kafka && \ |
| 93 | mkdir /app/log && \ |
| 94 | chown -R appuser:appuser /app |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 95 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 96 | WORKDIR /app/osm_nbi |
| 97 | |
| sousaedu | a8e75d0 | 2021-09-30 14:07:57 +0100 | [diff] [blame] | 98 | # Changing the security context |
| 99 | USER appuser |
| 100 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 101 | EXPOSE 9999 |
| 102 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 103 | RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public |
| 104 | RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/ |
| 105 | RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/ |
| jegan | 0f0ab77 | 2024-10-31 08:05:07 +0000 | [diff] [blame] | 106 | RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/templates /app/osm_nbi/templates |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 107 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 108 | # The following ENV can be added with "docker run -e xxx' to configure |
| 109 | # server |
| 110 | ENV OSMNBI_SOCKET_HOST 0.0.0.0 |
| 111 | ENV OSMNBI_SOCKET_PORT 9999 |
| 112 | # storage |
| 113 | ENV OSMNBI_STORAGE_PATH /app/storage |
| 114 | # database |
| 115 | ENV OSMNBI_DATABASE_DRIVER mongo |
| Juan | cc084d7 | 2018-11-16 11:08:07 -0300 | [diff] [blame] | 116 | ENV OSMNBI_DATABASE_URI mongodb://mongo:27017 |
| 117 | #ENV OSMNBI_DATABASE_HOST mongo |
| 118 | #ENV OSMNBI_DATABASE_PORT 27017 |
| 119 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 120 | # web |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 121 | ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 122 | # message |
| 123 | ENV OSMNBI_MESSAGE_DRIVER kafka |
| 124 | ENV OSMNBI_MESSAGE_HOST kafka |
| 125 | ENV OSMNBI_MESSAGE_PORT 9092 |
| 126 | # logs |
| 127 | ENV OSMNBI_LOG_FILE /app/log/nbi.log |
| 128 | ENV OSMNBI_LOG_LEVEL DEBUG |
| Eduardo Sousa | e193dfd | 2018-09-21 11:37:49 +0100 | [diff] [blame] | 129 | # authentication |
| 130 | ENV OSMNBI_AUTHENTICATION_BACKEND internal |
| 131 | #ENV OSMNBI_AUTHENTICATION_BACKEND keystone |
| 132 | #ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone |
| 133 | #ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000 |
| 134 | #ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default |
| 135 | #ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default |
| 136 | #ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi |
| 137 | #ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi |
| 138 | #ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service |
| vijay.r | bdb4802 | 2019-05-06 15:38:23 +0530 | [diff] [blame] | 139 | #prometheus |
| 140 | ENV OSMNBI_PROMETHEUS_HOST prometheus |
| 141 | ENV OSMNBI_PROMETHEUS_PORT 9090 |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 142 | |
| tierno | 836e9db | 2019-07-22 13:23:56 +0000 | [diff] [blame] | 143 | HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \ |
| Mike Marchetti | 851aac2 | 2018-09-20 10:18:01 -0400 | [diff] [blame] | 144 | CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1 |
| 145 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 146 | # Run app.py when the container launches |
| tierno | 2c002c9 | 2019-09-13 12:57:35 +0000 | [diff] [blame] | 147 | CMD python3 -m osm_nbi.nbi |