2021-10-22 06:19:55 +00:00
|
|
|
# This Dockerfile contains two images, `builder` and `runtime`.
|
|
|
|
# `builder` contains all necessary code to build
|
|
|
|
# `runtime` is stripped down.
|
|
|
|
|
|
|
|
ARG ARCH=
|
2024-11-28 05:42:10 +00:00
|
|
|
ARG SOURCE_DATE_EPOCH
|
2021-10-22 06:19:55 +00:00
|
|
|
ARG TAG
|
2024-10-30 03:44:11 +00:00
|
|
|
FROM ${ARCH}debian:bookworm-slim AS builder
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
WORKDIR /
|
|
|
|
|
|
|
|
# This is a temporary workaround, see https://github.com/cowrie/docker-cowrie/issues/26
|
|
|
|
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
|
|
|
|
|
|
|
|
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 ${COWRIE_GROUP} && \
|
|
|
|
useradd -r -d ${COWRIE_HOME} -m -g ${COWRIE_GROUP} ${COWRIE_USER}
|
|
|
|
|
|
|
|
# Set up Debian prereqs
|
|
|
|
RUN export DEBIAN_FRONTEND=noninteractive; \
|
2023-09-21 13:50:07 +00:00
|
|
|
apt-get -q update && \
|
|
|
|
apt-get -q install -y \
|
2021-10-22 06:19:55 +00:00
|
|
|
-o APT::Install-Suggests=false \
|
|
|
|
-o APT::Install-Recommends=false \
|
2024-11-18 12:44:14 +00:00
|
|
|
build-essential \
|
2021-10-22 06:19:55 +00:00
|
|
|
ca-certificates \
|
2024-11-18 12:44:14 +00:00
|
|
|
cargo \
|
2021-10-22 06:19:55 +00:00
|
|
|
libffi-dev \
|
2024-11-18 12:44:14 +00:00
|
|
|
libsnappy-dev \
|
2021-10-22 06:19:55 +00:00
|
|
|
libssl-dev \
|
2024-11-18 12:44:14 +00:00
|
|
|
python3 \
|
2021-10-22 06:19:55 +00:00
|
|
|
python3-dev \
|
2024-11-18 12:44:14 +00:00
|
|
|
python3-pip \
|
2021-10-22 06:19:55 +00:00
|
|
|
python3-venv \
|
2024-11-18 12:44:14 +00:00
|
|
|
rustc && \
|
2021-10-22 06:19:55 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
USER ${COWRIE_USER}
|
|
|
|
WORKDIR ${COWRIE_HOME}
|
|
|
|
|
|
|
|
# Copy requirements first to use Docker caching better
|
|
|
|
RUN mkdir -p ${COWRIE_HOME}/cowrie-git
|
2021-10-24 04:53:13 +00:00
|
|
|
COPY --chown=${COWRIE_USER}:${COWRIE_GROUP} requirements.txt requirements-output.txt ${COWRIE_HOME}/cowrie-git/
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
RUN python3 -m venv cowrie-env && \
|
|
|
|
. cowrie-env/bin/activate && \
|
2024-11-18 12:44:14 +00:00
|
|
|
pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
2021-10-22 06:19:55 +00:00
|
|
|
pip install --no-cache-dir --upgrade cffi && \
|
|
|
|
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
|
|
|
|
|
|
|
|
COPY --chown=${COWRIE_USER}:${COWRIE_GROUP} . ${COWRIE_HOME}/cowrie-git
|
|
|
|
|
|
|
|
|
2023-09-21 13:50:07 +00:00
|
|
|
FROM gcr.io/distroless/python3-debian12 AS runtime
|
|
|
|
#FROM gcr.io/distroless/python3-debian12:debug AS runtime
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
LABEL org.opencontainers.image.authors="Michel Oosterhof <michel@oosterhof.net>"
|
|
|
|
LABEL org.opencontainers.image.url="https://cowrie.org/"
|
2024-12-18 06:52:06 +00:00
|
|
|
LABEL org.opencontainers.image.documentation="https://docs.cowrie.org"
|
2023-01-09 05:24:46 +00:00
|
|
|
LABEL org.opencontainers.image.source="https://github.com/cowrie/cowrie"
|
|
|
|
LABEL org.opencontainers.image.version=${TAG}
|
2021-10-22 06:19:55 +00:00
|
|
|
LABEL org.opencontainers.image.revision="Source control revision identifier for the packaged software."
|
|
|
|
LABEL org.opencontainers.image.vendor="Cowrie"
|
|
|
|
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
2023-01-09 05:24:46 +00:00
|
|
|
LABEL org.opencontainers.image.ref.name=${TAG}
|
2021-10-22 06:19:55 +00:00
|
|
|
LABEL org.opencontainers.image.title="Cowrie SSH/Telnet Honeypot"
|
|
|
|
LABEL org.opencontainers.image.description="Cowrie SSH/Telnet Honeypot"
|
|
|
|
#LABEL org.opencontainers.image.base.digest="7beb0248fd81"
|
2023-09-21 13:50:07 +00:00
|
|
|
LABEL org.opencontainers.image.base.name="gcr.io/distroless/python3-debian12"
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
ENV COWRIE_GROUP=cowrie \
|
|
|
|
COWRIE_USER=cowrie \
|
|
|
|
COWRIE_HOME=/cowrie
|
|
|
|
|
|
|
|
#RUN groupadd -r ${COWRIE_GROUP} && \
|
|
|
|
# useradd -r -d ${COWRIE_HOME} -m -g ${COWRIE_GROUP} ${COWRIE_USER}
|
|
|
|
COPY --from=builder --chown=0:0 /etc/passwd /etc/passwd
|
2021-10-24 04:53:13 +00:00
|
|
|
COPY --from=builder --chown=0:0 /etc/group /etc/group
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
#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 \
|
|
|
|
# libffi7 \
|
|
|
|
# procps \
|
|
|
|
# python3 \
|
|
|
|
# python3-distutils && \
|
|
|
|
# rm -rf /var/lib/apt/lists/* && \
|
|
|
|
# ln -s /usr/bin/python3 /usr/local/bin/python
|
|
|
|
|
|
|
|
COPY --from=builder --chown=${COWRIE_USER}:${COWRIE_GROUP} ${COWRIE_HOME} ${COWRIE_HOME}
|
|
|
|
|
2024-11-29 15:28:41 +00:00
|
|
|
RUN [ "python3", "-m", "compileall", "-q", "/cowrie/cowrie-git/src", "/cowrie/cowrie-env/", "/usr/lib/python3.11"]
|
2021-10-22 06:19:55 +00:00
|
|
|
|
|
|
|
VOLUME [ "/cowrie/cowrie-git/var", "/cowrie/cowrie-git/etc" ]
|
|
|
|
|
|
|
|
USER ${COWRIE_USER}
|
|
|
|
WORKDIR ${COWRIE_HOME}/cowrie-git
|
|
|
|
|
|
|
|
ENV PATH=${COWRIE_HOME}/cowrie-env/bin:${PATH}
|
|
|
|
ENV PYTHONPATH=${COWRIE_HOME}/cowrie-git/src
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
2024-11-28 05:42:10 +00:00
|
|
|
RUN [ "python3", "/cowrie/cowrie-git/bin/regen-dropin.cache" ]
|
|
|
|
|
2021-10-22 06:19:55 +00:00
|
|
|
ENTRYPOINT [ "/cowrie/cowrie-env/bin/python3" ]
|
|
|
|
CMD [ "/cowrie/cowrie-env/bin/twistd", "-n", "--umask=0022", "--pidfile=", "cowrie" ]
|
|
|
|
|
|
|
|
EXPOSE 2222 2223
|