| 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 | |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 19 | FROM ubuntu:20.04 as INSTALL |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -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 \ |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 23 | gcc=4:9.3.* \ |
| 24 | python3=3.8.* \ |
| 25 | python3-dev=3.8.* \ |
| 26 | python3-pip=20.0.2* \ |
| 27 | python3-setuptools=45.2.* \ |
| 28 | curl=7.68.* |
| 29 | |
| garciadeblas | 3a0df72 | 2022-02-10 00:49:51 +0100 | [diff] [blame^] | 30 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 31 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 32 | apt-transport-https=2.0.* \ |
| sousaedu | e99b45e | 2021-08-12 15:35:51 +0100 | [diff] [blame] | 33 | gnupg2=2.2.* \ |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 34 | openssh-client=1:8.* |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 35 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 36 | RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \ |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 37 | && echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list \ |
| aticig | 734099e | 2022-02-04 15:36:26 +0300 | [diff] [blame] | 38 | && apt-get update && apt-get install -y kubectl=1.23.3-00 |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 39 | |
| David Garcia | b7827fe | 2021-05-28 16:24:24 +0200 | [diff] [blame] | 40 | RUN curl https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz --output helm-v2.17.0.tar.gz \ |
| 41 | && tar -zxvf helm-v2.17.0.tar.gz \ |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 42 | && mv linux-amd64/helm /usr/local/bin/helm \ |
| 43 | && rm -r linux-amd64/ |
| 44 | |
| aticig | 734099e | 2022-02-04 15:36:26 +0300 | [diff] [blame] | 45 | RUN curl https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz --output helm-v3.7.2.tar.gz \ |
| 46 | && tar -zxvf helm-v3.7.2.tar.gz \ |
| lloretgalleg | 5926de2 | 2020-11-16 10:27:49 +0000 | [diff] [blame] | 47 | && mv linux-amd64/helm /usr/local/bin/helm3 \ |
| 48 | && rm -r linux-amd64/ |
| 49 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 50 | ARG PYTHON3_OSM_COMMON_URL |
| 51 | ARG PYTHON3_OSM_LCM_URL |
| 52 | ARG PYTHON3_N2VC_URL |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 53 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 54 | RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb |
| 55 | RUN dpkg -i ./osm_common.deb |
| David Garcia | 5ac9781 | 2019-12-09 10:18:58 +0100 | [diff] [blame] | 56 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 57 | RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb |
| 58 | RUN dpkg -i ./osm_lcm.deb |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 59 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 60 | RUN curl $PYTHON3_N2VC_URL -o osm_n2vc.deb |
| 61 | RUN dpkg -i ./osm_n2vc.deb |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 62 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 63 | RUN pip3 install \ |
| 64 | -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \ |
| 65 | -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt \ |
| 66 | -r /usr/lib/python3/dist-packages/n2vc/requirements.txt |
| 67 | |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 68 | ####################################################################################### |
| 69 | FROM ubuntu:20.04 as FINAL |
| 70 | |
| 71 | ARG APT_PROXY |
| 72 | RUN if [ ! -z $APT_PROXY ] ; then \ |
| 73 | echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\ |
| 74 | echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\ |
| 75 | fi |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 76 | |
| 77 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| garciadeblas | ca27568 | 2021-09-22 18:11:54 +0200 | [diff] [blame] | 78 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 79 | python3-minimal=3.8.* \ |
| 80 | && rm -rf /var/lib/apt/lists/* |
| 81 | |
| 82 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 83 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| garciadeblas | d992a95 | 2021-09-23 17:43:15 +0200 | [diff] [blame] | 84 | ca-certificates \ |
| 85 | && rm -rf /var/lib/apt/lists/* |
| beierlm | 9c33b5a | 2021-04-13 10:04:22 -0400 | [diff] [blame] | 86 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 87 | COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages |
| beierlm | 5a6d112 | 2022-01-26 10:18:21 -0500 | [diff] [blame] | 88 | COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 89 | |
| 90 | COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl |
| 91 | COPY --from=INSTALL /usr/local/bin/helm /usr/local/bin/helm |
| 92 | COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3 |
| beierlm | 3b36f4d | 2021-04-13 17:01:53 -0400 | [diff] [blame] | 93 | COPY --from=INSTALL /usr/bin/scp /usr/bin/scp |
| beierlm | 249cd46 | 2021-04-07 14:19:03 -0400 | [diff] [blame] | 94 | COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen |
| beierlm | 9c33b5a | 2021-04-13 10:04:22 -0400 | [diff] [blame] | 95 | COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh |
| beierlm | 249cd46 | 2021-04-07 14:19:03 -0400 | [diff] [blame] | 96 | COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/ |
| beierlm | 9c33b5a | 2021-04-13 10:04:22 -0400 | [diff] [blame] | 97 | COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 98 | |
| garciadeblas | cc9fc1c | 2022-02-22 00:04:09 +0100 | [diff] [blame] | 99 | COPY scripts/ /app/osm_lcm/scripts/ |
| 100 | |
| 101 | # Creating the user for the app |
| 102 | RUN groupadd -g 1000 appuser && \ |
| 103 | useradd -u 1000 -g 1000 -d /app appuser && \ |
| 104 | mkdir -p /app/osm_lcm && \ |
| 105 | mkdir -p /app/storage/kafka && \ |
| 106 | mkdir /app/log && \ |
| 107 | chown -R appuser:appuser /app |
| 108 | |
| garciadeblas | 310805f | 2022-02-28 17:05:09 +0100 | [diff] [blame] | 109 | RUN mkdir /opt/prometheus |
| 110 | RUN chown appuser: /opt/prometheus |
| 111 | |
| garciadeblas | cc9fc1c | 2022-02-22 00:04:09 +0100 | [diff] [blame] | 112 | WORKDIR /app/osm_lcm |
| 113 | |
| 114 | # Changing the security context |
| 115 | USER appuser |
| sousaedu | fa6cbc1 | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 116 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 117 | ######################################################################## |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 118 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 119 | # The following ENV can be added with "docker run -e xxx' to configure LCM |
| 120 | ENV OSMLCM_RO_HOST ro |
| 121 | ENV OSMLCM_RO_PORT 9090 |
| 122 | ENV OSMLCM_RO_TENANT osm |
| 123 | |
| 124 | # VCA |
| 125 | ENV OSMLCM_VCA_HOST vca |
| garciadeblas | a2e4184 | 2019-12-18 11:05:24 +0100 | [diff] [blame] | 126 | ENV OSMLCM_VCA_PORT 17070 |
| 127 | ENV OSMLCM_VCA_USER admin |
| 128 | ENV OSMLCM_VCA_SECRET secret |
| 129 | # ENV OSMLCM_VCA_PUBKEY pubkey |
| 130 | # ENV OSMLCM_VCA_CACERT cacert |
| 131 | # ENV OSMLCM_VCA_ENABLEOSUPGRADE false |
| 132 | # ENV OSMLCM_VCA_APTMIRROR http://archive.ubuntu.com/ubuntu/ |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 133 | |
| 134 | # database |
| 135 | ENV OSMLCM_DATABASE_DRIVER mongo |
| Juan | cc084d7 | 2018-11-16 11:08:07 -0300 | [diff] [blame] | 136 | ENV OSMLCM_DATABASE_URI mongodb://mongo:27017 |
| 137 | #ENV OSMLCM_DATABASE_HOST mongo |
| 138 | #ENV OSMLCM_DATABASE_PORT 27017 |
| 139 | |
| 140 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 141 | ENV OSMLCM_STORAGE_DRIVER local |
| 142 | ENV OSMLCM_STORAGE_PATH /app/storage |
| 143 | |
| 144 | # message |
| 145 | ENV OSMLCM_MESSAGE_DRIVER kafka |
| 146 | ENV OSMLCM_MESSAGE_HOST kafka |
| 147 | ENV OSMLCM_MESSAGE_PORT 9092 |
| 148 | |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 149 | # k8s |
| 150 | ENV OSMLCM_VCA_HELMPATH /usr/local/bin/helm |
| 151 | ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl |
| Adam Israel | 3f16fd5 | 2019-12-03 10:14:06 -0500 | [diff] [blame] | 152 | ENV OSMLCM_VCA_JUJUPATH /usr/local/bin/juju |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 153 | |
| David Garcia | b7827fe | 2021-05-28 16:24:24 +0200 | [diff] [blame] | 154 | # helm |
| 155 | ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable |
| sousaedu | fa6cbc1 | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 156 | # ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert> |
| David Garcia | b7827fe | 2021-05-28 16:24:24 +0200 | [diff] [blame] | 157 | |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 158 | # logs |
| 159 | # ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log |
| 160 | # ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG |
| 161 | |
| tierno | 9f8b53b | 2019-09-13 13:19:48 +0000 | [diff] [blame] | 162 | HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \ |
| tierno | 62478d1 | 2020-01-09 17:25:29 +0000 | [diff] [blame] | 163 | CMD python3 -m osm_lcm.lcm_hc || exit 1 |
| tierno | 84a3c9a | 2018-10-24 11:02:57 +0200 | [diff] [blame] | 164 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 165 | # Run app.py when the container launches |
| sousaedu | fa6cbc1 | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 166 | CMD [ "/bin/bash", "scripts/start.sh" ] |