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 | 1f5777d | 2019-10-23 10:42:52 -0400 | [diff] [blame] | 14 | FROM voltha/voltha-python-base:1.0.0 |
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 \ |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 19 | openssh-server=1:7.2p2-4ubuntu2.8 \ |
| 20 | && apt-get clean && rm -rf /var/lib/apt/lists/* |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 21 | |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 22 | # Install adapter requirements. |
| 23 | COPY requirements.txt /tmp/requirements.txt |
| 24 | RUN pip install -r /tmp/requirements.txt |
| 25 | |
| 26 | ARG LOCAL_PYVOLTHA |
| 27 | ARG LOCAL_PROTOS |
| 28 | COPY local_imports/ /local_imports/ |
| 29 | RUN if [ -n "$LOCAL_PYVOLTHA" ] ; then \ |
William Kurkian | 190e38b | 2019-07-16 14:54:04 -0400 | [diff] [blame] | 30 | 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 Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 33 | fi |
| 34 | |
| 35 | RUN if [ -n "$LOCAL_PROTOS" ] ; then \ |
William Kurkian | 190e38b | 2019-07-16 14:54:04 -0400 | [diff] [blame] | 36 | 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 |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 40 | # Bundle app source |
| 41 | RUN mkdir /voltha && touch /voltha/__init__.py |
| 42 | ENV PYTHONPATH=/voltha |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 43 | COPY cli /voltha/python/cli |
| 44 | RUN touch /voltha/python/__init__.py |
| 45 | RUN touch /voltha/python/cli/__init__.py |
| 46 | |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 47 | # Setup the voltha user |
David Bainbridge | 5f3619c | 2019-07-10 22:51:09 +0000 | [diff] [blame] | 48 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 49 | RUN useradd -b /home -d /home/voltha voltha -s /bin/bash |
| 50 | RUN mkdir /home/voltha |
| 51 | RUN chown voltha.voltha /home/voltha |
| 52 | RUN echo "voltha:admin" | chpasswd |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 53 | RUN mkdir /var/run/sshd |
| 54 | RUN echo 'root:screencast' | chpasswd |
| 55 | RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config |
| 56 | |
| 57 | # SSH login fix. Otherwise user is kicked off after login |
| 58 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd |
| 59 | |
| 60 | ENV NOTVISIBLE "in users profile" |
| 61 | RUN echo "export VISIBLE=now" >> /etc/profile |
| 62 | |
| 63 | EXPOSE 22 |
| 64 | |
khenaidoo | fdbad6e | 2018-11-06 22:26:38 -0500 | [diff] [blame] | 65 | CMD ["/voltha/python/cli/setup.sh"] |
Matt Jeanneret | 2e3051a | 2019-05-11 15:01:46 -0400 | [diff] [blame] | 66 | |
| 67 | # Label image |
| 68 | ARG org_label_schema_version=unknown |
| 69 | ARG org_label_schema_vcs_url=unknown |
| 70 | ARG org_label_schema_vcs_ref=unknown |
| 71 | ARG org_label_schema_build_date=unknown |
| 72 | ARG org_opencord_vcs_commit_date=unknown |
| 73 | |
| 74 | LABEL 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 |