blob: 348676a9772b71b481e4e3470301859e8907176d [file] [log] [blame]
Alex Shatovb9b955c2018-03-08 13:12:23 -05001# ================================================================================
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_sh9d980ce2017-08-23 17:30:56 -040020FROM python:2.7
21
22ENV INSROOT /opt/app
23ENV APPUSER policy_handler
24ENV APPDIR ${INSROOT}/${APPUSER}
25
26RUN useradd -d ${APPDIR} ${APPUSER}
27
28WORKDIR ${APPDIR}
29
30# Make port 25577 available to the world outside this container
31EXPOSE 25577
32
Alex Shatovb9b955c2018-03-08 13:12:23 -050033# Copy the current directory content into the container at ${APPDIR}
alex_sh9d980ce2017-08-23 17:30:56 -040034COPY ./*.py ./
35COPY ./*.in ./
36COPY ./*.txt ./
Alex Shatovb9b955c2018-03-08 13:12:23 -050037COPY ./run_policy.sh ./
alex_sh9d980ce2017-08-23 17:30:56 -040038COPY ./policyhandler/ ./policyhandler/
39COPY ./etc/ ./etc/
Alex Shatovb9b955c2018-03-08 13:12:23 -050040COPY ./etc_customize/ ./etc_customize/
alex_sh9d980ce2017-08-23 17:30:56 -040041
42RUN mkdir -p ${APPDIR}/logs \
alex_sh9d980ce2017-08-23 17:30:56 -040043 && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \
44 && chmod a+w ${APPDIR}/logs \
alex_sh9d980ce2017-08-23 17:30:56 -040045 && chmod 500 ${APPDIR}/etc \
46 && chmod 500 ${APPDIR}/run_policy.sh \
Alex Shatovb9b955c2018-03-08 13:12:23 -050047 && 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_sh9d980ce2017-08-23 17:30:56 -040051
52USER ${APPUSER}
53
54VOLUME ${APPDIR}/logs
55
56# Run run_policy.sh when the container launches
57CMD ["./run_policy.sh"]