Update helm and kubectl versions in LCM and tests Dockerfile
[osm/devops.git] / docker / LCM / Dockerfile
1 #######################################################################################
2 # Copyright ETSI Contributors and Others.
3 #
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
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,
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 #######################################################################################
17
18 FROM ubuntu:22.04 as INSTALL
19
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
26 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
27     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
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
35 ########### End of common preparation
36
37 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
38     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
39     apt-transport-https=2.4.* \
40     gnupg2=2.2.* \
41     openssh-client=1:8.* \
42     && rm -rf /var/lib/apt/lists/*
43
44 # https://kubernetes.io/releases/
45 RUN curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/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.30/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list \
47     && apt-get update && apt-get install -y kubectl=1.30.1-1.1
48
49 RUN 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 \
51     && mv linux-amd64/helm /usr/local/bin/helm \
52     && rm -r linux-amd64/
53 # https://github.com/helm/helm/releases
54 RUN curl https://get.helm.sh/helm-v3.15.1-linux-amd64.tar.gz --output helm-v3.15.1.tar.gz \
55     && tar -zxvf helm-v3.15.1.tar.gz \
56     && mv linux-amd64/helm /usr/local/bin/helm3 \
57     && rm -r linux-amd64/
58
59 ARG PYTHON3_OSM_COMMON_URL
60 ARG PYTHON3_OSM_LCM_URL
61 ARG PYTHON3_N2VC_URL
62
63 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
64 RUN dpkg -i ./osm_common.deb
65
66 RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb
67 RUN dpkg -i ./osm_lcm.deb
68
69 RUN curl $PYTHON3_N2VC_URL -o osm_n2vc.deb
70 RUN dpkg -i ./osm_n2vc.deb
71
72 RUN pip3 install \
73     -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
74     -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt \
75     -r /usr/lib/python3/dist-packages/n2vc/requirements.txt
76
77 #######################################################################################
78 FROM ubuntu:22.04 as FINAL
79
80 ARG APT_PROXY
81 RUN if [ ! -z $APT_PROXY ] ; then \
82     echo "Acquire::http::Proxy \"$APT_PROXY\";" > /etc/apt/apt.conf.d/proxy.conf ;\
83     echo "Acquire::https::Proxy \"$APT_PROXY\";" >> /etc/apt/apt.conf.d/proxy.conf ;\
84     fi
85
86 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
87     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
88     python3-minimal=3.10.* \
89     && rm -rf /var/lib/apt/lists/*
90
91 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
92 COPY --from=INSTALL /usr/local/lib/python3.10/dist-packages  /usr/local/lib/python3.10/dist-packages
93
94 #######################################################################################
95 # End of common preparation
96
97 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
98     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
99     ca-certificates \
100     && rm -rf /var/lib/apt/lists/*
101
102 RUN rm -f /etc/apt/apt.conf.d/proxy.conf
103
104 COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl
105 COPY --from=INSTALL /usr/local/bin/helm /usr/local/bin/helm
106 COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3
107 COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
108 COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
109 COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
110 COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
111 COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
112
113 COPY scripts/ /app/osm_lcm/scripts/
114
115 # Creating the user for the app
116 RUN groupadd -g 1000 appuser && \
117     useradd -u 1000 -g 1000 -d /app appuser && \
118     mkdir -p /app/osm_lcm && \
119     mkdir -p /app/storage/kafka && \
120     mkdir /app/log && \
121     chown -R appuser:appuser /app && \
122     chown appuser: /etc/ssl/certs/ca-certificates.crt
123
124
125 WORKDIR /app/osm_lcm
126
127 # Changing the security context
128 USER appuser
129
130 ########################################################################
131
132 # The following ENV can be added with "docker run -e xxx' to configure LCM
133 ENV OSMLCM_RO_HOST         ro
134 ENV OSMLCM_RO_PORT         9090
135 ENV OSMLCM_RO_TENANT       osm
136
137 # VCA
138 ENV OSMLCM_VCA_HOST        vca
139 ENV OSMLCM_VCA_PORT       17070
140 ENV OSMLCM_VCA_USER       admin
141 ENV OSMLCM_VCA_SECRET     secret
142 # ENV OSMLCM_VCA_PUBKEY     pubkey
143 # ENV OSMLCM_VCA_CACERT     cacert
144 # ENV OSMLCM_VCA_ENABLEOSUPGRADE false
145 # ENV OSMLCM_VCA_APTMIRROR  http://archive.ubuntu.com/ubuntu/
146
147 # database
148 ENV OSMLCM_DATABASE_DRIVER mongo
149 ENV OSMLCM_DATABASE_URI    mongodb://mongo:27017
150 #ENV OSMLCM_DATABASE_HOST    mongo
151 #ENV OSMLCM_DATABASE_PORT    27017
152
153
154 ENV OSMLCM_STORAGE_DRIVER  local
155 ENV OSMLCM_STORAGE_PATH    /app/storage
156
157 # message
158 ENV OSMLCM_MESSAGE_DRIVER  kafka
159 ENV OSMLCM_MESSAGE_HOST    kafka
160 ENV OSMLCM_MESSAGE_PORT    9092
161
162 # k8s
163 ENV OSMLCM_VCA_HELMPATH    /usr/local/bin/helm
164 ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
165 ENV OSMLCM_VCA_JUJUPATH    /usr/local/bin/juju
166
167 # helm
168 ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable
169 # ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert>
170
171 # logs
172 # ENV OSMLCM_GLOBAL_LOGFILE  /app/log/lcm.log
173 # ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
174
175 HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
176   CMD python3 -m osm_lcm.lcm_hc || exit 1
177
178 # Run app.py when the container launches
179 CMD [ "/bin/bash", "scripts/start.sh" ]