370f1fe02bf3b6720685f1af943db9bf41494a3f
[osm/devops.git] / docker / LCM / Dockerfile
1 ##
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
19 FROM ubuntu:18.04 as INSTALL
20
21 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
22     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
23     gcc=4:7.4.* \
24     python3=3.6.* \
25     python3-dev=3.6.* \
26     python3-setuptools=39.0.* \
27     curl=7.58.* \
28     apt-transport-https=1.6.* \
29     gnupg2=2.2.* \
30     openssh-client=1:7.* && \
31     python3 -m easy_install pip==21.0.1 setuptools==51.0.0
32
33 # https://kubernetes.io/releases/
34 RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
35     && echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
36     && apt-get update && apt-get install -y kubectl=1.20.14-00
37
38 RUN curl https://get.helm.sh/helm-v2.17.0-linux-amd64.tar.gz --output helm-v2.17.0.tar.gz \
39     && tar -zxvf helm-v2.17.0.tar.gz \
40     && mv linux-amd64/helm /usr/local/bin/helm \
41     && rm -r linux-amd64/
42
43 # https://github.com/helm/helm/releases
44 RUN 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 \
46     && mv linux-amd64/helm /usr/local/bin/helm3 \
47     && rm -r linux-amd64/
48
49
50 ARG PYTHON3_OSM_COMMON_URL
51 ARG PYTHON3_OSM_LCM_URL
52 ARG PYTHON3_N2VC_URL
53
54 RUN curl $PYTHON3_OSM_COMMON_URL -o osm_common.deb
55 RUN dpkg -i ./osm_common.deb
56
57 RUN curl $PYTHON3_OSM_LCM_URL -o osm_lcm.deb
58 RUN dpkg -i ./osm_lcm.deb
59
60 RUN curl $PYTHON3_N2VC_URL -o osm_n2vc.deb
61 RUN dpkg -i ./osm_n2vc.deb
62
63 RUN pip3 install \
64     -r /usr/lib/python3/dist-packages/osm_common/requirements.txt \
65     -r /usr/lib/python3/dist-packages/osm_lcm/requirements.txt \
66     -r /usr/lib/python3/dist-packages/n2vc/requirements.txt
67
68 FROM ubuntu:18.04
69
70 RUN DEBIAN_FRONTEND=noninteractive apt-get --yes update && \
71     DEBIAN_FRONTEND=noninteractive apt-get --yes install \
72     python3-minimal=3.6.* \
73     ca-certificates \
74     && rm -rf /var/lib/apt/lists/*
75
76 COPY --from=INSTALL /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
77 COPY --from=INSTALL /usr/local/lib/python3.6/dist-packages  /usr/local/lib/python3.6/dist-packages
78
79 COPY --from=INSTALL /usr/bin/kubectl /usr/bin/kubectl
80 COPY --from=INSTALL /usr/local/bin/helm /usr/local/bin/helm
81 COPY --from=INSTALL /usr/local/bin/helm3 /usr/local/bin/helm3
82 COPY --from=INSTALL /usr/bin/scp /usr/bin/scp
83 COPY --from=INSTALL /usr/bin/ssh-keygen /usr/bin/ssh-keygen
84 COPY --from=INSTALL /usr/bin/ssh /usr/bin/ssh
85 COPY --from=INSTALL /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
86 COPY --from=INSTALL /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
87
88 COPY scripts/ scripts/
89
90 ########################################################################
91
92 # Used for local storage
93 VOLUME /app/storage
94 # Used for logs
95 VOLUME /app/log
96
97 # The following ENV can be added with "docker run -e xxx' to configure LCM
98 ENV OSMLCM_RO_HOST         ro
99 ENV OSMLCM_RO_PORT         9090
100 ENV OSMLCM_RO_TENANT       osm
101
102 # VCA
103 ENV OSMLCM_VCA_HOST        vca
104 ENV OSMLCM_VCA_PORT       17070
105 ENV OSMLCM_VCA_USER       admin
106 ENV OSMLCM_VCA_SECRET     secret
107 # ENV OSMLCM_VCA_PUBKEY     pubkey
108 # ENV OSMLCM_VCA_CACERT     cacert
109 # ENV OSMLCM_VCA_ENABLEOSUPGRADE false
110 # ENV OSMLCM_VCA_APTMIRROR  http://archive.ubuntu.com/ubuntu/
111
112 # database
113 ENV OSMLCM_DATABASE_DRIVER mongo
114 ENV OSMLCM_DATABASE_URI    mongodb://mongo:27017
115 #ENV OSMLCM_DATABASE_HOST    mongo
116 #ENV OSMLCM_DATABASE_PORT    27017
117
118
119 ENV OSMLCM_STORAGE_DRIVER  local
120 ENV OSMLCM_STORAGE_PATH    /app/storage
121
122 # message
123 ENV OSMLCM_MESSAGE_DRIVER  kafka
124 ENV OSMLCM_MESSAGE_HOST    kafka
125 ENV OSMLCM_MESSAGE_PORT    9092
126
127 # k8s
128 ENV OSMLCM_VCA_HELMPATH    /usr/local/bin/helm
129 ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
130 ENV OSMLCM_VCA_JUJUPATH    /usr/local/bin/juju
131
132 # helm
133 ENV OSMLCM_VCA_STABLEREPOURL https://charts.helm.sh/stable
134 # ENV OSMLCM_VCA_HELM_CA_CERTS <ca-cert>
135
136 # logs
137 # ENV OSMLCM_GLOBAL_LOGFILE  /app/log/lcm.log
138 # ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
139
140 HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
141   CMD python3 -m osm_lcm.lcm_hc || exit 1
142
143
144 # Run app.py when the container launches
145 CMD [ "/bin/bash", "scripts/start.sh" ]
146