blob: 0e025f76e96a91fbf9257acd3ab91d550d73ad83 [file] [log] [blame]
beierlme7646252022-01-13 10:53:08 -05001#######################################################################################
2# Copyright ETSI Contributors and Others.
calvinosanchbfb77902019-07-31 13:31:16 +00003#
beierlme7646252022-01-13 10:53:08 -05004# 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
calvinosanchbfb77902019-07-31 13:31:16 +00007#
beierlme7646252022-01-13 10:53:08 -05008# http://www.apache.org/licenses/LICENSE-2.0
calvinosanchbfb77902019-07-31 13:31:16 +00009#
10# 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#######################################################################################
calvinosanchbfb77902019-07-31 13:31:16 +000017
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
garciadeblas21503ab2023-06-28 14:31:27 +020035########### End of common preparation
beierlmd7449362022-01-13 10:53:08 -050036
garciadeblas10285302022-02-10 00:49:51 +010037RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
38 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
Mark Beierl02feb8e2023-05-10 11:44:11 -040039 apt-transport-https=2.4.* \
sousaedufd164af2021-08-12 15:35:51 +010040 gnupg2=2.2.* \
Mark Beierl02feb8e2023-05-10 11:44:11 -040041 openssh-client=1:8.* \
garciadeblas2fc3deb2025-11-25 17:26:14 +010042 git \
Mark Beierl02feb8e2023-05-10 11:44:11 -040043 && rm -rf /var/lib/apt/lists/*
Mike Marchetti13d76c82018-09-19 15:00:36 -040044
garciadeblasf6f45842021-12-14 17:46:08 +010045# https://kubernetes.io/releases/
garciadeblas437867e2024-05-30 14:46:54 +020046RUN curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg \
47 && 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 \
48 && apt-get update && apt-get install -y kubectl=1.30.1-1.1
garciadeblas0ccc31e2019-11-22 15:28:50 +010049
garciadeblasf6f45842021-12-14 17:46:08 +010050# https://github.com/helm/helm/releases
garciadeblas437867e2024-05-30 14:46:54 +020051RUN curl https://get.helm.sh/helm-v3.15.1-linux-amd64.tar.gz --output helm-v3.15.1.tar.gz \
52 && tar -zxvf helm-v3.15.1.tar.gz \
lloretgalleg5926de22020-11-16 10:27:49 +000053 && mv linux-amd64/helm /usr/local/bin/helm3 \
54 && rm -r linux-amd64/
55
garciadeblas2fc3deb2025-11-25 17:26:14 +010056ARG COMMON_GERRIT_REFSPEC=master
57RUN git clone --filter=blob:none --tags https://osm.etsi.org/gerrit/osm/common.git /tmp/osm-common && \
58 cd /tmp/osm-common && \
59 git fetch origin ${COMMON_GERRIT_REFSPEC} && \
60 git checkout FETCH_HEAD && \
61 cd - && \
62 pip install --no-cache-dir -r /tmp/osm-common/requirements.txt && \
63 pip install /tmp/osm-common
64
David Garciaa60ec732021-03-17 15:28:47 +010065ARG PYTHON3_OSM_LCM_URL
garciadeblasca6cf4a2024-07-16 18:14:34 +020066RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb
67RUN dpkg -i ./osm_lcm.deb
68
David Garciaa60ec732021-03-17 15:28:47 +010069RUN pip3 install \
garciadeblasca6cf4a2024-07-16 18:14:34 +020070 -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt
David Garciaa60ec732021-03-17 15:28:47 +010071
beierlmd7449362022-01-13 10:53:08 -050072#######################################################################################
Mark Beierl02feb8e2023-05-10 11:44:11 -040073FROM ubuntu:22.04 as FINAL
beierlmd7449362022-01-13 10:53:08 -050074
75ARG APT_PROXY
76RUN if [ ! -z $APT_PROXY ] ; then \
77 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
78 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
79 fi
David Garciaa60ec732021-03-17 15:28:47 +010080
81RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
garciadeblas15897d62021-09-22 18:11:54 +020082 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
Mark Beierl02feb8e2023-05-10 11:44:11 -040083 python3-minimal=3.10.* \
beierlmd7449362022-01-13 10:53:08 -050084 && rm -rf /var/lib/apt/lists/*
85
Mark Beierl02feb8e2023-05-10 11:44:11 -040086COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
87COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
88
89#######################################################################################
garciadeblas21503ab2023-06-28 14:31:27 +020090# End of common preparation
Mark Beierl02feb8e2023-05-10 11:44:11 -040091
beierlmd7449362022-01-13 10:53:08 -050092RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
93 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
garciadeblas6ba74b52021-09-23 17:43:15 +020094 ca-certificates \
95 && rm -rf /var/lib/apt/lists/*
beierlm9c33b5a2021-04-13 10:04:22 -040096
Mark Beierle5b9ba62022-09-08 05:44:06 -040097RUN rm -f /etc/apt/apt.conf.d/proxy.conf
98
David Garciaa60ec732021-03-17 15:28:47 +010099COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl
David Garciaa60ec732021-03-17 15:28:47 +0100100COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3
beierlm3b36f4d2021-04-13 17:01:53 -0400101COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
beierlm249cd462021-04-07 14:19:03 -0400102COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
beierlm9c33b5a2021-04-13 10:04:22 -0400103COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
beierlm249cd462021-04-07 14:19:03 -0400104COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
beierlm9c33b5a2021-04-13 10:04:22 -0400105COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
David Garciaa60ec732021-03-17 15:28:47 +0100106
Mark Beierlabc56a92022-02-11 08:56:32 -0500107COPY scripts/ /app/osm_lcm/scripts/
108
109# Creating the user for the app
110RUN groupadd -g 1000 appuser && \
111 useradd -u 1000 -g 1000 -d /app appuser && \
112 mkdir -p /app/osm_lcm && \
113 mkdir -p /app/storage/kafka && \
114 mkdir /app/log && \
David Garcia85130462022-04-27 13:46:34 +0200115 chown -R appuser:appuser /app && \
116 chown appuser: /etc/ssl/certs/ca-certificates.crt
117
Mark Beierlabc56a92022-02-11 08:56:32 -0500118
119WORKDIR /app/osm_lcm
120
121# Changing the security context
122USER appuser
sousaedu7389cfc2021-07-30 11:52:48 +0200123
David Garciaa60ec732021-03-17 15:28:47 +0100124########################################################################
Mike Marchetti13d76c82018-09-19 15:00:36 -0400125
Mike Marchetti13d76c82018-09-19 15:00:36 -0400126# The following ENV can be added with "docker run -e xxx' to configure LCM
127ENV OSMLCM_RO_HOST ro
128ENV OSMLCM_RO_PORT 9090
129ENV OSMLCM_RO_TENANT osm
130
131# VCA
132ENV OSMLCM_VCA_HOST vca
garciadeblasa2e41842019-12-18 11:05:24 +0100133ENV OSMLCM_VCA_PORT 17070
134ENV OSMLCM_VCA_USER admin
135ENV OSMLCM_VCA_SECRET secret
136# ENV OSMLCM_VCA_PUBKEY pubkey
137# ENV OSMLCM_VCA_CACERT cacert
138# ENV OSMLCM_VCA_ENABLEOSUPGRADE false
139# ENV OSMLCM_VCA_APTMIRROR http://archive.ubuntu.com/ubuntu/
Mike Marchetti13d76c82018-09-19 15:00:36 -0400140
141# database
142ENV OSMLCM_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300143ENV OSMLCM_DATABASE_URI mongodb://mongo:27017
144#ENV OSMLCM_DATABASE_HOST mongo
145#ENV OSMLCM_DATABASE_PORT 27017
146
147
Mike Marchetti13d76c82018-09-19 15:00:36 -0400148ENV OSMLCM_STORAGE_DRIVER local
149ENV OSMLCM_STORAGE_PATH /app/storage
150
151# message
152ENV OSMLCM_MESSAGE_DRIVER kafka
153ENV OSMLCM_MESSAGE_HOST kafka
154ENV OSMLCM_MESSAGE_PORT 9092
155
garciadeblas0ccc31e2019-11-22 15:28:50 +0100156# k8s
garciadeblas09bc8092024-05-30 22:35:30 +0200157ENV OSMLCM_VCA_HELMPATH /usr/local/bin/helm3
garciadeblas0ccc31e2019-11-22 15:28:50 +0100158ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
Adam Israel3f16fd52019-12-03 10:14:06 -0500159ENV OSMLCM_VCA_JUJUPATH /usr/local/bin/juju
garciadeblas0ccc31e2019-11-22 15:28:50 +0100160
Pedro Pereirac09bd232024-06-19 20:59:36 +0100161# post-renderers
garciadeblas2ed535b2024-12-16 17:02:11 +0100162ENV OSMLCM_MAINPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/mainPostRenderer/mainPostRenderer
163ENV OSMLCM_PODLABELSPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/podLabels/podLabels
164ENV OSMLCM_NODESELECTORPOSTRENDERERPATH /app/osm_lcm/n2vc/post-renderer-scripts/nodeSelector/nodeSelector
Pedro Pereirac09bd232024-06-19 20:59:36 +0100165
David Garcia1d5c2212021-05-28 16:24:24 +0200166# helm
167ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable
sousaedu7389cfc2021-07-30 11:52:48 +0200168# ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert>
David Garcia1d5c2212021-05-28 16:24:24 +0200169
garciadeblas0ccc31e2019-11-22 15:28:50 +0100170# logs
171# ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log
172# ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
173
tierno9f8b53b2019-09-13 13:19:48 +0000174HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
tierno62478d12020-01-09 17:25:29 +0000175 CMD python3 -m osm_lcm.lcm_hc || exit 1
tierno84a3c9a2018-10-24 11:02:57 +0200176
Mike Marchetti13d76c82018-09-19 15:00:36 -0400177# Run app.py when the container launches
sousaedu7389cfc2021-07-30 11:52:48 +0200178CMD [ "/bin/bash", "scripts/start.sh" ]