blob: cfb9735cf17b892226b331b8377f35e107e83cc3 [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.* \
42 && rm -rf /var/lib/apt/lists/*
Mike Marchetti13d76c82018-09-19 15:00:36 -040043
garciadeblasf6f45842021-12-14 17:46:08 +010044# https://kubernetes.io/releases/
Pedro Escaleira6272e402024-03-05 17:56:23 +000045RUN curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg \
46 && echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list \
47 && apt-get update && apt-get install -y kubectl=1.28.2-1.1
garciadeblas0ccc31e2019-11-22 15:28:50 +010048
David Garcia1d5c2212021-05-28 16:24:24 +020049RUN curl https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz --output helm-v2.17.0.tar.gz \
50 && tar -zxvf helm-v2.17.0.tar.gz \
garciadeblas0ccc31e2019-11-22 15:28:50 +010051 && mv linux-amd64/helm /usr/local/bin/helm \
52 && rm -r linux-amd64/
53
garciadeblasf6f45842021-12-14 17:46:08 +010054# https://github.com/helm/helm/releases
garciadeblas115f5b92023-05-30 16:24:19 +020055RUN curl https://get.helm.sh/helm-v3.11.3-linux-amd64.tar.gz --output helm-v3.11.3.tar.gz \
56 && tar -zxvf helm-v3.11.3.tar.gz \
lloretgalleg5926de22020-11-16 10:27:49 +000057 && mv linux-amd64/helm /usr/local/bin/helm3 \
58 && rm -r linux-amd64/
59
David Garciaa60ec732021-03-17 15:28:47 +010060ARG PYTHON3_OSM_COMMON_URL
61ARG PYTHON3_OSM_LCM_URL
62ARG PYTHON3_N2VC_URL
Mike Marchetti13d76c82018-09-19 15:00:36 -040063
David Garciaa60ec732021-03-17 15:28:47 +010064RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
65RUN dpkg -i ./osm_common.deb
David Garcia5ac97812019-12-09 10:18:58 +010066
David Garciaa60ec732021-03-17 15:28:47 +010067RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb
68RUN dpkg -i ./osm_lcm.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040069
David Garciaa60ec732021-03-17 15:28:47 +010070RUN curl $PYTHON3_N2VC_URL -o osm_n2vc.deb
71RUN dpkg -i ./osm_n2vc.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040072
David Garciaa60ec732021-03-17 15:28:47 +010073RUN pip3 install \
74 -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
75 -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt \
76 -r /usr/lib/python3/dist-packages/n2vc/requirements.txt
77
beierlmd7449362022-01-13 10:53:08 -050078#######################################################################################
Mark Beierl02feb8e2023-05-10 11:44:11 -040079FROM ubuntu:22.04 as FINAL
beierlmd7449362022-01-13 10:53:08 -050080
81ARG APT_PROXY
82RUN if [ ! -z $APT_PROXY ] ; then \
83 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
84 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
85 fi
David Garciaa60ec732021-03-17 15:28:47 +010086
87RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
garciadeblas15897d62021-09-22 18:11:54 +020088 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
Mark Beierl02feb8e2023-05-10 11:44:11 -040089 python3-minimal=3.10.* \
beierlmd7449362022-01-13 10:53:08 -050090 && rm -rf /var/lib/apt/lists/*
91
Mark Beierl02feb8e2023-05-10 11:44:11 -040092COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
93COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages
94
95#######################################################################################
garciadeblas21503ab2023-06-28 14:31:27 +020096# End of common preparation
Mark Beierl02feb8e2023-05-10 11:44:11 -040097
beierlmd7449362022-01-13 10:53:08 -050098RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
99 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
garciadeblas6ba74b52021-09-23 17:43:15 +0200100 ca-certificates \
101 && rm -rf /var/lib/apt/lists/*
beierlm9c33b5a2021-04-13 10:04:22 -0400102
Mark Beierle5b9ba62022-09-08 05:44:06 -0400103RUN rm -f /etc/apt/apt.conf.d/proxy.conf
104
David Garciaa60ec732021-03-17 15:28:47 +0100105COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl
106COPY --from=INSTALL /usr/local/bin/helm /usr/local/bin/helm
107COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3
beierlm3b36f4d2021-04-13 17:01:53 -0400108COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
beierlm249cd462021-04-07 14:19:03 -0400109COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
beierlm9c33b5a2021-04-13 10:04:22 -0400110COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
beierlm249cd462021-04-07 14:19:03 -0400111COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
beierlm9c33b5a2021-04-13 10:04:22 -0400112COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
David Garciaa60ec732021-03-17 15:28:47 +0100113
Mark Beierlabc56a92022-02-11 08:56:32 -0500114COPY scripts/ /app/osm_lcm/scripts/
115
116# Creating the user for the app
117RUN groupadd -g 1000 appuser && \
118 useradd -u 1000 -g 1000 -d /app appuser && \
119 mkdir -p /app/osm_lcm && \
120 mkdir -p /app/storage/kafka && \
121 mkdir /app/log && \
David Garcia85130462022-04-27 13:46:34 +0200122 chown -R appuser:appuser /app && \
123 chown appuser: /etc/ssl/certs/ca-certificates.crt
124
Mark Beierlabc56a92022-02-11 08:56:32 -0500125
126WORKDIR /app/osm_lcm
127
128# Changing the security context
129USER appuser
sousaedu7389cfc2021-07-30 11:52:48 +0200130
David Garciaa60ec732021-03-17 15:28:47 +0100131########################################################################
Mike Marchetti13d76c82018-09-19 15:00:36 -0400132
Mike Marchetti13d76c82018-09-19 15:00:36 -0400133# The following ENV can be added with "docker run -e xxx' to configure LCM
134ENV OSMLCM_RO_HOST ro
135ENV OSMLCM_RO_PORT 9090
136ENV OSMLCM_RO_TENANT osm
137
138# VCA
139ENV OSMLCM_VCA_HOST vca
garciadeblasa2e41842019-12-18 11:05:24 +0100140ENV OSMLCM_VCA_PORT 17070
141ENV OSMLCM_VCA_USER admin
142ENV OSMLCM_VCA_SECRET secret
143# ENV OSMLCM_VCA_PUBKEY pubkey
144# ENV OSMLCM_VCA_CACERT cacert
145# ENV OSMLCM_VCA_ENABLEOSUPGRADE false
146# ENV OSMLCM_VCA_APTMIRROR http://archive.ubuntu.com/ubuntu/
Mike Marchetti13d76c82018-09-19 15:00:36 -0400147
148# database
149ENV OSMLCM_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300150ENV OSMLCM_DATABASE_URI mongodb://mongo:27017
151#ENV OSMLCM_DATABASE_HOST mongo
152#ENV OSMLCM_DATABASE_PORT 27017
153
154
Mike Marchetti13d76c82018-09-19 15:00:36 -0400155ENV OSMLCM_STORAGE_DRIVER local
156ENV OSMLCM_STORAGE_PATH /app/storage
157
158# message
159ENV OSMLCM_MESSAGE_DRIVER kafka
160ENV OSMLCM_MESSAGE_HOST kafka
161ENV OSMLCM_MESSAGE_PORT 9092
162
garciadeblas0ccc31e2019-11-22 15:28:50 +0100163# k8s
164ENV OSMLCM_VCA_HELMPATH /usr/local/bin/helm
165ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
Adam Israel3f16fd52019-12-03 10:14:06 -0500166ENV OSMLCM_VCA_JUJUPATH /usr/local/bin/juju
garciadeblas0ccc31e2019-11-22 15:28:50 +0100167
David Garcia1d5c2212021-05-28 16:24:24 +0200168# helm
169ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable
sousaedu7389cfc2021-07-30 11:52:48 +0200170# ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert>
David Garcia1d5c2212021-05-28 16:24:24 +0200171
garciadeblas0ccc31e2019-11-22 15:28:50 +0100172# logs
173# ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log
174# ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
175
tierno9f8b53b2019-09-13 13:19:48 +0000176HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
tierno62478d12020-01-09 17:25:29 +0000177 CMD python3 -m osm_lcm.lcm_hc || exit 1
tierno84a3c9a2018-10-24 11:02:57 +0200178
Mike Marchetti13d76c82018-09-19 15:00:36 -0400179# Run app.py when the container launches
sousaedu7389cfc2021-07-30 11:52:48 +0200180CMD [ "/bin/bash", "scripts/start.sh" ]