blob: b00420ab0c31c3bbfe7185442d25d13a00d33bae [file] [log] [blame]
khenaidoofdbad6e2018-11-06 22:26:38 -05001# Copyright 2016 the original author or authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Matt Jeanneret1f5777d2019-10-23 10:42:52 -040014FROM voltha/voltha-python-base:1.0.0
khenaidoofdbad6e2018-11-06 22:26:38 -050015
Matt Jeanneret2e3051a2019-05-11 15:01:46 -040016# Update to have latest images
17RUN apt-get update && \
David Bainbridge5f3619c2019-07-10 22:51:09 +000018 apt-get install -y --no-install-recommends \
David Bainbridge5f3619c2019-07-10 22:51:09 +000019 openssh-server=1:7.2p2-4ubuntu2.8 \
20 && apt-get clean && rm -rf /var/lib/apt/lists/*
khenaidoofdbad6e2018-11-06 22:26:38 -050021
Matt Jeanneret2e3051a2019-05-11 15:01:46 -040022# Install adapter requirements.
23COPY requirements.txt /tmp/requirements.txt
24RUN pip install -r /tmp/requirements.txt
25
26ARG LOCAL_PYVOLTHA
27ARG LOCAL_PROTOS
28COPY local_imports/ /local_imports/
29RUN if [ -n "$LOCAL_PYVOLTHA" ] ; then \
William Kurkian190e38b2019-07-16 14:54:04 -040030 PYVOLTHA_PATH=$(ls /local_imports/pyvoltha/dist/) ; \
31 printf "/local_imports/pyvoltha/dist/%s\npyvoltha" "$PYVOLTHA_PATH" > pyvoltha-install.txt ; \
32 pip install -r pyvoltha-install.txt ; \
Matt Jeanneret2e3051a2019-05-11 15:01:46 -040033fi
34
35RUN if [ -n "$LOCAL_PROTOS" ] ; then \
William Kurkian190e38b2019-07-16 14:54:04 -040036 PROTOS_PATH=$(ls /local_imports/voltha-protos/dist/) ; \
37 printf "/local_imports/voltha-protos/dist/%s\nvoltha-protos" "$PROTOS_PATH" > protos-install.txt ; \
38 pip install -r protos-install.txt ; \
39 fi
khenaidoofdbad6e2018-11-06 22:26:38 -050040# Bundle app source
41RUN mkdir /voltha && touch /voltha/__init__.py
42ENV PYTHONPATH=/voltha
khenaidoofdbad6e2018-11-06 22:26:38 -050043COPY cli /voltha/python/cli
44RUN touch /voltha/python/__init__.py
45RUN touch /voltha/python/cli/__init__.py
46
khenaidoofdbad6e2018-11-06 22:26:38 -050047# Setup the voltha user
David Bainbridge5f3619c2019-07-10 22:51:09 +000048SHELL ["/bin/bash", "-o", "pipefail", "-c"]
khenaidoofdbad6e2018-11-06 22:26:38 -050049RUN useradd -b /home -d /home/voltha voltha -s /bin/bash
50RUN mkdir /home/voltha
51RUN chown voltha.voltha /home/voltha
52RUN echo "voltha:admin" | chpasswd
khenaidoofdbad6e2018-11-06 22:26:38 -050053RUN mkdir /var/run/sshd
54RUN echo 'root:screencast' | chpasswd
55RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
56
57# SSH login fix. Otherwise user is kicked off after login
58RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
59
60ENV NOTVISIBLE "in users profile"
61RUN echo "export VISIBLE=now" >> /etc/profile
62
63EXPOSE 22
64
khenaidoofdbad6e2018-11-06 22:26:38 -050065CMD ["/voltha/python/cli/setup.sh"]
Matt Jeanneret2e3051a2019-05-11 15:01:46 -040066
67# Label image
68ARG org_label_schema_version=unknown
69ARG org_label_schema_vcs_url=unknown
70ARG org_label_schema_vcs_ref=unknown
71ARG org_label_schema_build_date=unknown
72ARG org_opencord_vcs_commit_date=unknown
73
74LABEL org.label-schema.schema-version=1.0 \
75 org.label-schema.name=voltha-cli \
76 org.label-schema.version=$org_label_schema_version \
77 org.label-schema.vcs-url=$org_label_schema_vcs_url \
78 org.label-schema.vcs-ref=$org_label_schema_vcs_ref \
79 org.label-schema.build-date=$org_label_schema_build_date \
80 org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date