Pin libjuju version to 2.8.2
[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 # This creates som/LCM docker from from last stable package
20
21 FROM ubuntu:18.04
22
23 # Set the working directory to /app
24 WORKDIR /app/osm_lcm
25
26 # avoid extra information from packages
27 RUN echo 'path-exclude /usr/share/doc/*\n\
28 path-include /usr/share/doc/*/copyright\n\
29 path-exclude /usr/share/man/*\n\
30 path-exclude /usr/share/groff/*\n\
31 path-exclude /usr/share/info/*\n\
32 path-exclude /usr/share/lintian/*\n\
33 path-exclude /usr/share/linda/*\n'\
34 > /etc/dpkg/dpkg.cfg.d/01_nodoc && \
35     echo  'APT::Install-Recommends "false";\n\
36 APT::AutoRemove::RecommendsImportant "false";\n\
37 APT::AutoRemove::SuggestsImportant "false";\n'\
38 > /etc/apt/apt.conf.d/99_norecommends
39
40 RUN apt-get update && apt-get -y install curl software-properties-common
41
42 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git make python3 \
43     gpg-agent python3-pip python3-pymongo python3-aiohttp \
44     python3-all python3-setuptools openssh-client libffi-dev libssl-dev \
45     python3-bitarray python3-regex python3-lxml dh-python wget tox \
46     python3-cffi \
47     && python3 -m pip install -U pip \
48     && python3 -m pip install -U aiokafka lxml six enum34 \
49     && python3 -m pip install requests \
50     && python3 -m pip install -U juju==2.8.2 \
51     && rm -rf /var/lib/apt/lists/*
52
53 # RUN git clone https://osm.etsi.org/gerrit/osm/N2VC.git \
54 #     && cd N2VC \
55 #     && cd modules/libjuju && python3 setup.py develop && cd ../.. \
56 #     && python3 -m pip install -U -r requirements.txt
57
58 RUN apt-get update && apt-get install -y curl xz-utils apt-transport-https \
59     && curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
60     && echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
61     && apt-get update && apt-get install -y kubectl
62
63 RUN curl https://get.helm.sh/helm-v2.15.2-linux-amd64.tar.gz --output helm-v2.15.2.tar.gz \
64     && tar -zxvf helm-v2.15.2.tar.gz \
65     && mv linux-amd64/helm /usr/local/bin/helm \
66     && rm -r linux-amd64/
67
68 RUN curl -L https://launchpad.net/juju/2.7/2.7.6/+download/juju-2.7.6-k8s.tar.xz --output juju-2.7.6-k8s.tar.xz \
69     && tar -xvf juju-2.7.6-k8s.tar.xz \
70     && mv juju /usr/local/bin/juju
71
72 ARG REPOSITORY_BASE=http://osm-download.etsi.org/repository/osm/debian
73 ARG RELEASE=ReleaseEIGHT-daily
74 ARG REPOSITORY_KEY=OSM%20ETSI%20Release%20Key.gpg
75 ARG REPOSITORY=testing
76
77 RUN curl ${REPOSITORY_BASE}/${RELEASE}/${REPOSITORY_KEY} | apt-key add -
78 RUN add-apt-repository -y "deb ${REPOSITORY_BASE}/${RELEASE} ${REPOSITORY} LCM N2VC common" && apt update
79
80 RUN python3 -m pip install -U "cffi==1.13.2"
81
82 RUN python3 -m pip install grpcio-tools grpclib
83
84 ARG LCM_VERSION
85 ARG COMMON_VERSION
86 ARG N2VC_VERSION
87
88 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
89      python3-osm-lcm${LCM_VERSION} \
90      python3-osm-common${COMMON_VERSION} \
91      python3-n2vc${N2VC_VERSION} \
92      && rm -rf /var/lib/apt/lists/*
93
94 LABEL Maintainer="alfonso.tiernosepulveda@telefonica.com" \
95       Description="This implements life cycle management engine for OSM" \
96       Version="1.0" \
97       Author="Alfonso Tierno"
98
99 # Used for local storage
100 VOLUME /app/storage
101 # Used for logs
102 VOLUME /app/log
103
104 # The following ENV can be added with "docker run -e xxx' to configure LCM
105 ENV OSMLCM_RO_HOST         ro
106 ENV OSMLCM_RO_PORT         9090
107 ENV OSMLCM_RO_TENANT       osm
108
109 # VCA
110 ENV OSMLCM_VCA_HOST        vca
111 ENV OSMLCM_VCA_PORT       17070
112 ENV OSMLCM_VCA_USER       admin
113 ENV OSMLCM_VCA_SECRET     secret
114 # ENV OSMLCM_VCA_PUBKEY     pubkey
115 # ENV OSMLCM_VCA_CACERT     cacert
116 # ENV OSMLCM_VCA_ENABLEOSUPGRADE false
117 # ENV OSMLCM_VCA_APTMIRROR  http://archive.ubuntu.com/ubuntu/
118
119 # database
120 ENV OSMLCM_DATABASE_DRIVER mongo
121 ENV OSMLCM_DATABASE_URI    mongodb://mongo:27017
122 #ENV OSMLCM_DATABASE_HOST    mongo
123 #ENV OSMLCM_DATABASE_PORT    27017
124
125
126 ENV OSMLCM_STORAGE_DRIVER  local
127 ENV OSMLCM_STORAGE_PATH    /app/storage
128
129 # message
130 ENV OSMLCM_MESSAGE_DRIVER  kafka
131 ENV OSMLCM_MESSAGE_HOST    kafka
132 ENV OSMLCM_MESSAGE_PORT    9092
133
134 # k8s
135 ENV OSMLCM_VCA_HELMPATH    /usr/local/bin/helm
136 ENV OSMLCM_VCA_KUBECTLPATH /usr/bin/kubectl
137 ENV OSMLCM_VCA_JUJUPATH    /usr/local/bin/juju
138
139 # logs
140 # ENV OSMLCM_GLOBAL_LOGFILE  /app/log/lcm.log
141 # ENV OSMLCM_GLOBAL_LOGLEVEL DEBUG
142
143 HEALTHCHECK --start-period=120s --interval=30s --timeout=30s --retries=1 \
144   CMD python3 -m osm_lcm.lcm_hc || exit 1
145
146
147 # Run app.py when the container launches
148 CMD python3 -m osm_lcm.lcm
149