blob: b6c998938c6ba6cf49cf923e3aa46bc55c31f6ef [file] [log] [blame]
calvinosanchbfb77902019-07-31 13:31:16 +00001##
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
beierlm5a6d1122022-01-26 10:18:21 -050019FROM ubuntu:20.04 as INSTALL
Mike Marchetti13d76c82018-09-19 15:00:36 -040020
David Garciaa60ec732021-03-17 15:28:47 +010021RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
22 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlm5a6d1122022-01-26 10:18:21 -050023 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
30RUN DEBIAN_FRONTEND=noninteractive apt-get --yes install \
31 apt-transport-https=2.0.* \
sousaedue99b45e2021-08-12 15:35:51 +010032 gnupg2=2.2.* \
beierlm5a6d1122022-01-26 10:18:21 -050033 openssh-client=1:8.*
Mike Marchetti13d76c82018-09-19 15:00:36 -040034
David Garciaa60ec732021-03-17 15:28:47 +010035RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
garciadeblas0ccc31e2019-11-22 15:28:50 +010036 && echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
aticig734099e2022-02-04 15:36:26 +030037 && apt-get update && apt-get install -y kubectl=1.23.3-00
garciadeblas0ccc31e2019-11-22 15:28:50 +010038
David Garciab7827fe2021-05-28 16:24:24 +020039RUN curl https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz --output helm-v2.17.0.tar.gz \
40 && tar -zxvf helm-v2.17.0.tar.gz \
garciadeblas0ccc31e2019-11-22 15:28:50 +010041 && mv linux-amd64/helm /usr/local/bin/helm \
42 && rm -r linux-amd64/
43
aticig734099e2022-02-04 15:36:26 +030044RUN curl https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz --output helm-v3.7.2.tar.gz \
45 && tar -zxvf helm-v3.7.2.tar.gz \
lloretgalleg5926de22020-11-16 10:27:49 +000046 && mv linux-amd64/helm /usr/local/bin/helm3 \
47 && rm -r linux-amd64/
48
David Garciaa60ec732021-03-17 15:28:47 +010049ARG PYTHON3_OSM_COMMON_URL
50ARG PYTHON3_OSM_LCM_URL
51ARG PYTHON3_N2VC_URL
Mike Marchetti13d76c82018-09-19 15:00:36 -040052
David Garciaa60ec732021-03-17 15:28:47 +010053RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
54RUN dpkg -i ./osm_common.deb
David Garcia5ac97812019-12-09 10:18:58 +010055
David Garciaa60ec732021-03-17 15:28:47 +010056RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb
57RUN dpkg -i ./osm_lcm.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040058
David Garciaa60ec732021-03-17 15:28:47 +010059RUN curl $PYTHON3_N2VC_URL -o osm_n2vc.deb
60RUN dpkg -i ./osm_n2vc.deb
Mike Marchetti13d76c82018-09-19 15:00:36 -040061
David Garciaa60ec732021-03-17 15:28:47 +010062RUN pip3 install \
63 -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
64 -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt \
65 -r /usr/lib/python3/dist-packages/n2vc/requirements.txt
66
beierlm5a6d1122022-01-26 10:18:21 -050067#######################################################################################
68FROM ubuntu:20.04 as FINAL
69
70ARG APT_PROXY
71RUN if [ ! -z $APT_PROXY ] ; then \
72 echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
73 echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
74 fi
David Garciaa60ec732021-03-17 15:28:47 +010075
76RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
garciadeblasca275682021-09-22 18:11:54 +020077 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
beierlm5a6d1122022-01-26 10:18:21 -050078 python3-minimal=3.8.* \
79 && rm -rf /var/lib/apt/lists/*
80
81RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
82 DEBIAN_FRONTEND=noninteractive apt-get --yes install \
garciadeblasd992a952021-09-23 17:43:15 +020083 ca-certificates \
84 && rm -rf /var/lib/apt/lists/*
beierlm9c33b5a2021-04-13 10:04:22 -040085
David Garciaa60ec732021-03-17 15:28:47 +010086COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
beierlm5a6d1122022-01-26 10:18:21 -050087COPY --from=INSTALL /usr/local/lib/python3.8/dist-packages /usr/local/lib/python3.8/dist-packages
David Garciaa60ec732021-03-17 15:28:47 +010088
89COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl
90COPY --from=INSTALL /usr/local/bin/helm /usr/local/bin/helm
91COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3
beierlm3b36f4d2021-04-13 17:01:53 -040092COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
beierlm249cd462021-04-07 14:19:03 -040093COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
beierlm9c33b5a2021-04-13 10:04:22 -040094COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
beierlm249cd462021-04-07 14:19:03 -040095COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
beierlm9c33b5a2021-04-13 10:04:22 -040096COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
David Garciaa60ec732021-03-17 15:28:47 +010097
garciadeblascc9fc1c2022-02-22 00:04:09 +010098COPY scripts/ /app/osm_lcm/scripts/
99
100# Creating the user for the app
101RUN groupadd -g 1000 appuser && \
102 useradd -u 1000 -g 1000 -d /app appuser && \
103 mkdir -p /app/osm_lcm && \
104 mkdir -p /app/storage/kafka && \
105 mkdir /app/log && \
106 chown -R appuser:appuser /app
107
garciadeblas310805f2022-02-28 17:05:09 +0100108RUN mkdir /opt/prometheus
109RUN chown appuser: /opt/prometheus
110
garciadeblascc9fc1c2022-02-22 00:04:09 +0100111WORKDIR /app/osm_lcm
112
113# Changing the security context
114USER appuser
sousaedufa6cbc12021-07-30 11:52:48 +0200115
David Garciaa60ec732021-03-17 15:28:47 +0100116########################################################################
Mike Marchetti13d76c82018-09-19 15:00:36 -0400117
Mike Marchetti13d76c82018-09-19 15:00:36 -0400118# The following ENV can be added with "docker run -e xxx' to configure LCM
119ENV OSMLCM_RO_HOST ro
120ENV OSMLCM_RO_PORT 9090
121ENV OSMLCM_RO_TENANT osm
122
123# VCA
124ENV OSMLCM_VCA_HOST vca
garciadeblasa2e41842019-12-18 11:05:24 +0100125ENV OSMLCM_VCA_PORT 17070
126ENV OSMLCM_VCA_USER admin
127ENV OSMLCM_VCA_SECRET secret
128# ENV OSMLCM_VCA_PUBKEY pubkey
129# ENV OSMLCM_VCA_CACERT cacert
130# ENV OSMLCM_VCA_ENABLEOSUPGRADE false
131# ENV OSMLCM_VCA_APTMIRROR http://archive.ubuntu.com/ubuntu/
Mike Marchetti13d76c82018-09-19 15:00:36 -0400132
133# database
134ENV OSMLCM_DATABASE_DRIVER mongo
Juancc084d72018-11-16 11:08:07 -0300135ENV OSMLCM_DATABASE_URI mongodb://mongo:27017
136#ENV OSMLCM_DATABASE_HOST mongo
137#ENV OSMLCM_DATABASE_PORT 27017
138
139
Mike Marchetti13d76c82018-09-19 15:00:36 -0400140ENV OSMLCM_STORAGE_DRIVER local
141ENV OSMLCM_STORAGE_PATH /app/storage
142
143# message
144ENV OSMLCM_MESSAGE_DRIVER kafka
145ENV OSMLCM_MESSAGE_HOST kafka
146ENV OSMLCM_MESSAGE_PORT 9092
147
garciadeblas0ccc31e2019-11-22 15:28:50 +0100148# k8s
149ENV OSMLCM_VCA_HELMPATH /usr/local/bin/helm
150ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
Adam Israel3f16fd52019-12-03 10:14:06 -0500151ENV OSMLCM_VCA_JUJUPATH /usr/local/bin/juju
garciadeblas0ccc31e2019-11-22 15:28:50 +0100152
David Garciab7827fe2021-05-28 16:24:24 +0200153# helm
154ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable
sousaedufa6cbc12021-07-30 11:52:48 +0200155# ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert>
David Garciab7827fe2021-05-28 16:24:24 +0200156
garciadeblas0ccc31e2019-11-22 15:28:50 +0100157# logs
158# ENV OSMLCM_GLOBAL_LOGFILE /app/log/lcm.log
159# ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
160
tierno9f8b53b2019-09-13 13:19:48 +0000161HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
tierno62478d12020-01-09 17:25:29 +0000162 CMD python3 -m osm_lcm.lcm_hc || exit 1
tierno84a3c9a2018-10-24 11:02:57 +0200163
Mike Marchetti13d76c82018-09-19 15:00:36 -0400164# Run app.py when the container launches
sousaedufa6cbc12021-07-30 11:52:48 +0200165CMD [ "/bin/bash", "scripts/start.sh" ]