khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 1 | # 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 Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 14 | FROM ubuntu:16.04 |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 15 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 16 | # Update to have latest images |
| 17 | RUN apt-get update && \ |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 18 | apt-get install -y --no-install-recommends \ |
| 19 | ca-certificates=20170717~16.04.2 \ |
| 20 | python=2.7.12-1~16.04 \ |
| 21 | openssl=1.0.2g-1ubuntu4.15 \ |
| 22 | iproute2=4.3.0-1ubuntu3.16.04.5 \ |
| 23 | libpcap-dev=1.7.4-2 \ |
| 24 | wget=1.17.1-1ubuntu1.5 \ |
| 25 | build-essential=12.1ubuntu2 \ |
| 26 | git=1:2.7.4-0ubuntu1.6 \ |
| 27 | binutils=2.26.1-1ubuntu1~16.04.8 \ |
| 28 | python-dev=2.7.12-1~16.04 \ |
| 29 | libffi-dev=3.2.1-4 \ |
| 30 | libssl-dev=1.0.2g-1ubuntu4.15 \ |
| 31 | openssh-server=1:7.2p2-4ubuntu2.8 \ |
| 32 | && apt-get clean && rm -rf /var/lib/apt/lists/* |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 33 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 34 | # Install current version of pip rather than outdated pip from apt |
| 35 | RUN wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py |
| 36 | RUN python /tmp/get-pip.py |
| 37 | |
| 38 | # Install adapter requirements. |
| 39 | COPY requirements.txt /tmp/requirements.txt |
| 40 | RUN pip install -r /tmp/requirements.txt |
| 41 | |
| 42 | ARG LOCAL_PYVOLTHA |
| 43 | ARG LOCAL_PROTOS |
| 44 | COPY local_imports/ /local_imports/ |
| 45 | RUN if [ -n "$LOCAL_PYVOLTHA" ] ; then \ |
William Kurkian | 190e38b | 2019-07-16 14:54:04 -0400 | [diff] [blame] | 46 | PYVOLTHA_PATH=$(ls /local_imports/pyvoltha/dist/) ; \ |
| 47 | printf "/local_imports/pyvoltha/dist/%s\npyvoltha" "$PYVOLTHA_PATH" > pyvoltha-install.txt ; \ |
| 48 | pip install -r pyvoltha-install.txt ; \ |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 49 | fi |
| 50 | |
| 51 | RUN if [ -n "$LOCAL_PROTOS" ] ; then \ |
William Kurkian | 190e38b | 2019-07-16 14:54:04 -0400 | [diff] [blame] | 52 | PROTOS_PATH=$(ls /local_imports/voltha-protos/dist/) ; \ |
| 53 | printf "/local_imports/voltha-protos/dist/%s\nvoltha-protos" "$PROTOS_PATH" > protos-install.txt ; \ |
| 54 | pip install -r protos-install.txt ; \ |
| 55 | fi |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 56 | # Bundle app source |
| 57 | RUN mkdir /voltha && touch /voltha/__init__.py |
| 58 | ENV PYTHONPATH=/voltha |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 59 | COPY cli /voltha/python/cli |
| 60 | RUN touch /voltha/python/__init__.py |
| 61 | RUN touch /voltha/python/cli/__init__.py |
| 62 | |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 63 | # Setup the voltha user |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 64 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 65 | RUN useradd -b /home -d /home/voltha voltha -s /bin/bash |
| 66 | RUN mkdir /home/voltha |
| 67 | RUN chown voltha.voltha /home/voltha |
| 68 | RUN echo "voltha:admin" | chpasswd |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 69 | RUN mkdir /var/run/sshd |
| 70 | RUN echo 'root:screencast' | chpasswd |
| 71 | RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 72 | |
| 73 | # SSH login fix. Otherwise user is kicked off after login |
| 74 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd |
| 75 | |
| 76 | ENV NOTVISIBLE "in users profile" |
| 77 | RUN echo "export VISIBLE=now" >> /etc/profile |
| 78 | |
| 79 | EXPOSE 22 |
| 80 | |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 81 | CMD ["/voltha/python/cli/setup.sh"] |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 82 | |
| 83 | # Label image |
| 84 | ARG org_label_schema_version=unknown |
| 85 | ARG org_label_schema_vcs_url=unknown |
| 86 | ARG org_label_schema_vcs_ref=unknown |
| 87 | ARG org_label_schema_build_date=unknown |
| 88 | ARG org_opencord_vcs_commit_date=unknown |
| 89 | |
| 90 | LABEL org.label-schema.schema-version=1.0 \ |
| 91 | org.label-schema.name=voltha-cli \ |
| 92 | org.label-schema.version=$org_label_schema_version \ |
| 93 | org.label-schema.vcs-url=$org_label_schema_vcs_url \ |
| 94 | org.label-schema.vcs-ref=$org_label_schema_vcs_ref \ |
| 95 | org.label-schema.build-date=$org_label_schema_build_date \ |
| 96 | org.opencord.vcs-commit-date=$org_opencord_vcs_commit_date |