efiacor | 9b53268 | 2019-11-06 11:08:54 +0000 | [diff] [blame] | 1 | # ============LICENSE_START=================================================== |
efiacor | 8b3fc62 | 2020-01-24 13:19:01 +0000 | [diff] [blame] | 2 | # Copyright (C) 2020 Nordix Foundation. |
efiacor | 9b53268 | 2019-11-06 11:08:54 +0000 | [diff] [blame] | 3 | # ============================================================================ |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain 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, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # SPDX-License-Identifier: Apache-2.0 |
| 17 | # ============LICENSE_END===================================================== |
| 18 | |
| 19 | FROM python:3.7-slim-buster |
| 20 | MAINTAINER lego@est.tech |
| 21 | |
| 22 | ENV PMSHUSER=pmsh \ |
| 23 | APPDIR="/opt/app/pmsh" \ |
efiacor | 9b53268 | 2019-11-06 11:08:54 +0000 | [diff] [blame] | 24 | # set PATH & PYTHONPATH vars |
| 25 | PATH=/usr/local/lib/python3.7/bin:$PATH:$APPDIR/bin \ |
| 26 | PYTHONPATH=/usr/local/lib/python3.7/site-packages:./mod:./:$PYTHONPATH:$APPDIR/bin \ |
efiacor | 8b3fc62 | 2020-01-24 13:19:01 +0000 | [diff] [blame] | 27 | REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt \ |
| 28 | LOGS_PATH="/var/log/ONAP/dcaegen2/services/pmsh" |
efiacor | 9b53268 | 2019-11-06 11:08:54 +0000 | [diff] [blame] | 29 | |
| 30 | WORKDIR $APPDIR |
| 31 | |
| 32 | # add non root user & group |
efiacor | bc9f41e | 2020-02-12 23:31:16 +0000 | [diff] [blame] | 33 | RUN addgroup --system $PMSHUSER && adduser --ingroup $PMSHUSER --system $PMSHUSER && \ |
| 34 | # create and chown the LOGS_PATH |
| 35 | mkdir -p $LOGS_PATH && \ |
| 36 | chown -R $PMSHUSER:$PMSHUSER $LOGS_PATH |
efiacor | 9b53268 | 2019-11-06 11:08:54 +0000 | [diff] [blame] | 37 | |
| 38 | COPY setup.py ./ |
| 39 | COPY requirements.txt ./ |
| 40 | COPY ./pmsh_service ./bin/ |
| 41 | |
| 42 | # run the pip install |
| 43 | RUN pip install --upgrade pip && \ |
| 44 | pip install -r requirements.txt && \ |
| 45 | pip install -e . && \ |
| 46 | # change own & perms on entrypoint |
| 47 | chown -R $PMSHUSER:$PMSHUSER $APPDIR && \ |
| 48 | chmod 500 $APPDIR/bin/*.py |
| 49 | |
| 50 | # set to non root user |
| 51 | USER $PMSHUSER |
| 52 | |
| 53 | # run the app |
AndyWalshe | de549f5 | 2020-02-13 12:55:49 +0000 | [diff] [blame] | 54 | ENTRYPOINT ["python", "./bin/pmsh_service_main.py"] |