Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame^] | 1 | # ================================================================================ |
| 2 | # Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. |
| 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 | # ============LICENSE_END========================================================= |
| 16 | # |
| 17 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 18 | |
| 19 | # Use the official Python as the base image |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 20 | FROM python:2.7 |
| 21 | |
| 22 | ENV INSROOT /opt/app |
| 23 | ENV APPUSER policy_handler |
| 24 | ENV APPDIR ${INSROOT}/${APPUSER} |
| 25 | |
| 26 | RUN useradd -d ${APPDIR} ${APPUSER} |
| 27 | |
| 28 | WORKDIR ${APPDIR} |
| 29 | |
| 30 | # Make port 25577 available to the world outside this container |
| 31 | EXPOSE 25577 |
| 32 | |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame^] | 33 | # Copy the current directory content into the container at ${APPDIR} |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 34 | COPY ./*.py ./ |
| 35 | COPY ./*.in ./ |
| 36 | COPY ./*.txt ./ |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame^] | 37 | COPY ./run_policy.sh ./ |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 38 | COPY ./policyhandler/ ./policyhandler/ |
| 39 | COPY ./etc/ ./etc/ |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame^] | 40 | COPY ./etc_customize/ ./etc_customize/ |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 41 | |
| 42 | RUN mkdir -p ${APPDIR}/logs \ |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 43 | && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \ |
| 44 | && chmod a+w ${APPDIR}/logs \ |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 45 | && chmod 500 ${APPDIR}/etc \ |
| 46 | && chmod 500 ${APPDIR}/run_policy.sh \ |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame^] | 47 | && pip install -r requirements.txt \ |
| 48 | && (CUST_SH=./etc_customize/customize.sh && test -e ${CUST_SH} && chmod 500 ${CUST_SH} \ |
| 49 | && (${CUST_SH} | tee -a logs/"customize_${APPUSER}_$(date +%Y_%m%d-%H%M%S).log" 2>&1)) \ |
| 50 | && ls -laR ${APPDIR}/ |
alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame] | 51 | |
| 52 | USER ${APPUSER} |
| 53 | |
| 54 | VOLUME ${APPDIR}/logs |
| 55 | |
| 56 | # Run run_policy.sh when the container launches |
| 57 | CMD ["./run_policy.sh"] |