blob: 6a7901305e5051e07ee8e8fba778e8bec46ef7f2 [file] [log] [blame]
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -05001# Use an official pypy runtime as a base image
2FROM pypy:3
vagrant00bd7aa2018-01-20 15:12:44 +00003
4ENV INSROOT /opt/app
5ENV APPUSER snmptrap
6ENV APPDIR ${INSROOT}/${APPUSER}
7
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -05008# add group and user: ubuntu
vagrant00bd7aa2018-01-20 15:12:44 +00009RUN useradd -d ${APPDIR} ${APPUSER}
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050010#
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}
vagrant00bd7aa2018-01-20 15:12:44 +000014
15WORKDIR ${APPDIR}
16
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050017EXPOSE 162:6162/udp
vagrant00bd7aa2018-01-20 15:12:44 +000018
19# Copy the current directory contents into the container at ${APPDIR}
Vijay VK339ca1c2018-03-27 02:05:36 +010020COPY ./snmptrap/ ./bin/
vagrant00bd7aa2018-01-20 15:12:44 +000021COPY ./etc/ ./etc/
Ladue, David (dl3158)5f904e62018-03-20 16:55:35 -040022COPY requirements.txt ./
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050023#
24# RUN pip install -r requirements.txt
25RUN pip install --trusted-host files.pythonhosted.org -r requirements.txt
26
27RUN mkdir -p /etc \
28 && mkdir -p /etc/apt
29RUN apt-get update -y && apt-get install -y jq bc vim
vagrant00bd7aa2018-01-20 15:12:44 +000030
Ladue, David (dl3158)fb0aff82018-03-18 23:16:42 -040031RUN mkdir -p ${APPDIR}/data \
32 && mkdir -p ${APPDIR}/logs \
33 && mkdir -p ${APPDIR}/tmp \
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050034# && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \
Ladue, David (dl3158)fb0aff82018-03-18 23:16:42 -040035 && chmod a+w ${APPDIR}/data \
vagrant00bd7aa2018-01-20 15:12:44 +000036 && chmod a+w ${APPDIR}/logs \
Ladue, David (dl3158)fb0aff82018-03-18 23:16:42 -040037 && chmod a+w ${APPDIR}/tmp \
vagrant00bd7aa2018-01-20 15:12:44 +000038 && chmod 500 ${APPDIR}/etc \
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050039 && 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)93dcd542018-03-20 10:18:46 -040043
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050044# run everything from here on as $APPUSER, NOT ROOT!
45#USER ${APPUSER}
vagrant00bd7aa2018-01-20 15:12:44 +000046
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050047# map logs directory to external volume
vagrant00bd7aa2018-01-20 15:12:44 +000048VOLUME ${APPDIR}/logs
49
Ladue, David (dl3158)9c9a86f2020-02-14 12:02:30 -050050# launch container
Lusheng Ji4986bf02018-04-22 16:58:43 -040051CMD ["./bin/snmptrapd.sh", "start"]