alex_sh | 9d980ce | 2017-08-23 17:30:56 -0400 | [diff] [blame^] | 1 | # Use an official Python runtime as a base image |
| 2 | FROM python:2.7 |
| 3 | |
| 4 | ENV INSROOT /opt/app |
| 5 | ENV APPUSER policy_handler |
| 6 | ENV APPDIR ${INSROOT}/${APPUSER} |
| 7 | |
| 8 | RUN useradd -d ${APPDIR} ${APPUSER} |
| 9 | |
| 10 | WORKDIR ${APPDIR} |
| 11 | |
| 12 | # Make port 25577 available to the world outside this container |
| 13 | EXPOSE 25577 |
| 14 | |
| 15 | # Copy the current directory contents into the container at ${APPDIR} |
| 16 | COPY ./*.py ./ |
| 17 | COPY ./*.in ./ |
| 18 | COPY ./*.txt ./ |
| 19 | COPY ./*.sh ./ |
| 20 | COPY ./policyhandler/ ./policyhandler/ |
| 21 | COPY ./etc/ ./etc/ |
| 22 | |
| 23 | RUN mkdir -p ${APPDIR}/logs \ |
| 24 | && mkdir -p ${APPDIR}/tmp \ |
| 25 | && mkdir -p ${APPDIR}/etc \ |
| 26 | && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \ |
| 27 | && chmod a+w ${APPDIR}/logs \ |
| 28 | && chmod 700 ${APPDIR}/tmp \ |
| 29 | && chmod 500 ${APPDIR}/etc \ |
| 30 | && chmod 500 ${APPDIR}/run_policy.sh \ |
| 31 | && ls -la && ls -la ./policyhandler |
| 32 | |
| 33 | # Install any needed packages specified in requirements.txt |
| 34 | RUN pip install -r requirements.txt |
| 35 | |
| 36 | USER ${APPUSER} |
| 37 | |
| 38 | VOLUME ${APPDIR}/logs |
| 39 | |
| 40 | # Run run_policy.sh when the container launches |
| 41 | CMD ["./run_policy.sh"] |