| 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 | 13d76c8 | 2018-09-19 15:00:36 -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 | |
| garciadeblas | 21503ab | 2023-06-28 14:31:27 +0200 | [diff] [blame] | 35 | ########### End of common preparation |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 36 | |
| garciadeblas | 1028530 | 2022-02-10 00:49:51 +0100 | [diff] [blame] | 37 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 38 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 39 | apt-transport-https=2.4.* \ |
| sousaedu | fd164af | 2021-08-12 15:35:51 +0100 | [diff] [blame] | 40 | gnupg2=2.2.* \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 41 | openssh-client=1:8.* \ |
| garciadeblas | cfb3518 | 2025-12-17 11:20:33 +0100 | [diff] [blame^] | 42 | git=1:2.* \ |
| 43 | libcurl4-openssl-dev=7.81.* \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 44 | && rm -rf /var/lib/apt/lists/* |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 45 | |
| garciadeblas | f6f4584 | 2021-12-14 17:46:08 +0100 | [diff] [blame] | 46 | # https://kubernetes.io/releases/ |
| garciadeblas | 437867e | 2024-05-30 14:46:54 +0200 | [diff] [blame] | 47 | RUN curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg \ |
| 48 | && echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list \ |
| 49 | && apt-get update && apt-get install -y kubectl=1.30.1-1.1 |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 50 | |
| garciadeblas | f6f4584 | 2021-12-14 17:46:08 +0100 | [diff] [blame] | 51 | # https://github.com/helm/helm/releases |
| garciadeblas | 437867e | 2024-05-30 14:46:54 +0200 | [diff] [blame] | 52 | RUN curl https://get.helm.sh/helm-v3.15.1-linux-amd64.tar.gz --output helm-v3.15.1.tar.gz \ |
| 53 | && tar -zxvf helm-v3.15.1.tar.gz \ |
| lloretgalleg | 5926de2 | 2020-11-16 10:27:49 +0000 | [diff] [blame] | 54 | && mv linux-amd64/helm /usr/local/bin/helm3 \ |
| 55 | && rm -r linux-amd64/ |
| 56 | |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 57 | ARG COMMON_GERRIT_REFSPEC=master |
| garciadeblas | 87a45b7 | 2025-12-09 20:01:03 +0100 | [diff] [blame] | 58 | RUN pip3 install -U pip build |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 59 | RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \ |
| 60 | cd /tmp/osm-common && \ |
| 61 | git fetch origin ${COMMON_GERRIT_REFSPEC} && \ |
| 62 | git checkout FETCH_HEAD && \ |
| 63 | cd - && \ |
| garciadeblas | 87a45b7 | 2025-12-09 20:01:03 +0100 | [diff] [blame] | 64 | pip3 install --no-cache-dir -r /tmp/osm-common/requirements.txt && \ |
| 65 | pip3 install /tmp/osm-common |
| garciadeblas | 2fc3deb | 2025-11-25 17:26:14 +0100 | [diff] [blame] | 66 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 67 | ARG PYTHON3_OSM_LCM_URL |
| garciadeblas | ca6cf4a | 2024-07-16 18:14:34 +0200 | [diff] [blame] | 68 | RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb |
| 69 | RUN dpkg -i ./osm_lcm.deb |
| 70 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 71 | RUN pip3 install \ |
| garciadeblas | ca6cf4a | 2024-07-16 18:14:34 +0200 | [diff] [blame] | 72 | -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 73 | |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 74 | ####################################################################################### |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 75 | FROM ubuntu:22.04 as FINAL |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 76 | |
| 77 | ARG APT_PROXY |
| 78 | RUN if [ ! -z $APT_PROXY ] ; then \ |
| 79 | echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\ |
| 80 | echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\ |
| 81 | fi |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 82 | |
| 83 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| garciadeblas | 15897d6 | 2021-09-22 18:11:54 +0200 | [diff] [blame] | 84 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 85 | python3-minimal=3.10.* \ |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 86 | && rm -rf /var/lib/apt/lists/* |
| 87 | |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 88 | COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages |
| 89 | COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages |
| 90 | |
| 91 | ####################################################################################### |
| garciadeblas | 21503ab | 2023-06-28 14:31:27 +0200 | [diff] [blame] | 92 | # End of common preparation |
| Mark Beierl | 02feb8e | 2023-05-10 11:44:11 -0400 | [diff] [blame] | 93 | |
| beierlm | d744936 | 2022-01-13 10:53:08 -0500 | [diff] [blame] | 94 | RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \ |
| 95 | DEBIAN_FRONTEND=noninteractive apt-get --yes install \ |
| garciadeblas | 6ba74b5 | 2021-09-23 17:43:15 +0200 | [diff] [blame] | 96 | ca-certificates \ |
| 97 | && rm -rf /var/lib/apt/lists/* |
| beierlm | 9c33b5a | 2021-04-13 10:04:22 -0400 | [diff] [blame] | 98 | |
| Mark Beierl | e5b9ba6 | 2022-09-08 05:44:06 -0400 | [diff] [blame] | 99 | RUN rm -f /etc/apt/apt.conf.d/proxy.conf |
| 100 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 101 | COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 102 | COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3 |
| beierlm | 3b36f4d | 2021-04-13 17:01:53 -0400 | [diff] [blame] | 103 | COPY --from=INSTALL /usr/bin/scp /usr/bin/scp |
| beierlm | 249cd46 | 2021-04-07 14:19:03 -0400 | [diff] [blame] | 104 | COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen |
| beierlm | 9c33b5a | 2021-04-13 10:04:22 -0400 | [diff] [blame] | 105 | COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh |
| garciadeblas | cfb3518 | 2025-12-17 11:20:33 +0100 | [diff] [blame^] | 106 | COPY --from=INSTALL /usr/bin/git /usr/bin/git |
| beierlm | 249cd46 | 2021-04-07 14:19:03 -0400 | [diff] [blame] | 107 | 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] | 108 | COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ |
| garciadeblas | cfb3518 | 2025-12-17 11:20:33 +0100 | [diff] [blame^] | 109 | COPY --from=INSTALL /usr/lib/git-core/ /usr/lib/git-core/ |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 110 | |
| Mark Beierl | abc56a9 | 2022-02-11 08:56:32 -0500 | [diff] [blame] | 111 | COPY scripts/ /app/osm_lcm/scripts/ |
| 112 | |
| 113 | # Creating the user for the app |
| 114 | RUN groupadd -g 1000 appuser && \ |
| 115 | useradd -u 1000 -g 1000 -d /app appuser && \ |
| 116 | mkdir -p /app/osm_lcm && \ |
| 117 | mkdir -p /app/storage/kafka && \ |
| 118 | mkdir /app/log && \ |
| David Garcia | 8513046 | 2022-04-27 13:46:34 +0200 | [diff] [blame] | 119 | chown -R appuser:appuser /app && \ |
| 120 | chown appuser: /etc/ssl/certs/ca-certificates.crt |
| 121 | |
| Mark Beierl | abc56a9 | 2022-02-11 08:56:32 -0500 | [diff] [blame] | 122 | |
| 123 | WORKDIR /app/osm_lcm |
| 124 | |
| 125 | # Changing the security context |
| 126 | USER appuser |
| sousaedu | 7389cfc | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 127 | |
| David Garcia | a60ec73 | 2021-03-17 15:28:47 +0100 | [diff] [blame] | 128 | ######################################################################## |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 129 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 130 | # The following ENV can be added with "docker run -e xxx' to configure LCM |
| 131 | ENV OSMLCM_RO_HOST ro |
| 132 | ENV OSMLCM_RO_PORT 9090 |
| 133 | ENV OSMLCM_RO_TENANT osm |
| 134 | |
| 135 | # VCA |
| 136 | ENV OSMLCM_VCA_HOST vca |
| garciadeblas | a2e4184 | 2019-12-18 11:05:24 +0100 | [diff] [blame] | 137 | ENV OSMLCM_VCA_PORT 17070 |
| 138 | ENV OSMLCM_VCA_USER admin |
| 139 | ENV OSMLCM_VCA_SECRET secret |
| 140 | # ENV OSMLCM_VCA_PUBKEY pubkey |
| 141 | # ENV OSMLCM_VCA_CACERT cacert |
| 142 | # ENV OSMLCM_VCA_ENABLEOSUPGRADE false |
| 143 | # ENV OSMLCM_VCA_APTMIRROR http://archive.ubuntu.com/ubuntu/ |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 144 | |
| 145 | # database |
| 146 | ENV OSMLCM_DATABASE_DRIVER mongo |
| Juan | cc084d7 | 2018-11-16 11:08:07 -0300 | [diff] [blame] | 147 | ENV OSMLCM_DATABASE_URI mongodb://mongo:27017 |
| 148 | #ENV OSMLCM_DATABASE_HOST mongo |
| 149 | #ENV OSMLCM_DATABASE_PORT 27017 |
| 150 | |
| 151 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 152 | ENV OSMLCM_STORAGE_DRIVER local |
| 153 | ENV OSMLCM_STORAGE_PATH /app/storage |
| 154 | |
| 155 | # message |
| 156 | ENV OSMLCM_MESSAGE_DRIVER kafka |
| 157 | ENV OSMLCM_MESSAGE_HOST kafka |
| 158 | ENV OSMLCM_MESSAGE_PORT 9092 |
| 159 | |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 160 | # k8s |
| garciadeblas | 09bc809 | 2024-05-30 22:35:30 +0200 | [diff] [blame] | 161 | ENV OSMLCM_VCA_HELMPATH /usr/local/bin/helm3 |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 162 | ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl |
| Adam Israel | 3f16fd5 | 2019-12-03 10:14:06 -0500 | [diff] [blame] | 163 | ENV OSMLCM_VCA_JUJUPATH /usr/local/bin/juju |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 164 | |
| Pedro Pereira | c09bd23 | 2024-06-19 20:59:36 +0100 | [diff] [blame] | 165 | # post-renderers |
| garciadeblas | 2ed535b | 2024-12-16 17:02:11 +0100 | [diff] [blame] | 166 | ENV OSMLCM_MAINPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/mainPostRenderer/mainPostRenderer |
| 167 | ENV OSMLCM_PODLABELSPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/podLabels/podLabels |
| 168 | ENV OSMLCM_NODESELECTORPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/nodeSelector/nodeSelector |
| Pedro Pereira | c09bd23 | 2024-06-19 20:59:36 +0100 | [diff] [blame] | 169 | |
| David Garcia | 1d5c221 | 2021-05-28 16:24:24 +0200 | [diff] [blame] | 170 | # helm |
| 171 | ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable |
| sousaedu | 7389cfc | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 172 | # ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert> |
| David Garcia | 1d5c221 | 2021-05-28 16:24:24 +0200 | [diff] [blame] | 173 | |
| garciadeblas | 0ccc31e | 2019-11-22 15:28:50 +0100 | [diff] [blame] | 174 | # logs |
| 175 | # ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log |
| 176 | # ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG |
| 177 | |
| tierno | 9f8b53b | 2019-09-13 13:19:48 +0000 | [diff] [blame] | 178 | HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \ |
| tierno | 62478d1 | 2020-01-09 17:25:29 +0000 | [diff] [blame] | 179 | CMD python3 -m osm_lcm.lcm_hc || exit 1 |
| tierno | 84a3c9a | 2018-10-24 11:02:57 +0200 | [diff] [blame] | 180 | |
| Mike Marchetti | 13d76c8 | 2018-09-19 15:00:36 -0400 | [diff] [blame] | 181 | # Run app.py when the container launches |
| sousaedu | 7389cfc | 2021-07-30 11:52:48 +0200 | [diff] [blame] | 182 | CMD [ "/bin/bash", "scripts/start.sh" ] |