blob: 49a749d0a5354acc7dfd3cceb21f5160694cebb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# Copyright (c) 2023 J. F. Lucas. All rights reserved.
# (Previous versions by other authors did not have copyright notice.)
# Use an official pypy runtime as a base image
FROM pypy:3.8
ENV INSROOT /opt/app
ENV APPUSER snmptrap
ENV APPDIR ${INSROOT}/${APPUSER}
# add group and user: ubuntu
RUN useradd -d ${APPDIR} ${APPUSER}
#
# add group and user: ubuntu - for when DCAE platform evolves and runs as NON-ROOT!!!
# RUN addgroup -g 1000 -S ${APPUSER} && \
# adduser -u 1000 -S ${APPUSER} -G ${APPUSER}
WORKDIR ${APPDIR}
EXPOSE 6162/udp
# Copy the current directory contents into the container at ${APPDIR}
COPY ./snmptrap/ ./bin/
COPY ./etc/ ./etc/
COPY requirements.txt ./
#
# RUN pip install -r requirements.txt
RUN pip install --trusted-host files.pythonhosted.org -r requirements.txt
RUN mkdir -p /etc \
&& mkdir -p /etc/apt
RUN apt-get update -y && apt-get install -y jq bc vim
RUN mkdir -p ${APPDIR}/data \
&& mkdir -p ${APPDIR}/logs \
&& mkdir -p ${APPDIR}/tmp \
# && chown -R ${APPUSER}:${APPUSER} ${APPDIR} \
&& chmod a+w ${APPDIR}/data \
&& chmod a+w ${APPDIR}/logs \
&& chmod a+w ${APPDIR}/tmp \
&& chmod 500 ${APPDIR}/etc \
&& chmod 500 ${APPDIR}/bin/snmptrapd.sh \
&& chmod 500 ${APPDIR}/bin/scheduler.sh \
# && ln -s /usr/bin/python3 /usr/bin/python \
&& rm ${APPDIR}/requirements.txt
# run everything from here on as $APPUSER, NOT ROOT!
#USER ${APPUSER}
# map logs directory to external volume
VOLUME ${APPDIR}/logs
# launch container
CMD ["./bin/snmptrapd.sh", "start"]
|