| calvinosanch | bfb7790 | 2019-07-31 13:31:16 +0000 | [diff] [blame] | 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 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 19 | FROM ubuntu:18.04 as INSTALL |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 20 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 21 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 22 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| sousaedu | fd164af | 2021-08-12 15:35:51 +0100 | [diff] [blame] | 23 | gcc=4:7.4.* \ |
| 24 | python3=3.6.* \ |
| 25 | python3-dev=3.6.* \ |
| 26 | python3-setuptools=39.0.* \ |
| 27 | curl=7.58.* && \ |
| sousaedu | cb99276 | 2021-08-31 18:52:26 +0100 | [diff] [blame] | 28 | python3 -m easy_install pip==21.0.1 setuptools==51.0.0 |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 29 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 30 | ARG PYTHON3_OSM_COMMON_URL |
| 31 | ARG PYTHON3_OSM_IM_URL |
| 32 | ARG PYTHON3_OSM_NBI_URL |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 33 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 34 | RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb |
| 35 | RUN dpkg -i ./osm_common.deb |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 36 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 37 | RUN curl $PYTHON3_OSM_IM_URL -o osm_im.deb |
| 38 | RUN dpkg -i ./osm_im.deb |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 39 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 40 | RUN curl $PYTHON3_OSM_NBI_URL -o osm_nbi.deb |
| 41 | RUN dpkg -i ./osm_nbi.deb |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 42 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 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 |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 47 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 48 | FROM ubuntu:18.04 as FINAL |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 49 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 50 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| garciadeblas | 6ba74b5 | 2021-09-23 17:43:15 +0200 | [diff] [blame] | 51 | DEBIAN_FRONTEND=noninteractive apt-get --yes install python3-minimal=3.6.* \ |
| 52 | && rm -rf /var/lib/apt/lists/* |
| fonsecaj | f404b8b | 2021-02-11 14:08:52 +0100 | [diff] [blame] | 53 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 54 | COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages |
| 55 | COPY --from=INSTALL /usr/local/lib/python3.6/dist-packages /usr/local/lib/python3.6/dist-packages |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 56 | |
| sousaedu | a8e75d0 | 2021-09-30 14:07:57 +0100 | [diff] [blame^] | 57 | # Creating the user for the app |
| 58 | RUN groupadd -g 1000 appuser && \ |
| 59 | useradd -u 1000 -g 1000 -d /app appuser && \ |
| 60 | mkdir -p /app/osm_nbi && \ |
| 61 | mkdir -p /app/storage/kafka && \ |
| 62 | mkdir /app/log && \ |
| 63 | chown -R appuser:appuser /app |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 64 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 65 | WORKDIR /app/osm_nbi |
| 66 | |
| sousaedu | a8e75d0 | 2021-09-30 14:07:57 +0100 | [diff] [blame^] | 67 | # Changing the security context |
| 68 | USER appuser |
| 69 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 70 | EXPOSE 9999 |
| 71 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 72 | RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/html_public /app/osm_nbi/html_public |
| 73 | RUN cp /usr/lib/python3/dist-packages/osm_nbi/nbi.cfg /app/osm_nbi/ |
| 74 | RUN cp -R /usr/lib/python3/dist-packages/osm_nbi/http /app/osm_nbi/ |
| 75 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 76 | # The following ENV can be added with "docker run -e xxx' to configure |
| 77 | # server |
| 78 | ENV OSMNBI_SOCKET_HOST 0.0.0.0 |
| 79 | ENV OSMNBI_SOCKET_PORT 9999 |
| tierno | 2c002c9 | 2019-09-13 12:57:35 +0000 | [diff] [blame] | 80 | ENV OSMNBI_SERVER_SSL_CERTIFICATE /app/osm_nbi/http/cert.pem |
| 81 | ENV OSMNBI_SERVER_SSL_PRIVATE_KEY /app/osm_nbi/http/privkey.pem |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 82 | # storage |
| 83 | ENV OSMNBI_STORAGE_PATH /app/storage |
| 84 | # database |
| 85 | ENV OSMNBI_DATABASE_DRIVER mongo |
| Juan | cc084d7 | 2018-11-16 11:08:07 -0300 | [diff] [blame] | 86 | ENV OSMNBI_DATABASE_URI mongodb://mongo:27017 |
| 87 | #ENV OSMNBI_DATABASE_HOST mongo |
| 88 | #ENV OSMNBI_DATABASE_PORT 27017 |
| 89 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 90 | # web |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 91 | ENV OSMNBI_STATIC_DIR /app/osm_nbi/html_public |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 92 | # message |
| 93 | ENV OSMNBI_MESSAGE_DRIVER kafka |
| 94 | ENV OSMNBI_MESSAGE_HOST kafka |
| 95 | ENV OSMNBI_MESSAGE_PORT 9092 |
| 96 | # logs |
| 97 | ENV OSMNBI_LOG_FILE /app/log/nbi.log |
| 98 | ENV OSMNBI_LOG_LEVEL DEBUG |
| Eduardo Sousa | e193dfd | 2018-09-21 11:37:49 +0100 | [diff] [blame] | 99 | # authentication |
| 100 | ENV OSMNBI_AUTHENTICATION_BACKEND internal |
| 101 | #ENV OSMNBI_AUTHENTICATION_BACKEND keystone |
| 102 | #ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone |
| 103 | #ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000 |
| 104 | #ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default |
| 105 | #ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default |
| 106 | #ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi |
| 107 | #ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi |
| 108 | #ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service |
| vijay.r | bdb4802 | 2019-05-06 15:38:23 +0530 | [diff] [blame] | 109 | #prometheus |
| 110 | ENV OSMNBI_PROMETHEUS_HOST prometheus |
| 111 | ENV OSMNBI_PROMETHEUS_PORT 9090 |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 112 | |
| tierno | 836e9db | 2019-07-22 13:23:56 +0000 | [diff] [blame] | 113 | HEALTHCHECK --start-period=120s --interval=10s --timeout=5s --retries=5 \ |
| Mike Marchetti | 851aac2 | 2018-09-20 10:18:01 -0400 | [diff] [blame] | 114 | CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1 |
| 115 | |
| Mike Marchetti | 182bd73 | 2018-09-05 09:52:42 -0400 | [diff] [blame] | 116 | # Run app.py when the container launches |
| tierno | 2c002c9 | 2019-09-13 12:57:35 +0000 | [diff] [blame] | 117 | CMD python3 -m osm_nbi.nbi |