forked from cowrie/docker-cowrie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
98 lines (80 loc) · 2.97 KB
/
Dockerfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This Dockerfile contains two images, `builder` and `runtime`.
# `builder` contains all necessary code to build
# `runtime` is stripped down.
ARG ARCH=
FROM ${ARCH}debian:buster-slim as builder
LABEL maintainer="Michel Oosterhof <michel@oosterhof.net>"
WORKDIR /
ENV COWRIE_GROUP=cowrie \
COWRIE_USER=cowrie \
COWRIE_HOME=/cowrie
# Set locale to UTF-8, otherwise upstream libraries have bytes/string conversion issues
ENV LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
RUN groupadd -r -g 1000 ${COWRIE_GROUP} && \
useradd -r -u 1000 -d ${COWRIE_HOME} -m -g ${COWRIE_GROUP} ${COWRIE_USER}
# Set up Debian prereqs
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update && \
apt-get install -y \
-o APT::Install-Suggests=false \
-o APT::Install-Recommends=false \
python3-pip \
libssl-dev \
ca-certificates \
libffi-dev \
python3-dev \
python3-venv \
python3 \
gcc \
git \
build-essential \
python3-virtualenv \
libsnappy-dev \
default-libmysqlclient-dev && \
rm -rf /var/lib/apt/lists/*
# Build a cowrie environment from github master HEAD.
USER ${COWRIE_USER}
RUN git clone --separate-git-dir=/tmp/cowrie.git https://github.com/cowrie/cowrie ${COWRIE_HOME}/cowrie-git && \
cd ${COWRIE_HOME} && \
python3 -m venv cowrie-env && \
. cowrie-env/bin/activate && \
pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade cffi && \
pip install --no-cache-dir --upgrade setuptools && \
pip install --no-cache-dir --upgrade -r ${COWRIE_HOME}/cowrie-git/requirements.txt && \
pip install --no-cache-dir --upgrade -r ${COWRIE_HOME}/cowrie-git/requirements-output.txt
FROM ${ARCH}debian:buster-slim AS runtime
LABEL maintainer="Michel Oosterhof <michel@oosterhof.net>"
ENV COWRIE_GROUP=cowrie \
COWRIE_USER=cowrie \
COWRIE_HOME=/cowrie
RUN groupadd -r -g 1000 ${COWRIE_GROUP} && \
useradd -r -u 1000 -d ${COWRIE_HOME} -m -g ${COWRIE_GROUP} ${COWRIE_USER}
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update && \
apt-get install -y \
-o APT::Install-Suggests=false \
-o APT::Install-Recommends=false \
libssl1.1 \
ca-certificates \
libffi6 \
procps \
python3 \
python3-distutils && \
rm -rf /var/lib/apt/lists/* && \
ln -s /usr/bin/python3 /usr/local/bin/python
COPY --from=builder ${COWRIE_HOME} ${COWRIE_HOME}
RUN chown -R ${COWRIE_USER}:${COWRIE_GROUP} ${COWRIE_HOME}
ENV PATH=${COWRIE_HOME}/cowrie-git/bin:${PATH}
ENV COWRIE_STDOUT=yes
USER ${COWRIE_USER}
WORKDIR ${COWRIE_HOME}/cowrie-git
# preserve .dist file when etc/ volume is mounted
RUN cp ${COWRIE_HOME}/cowrie-git/etc/cowrie.cfg.dist ${COWRIE_HOME}/cowrie-git
VOLUME [ "/cowrie/cowrie-git/var", "/cowrie/cowrie-git/etc" ]
RUN mv ${COWRIE_HOME}/cowrie-git/cowrie.cfg.dist ${COWRIE_HOME}/cowrie-git/etc
ENTRYPOINT [ "cowrie" ]
CMD [ "start", "-n" ]
EXPOSE 2222 2223