Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 1 | # Use an official pypy runtime as a base image |
| 2 | FROM pypy:3 |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 3 | |
| 4 | ENV INSROOT /opt/app |
| 5 | ENV APPUSER snmptrap |
| 6 | ENV APPDIR ${INSROOT}/${APPUSER} |
| 7 | |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 8 | # add group and user: ubuntu |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 9 | RUN useradd -d ${APPDIR} ${APPUSER} |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 10 | # |
| 11 | # add group and user: ubuntu - for when DCAE platform evolves and runs as NON-ROOT!!! |
| 12 | # RUN addgroup -g 1000 -S ${APPUSER} && \ |
| 13 | # adduser -u 1000 -S ${APPUSER} -G ${APPUSER} |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 14 | |
| 15 | WORKDIR ${APPDIR} |
| 16 | |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 17 | EXPOSE 162:6162/udp |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 18 | |
| 19 | # Copy the current directory contents into the container at ${APPDIR} |
Vijay VK | 339ca1c | 2018-03-27 02:05:36 +0100 | [diff] [blame] | 20 | COPY ./snmptrap/ ./bin/ |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 21 | COPY ./etc/ ./etc/ |
Ladue, David (dl3158) | 5f904e6 | 2018-03-20 16:55:35 -0400 | [diff] [blame] | 22 | COPY requirements.txt ./ |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 23 | # |
| 24 | # RUN pip install -r requirements.txt |
| 25 | RUN pip install --trusted-host files.pythonhosted.org -r requirements.txt |
| 26 | |
| 27 | RUN mkdir -p /etc \ |
| 28 | && mkdir -p /etc/apt |
| 29 | RUN apt-get update -y && apt-get install -y jq bc vim |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 30 | |
Ladue, David (dl3158) | fb0aff8 | 2018-03-18 23:16:42 -0400 | [diff] [blame] | 31 | RUN mkdir -p ${APPDIR}/data \ |
| 32 | && mkdir -p ${APPDIR}/logs \ |
| 33 | && mkdir -p ${APPDIR}/tmp \ |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 34 | # && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \ |
Ladue, David (dl3158) | fb0aff8 | 2018-03-18 23:16:42 -0400 | [diff] [blame] | 35 | && chmod a+w ${APPDIR}/data \ |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 36 | && chmod a+w ${APPDIR}/logs \ |
Ladue, David (dl3158) | fb0aff8 | 2018-03-18 23:16:42 -0400 | [diff] [blame] | 37 | && chmod a+w ${APPDIR}/tmp \ |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 38 | && chmod 500 ${APPDIR}/etc \ |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 39 | && chmod 500 ${APPDIR}/bin/snmptrapd.sh \ |
| 40 | && chmod 500 ${APPDIR}/bin/scheduler.sh \ |
| 41 | # && ln -s /usr/bin/python3 /usr/bin/python \ |
| 42 | && rm ${APPDIR}/requirements.txt |
Ladue, David (dl3158) | 93dcd54 | 2018-03-20 10:18:46 -0400 | [diff] [blame] | 43 | |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 44 | # run everything from here on as $APPUSER, NOT ROOT! |
| 45 | #USER ${APPUSER} |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 46 | |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 47 | # map logs directory to external volume |
vagrant | 00bd7aa | 2018-01-20 15:12:44 +0000 | [diff] [blame] | 48 | VOLUME ${APPDIR}/logs |
| 49 | |
Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 50 | # launch container |
Lusheng Ji | 4986bf0 | 2018-04-22 16:58:43 -0400 | [diff] [blame] | 51 | CMD ["./bin/snmptrapd.sh", "start"] |