create dropin.cache at build time (#2414)

* create dropin.cache at build time
* set SOURCE_DATE_EPOCH for use in Docker
This commit is contained in:
Michel Oosterhof 2024-11-28 13:42:10 +08:00 committed by GitHub
parent bd8108cd01
commit 2cefdec289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -41,6 +41,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: set SOURCE_DATE_EPOCH
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU

4
bin/regen-dropin.cache Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env python
# This is run by packaging tools to update `dropin.cache` to keep track of Twisted's plugin cache
from twisted.plugin import IPlugin, getPlugins
print(list(getPlugins(IPlugin)))

View File

@ -3,7 +3,7 @@
# `runtime` is stripped down.
ARG ARCH=
ARG BUILD_DATE
ARG SOURCE_DATE_EPOCH
ARG TAG
FROM ${ARCH}debian:bookworm-slim AS builder
@ -63,7 +63,6 @@ COPY --chown=${COWRIE_USER}:${COWRIE_GROUP} . ${COWRIE_HOME}/cowrie-git
FROM gcr.io/distroless/python3-debian12 AS runtime
#FROM gcr.io/distroless/python3-debian12:debug AS runtime
LABEL org.opencontainers.image.created=${BUILD_DATE}
LABEL org.opencontainers.image.authors="Michel Oosterhof <michel@oosterhof.net>"
LABEL org.opencontainers.image.url="https://cowrie.org/"
LABEL org.opencontainers.image.documentation="https://cowrie.readthedocs.io"
@ -114,6 +113,8 @@ ENV PATH=${COWRIE_HOME}/cowrie-env/bin:${PATH}
ENV PYTHONPATH=${COWRIE_HOME}/cowrie-git/src
ENV PYTHONUNBUFFERED=1
RUN [ "python3", "/cowrie/cowrie-git/bin/regen-dropin.cache" ]
ENTRYPOINT [ "/cowrie/cowrie-env/bin/python3" ]
CMD [ "/cowrie/cowrie-env/bin/twistd", "-n", "--umask=0022", "--pidfile=", "cowrie" ]