Dockerfile 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. FROM docker.io/alpine:3.22.0
  2. # https://github.com/roehling/postsrsd/blob/main/CHANGELOG.rst
  3. # https://git.alpinelinux.org/aports/log/community/postsrsd?h=3.22-stable
  4. ARG POSTSRSD_PACKAGE_VERSION=2.0.11-r0
  5. # default in /etc/postsrsd/postsrsd.conf:
  6. # > secrets-file = "/etc/postsrsd/postsrsd.secret"
  7. ARG POSTSRSD_SECRET_DIR_PATH=/etc/postsrsd/secrets
  8. ENV POSTSRSD_SECRET_PATH=${POSTSRSD_SECRET_DIR_PATH}/list
  9. # `unprivileged-user = ""` for running as uid ≠ 0 without CAP_{SETUID,SETGID}:
  10. # > postsrsd: error: cannot drop privileges: setgroups: Operation not permitted
  11. # `chroot-dir = ""` for running as uid ≠ 0 without CAP_SYS_CHROOT:
  12. # > postsrsd: error: cannot drop privileges: chroot: Operation not permitted
  13. RUN adduser -S postsrsd \
  14. && apk add --no-cache postsrsd=$POSTSRSD_PACKAGE_VERSION \
  15. && sed -i 's/^\(\(unprivileged-user\|chroot-dir\) = "\).*"/\1"/' \
  16. /etc/postsrsd/postsrsd.conf \
  17. && sed -i 's/^\(socketmap = inet:\)localhost\(\:10003\)$/\10.0.0.0\2/' \
  18. /etc/postsrsd/postsrsd.conf \
  19. && mkdir --mode 700 "${POSTSRSD_SECRET_DIR_PATH}" \
  20. && chown postsrsd "${POSTSRSD_SECRET_DIR_PATH}" \
  21. && sed -i 's#^\(secrets-file = "\).*#\1'"${POSTSRSD_SECRET_PATH}\"#" \
  22. /etc/postsrsd/postsrsd.conf
  23. VOLUME ${POSTSRSD_SECRET_DIR_PATH}
  24. USER postsrsd
  25. ENV POSTSRSD_SECRET_PATH=${POSTSRSD_SECRET_PATH}
  26. EXPOSE 10003/tcp
  27. CMD set -x; \
  28. umask 0077; \
  29. if [ ! -s "$POSTSRSD_SECRET_PATH" ]; then \
  30. tr -dc '1-9a-zA-Z' < /dev/random | head -c 32 > "$POSTSRSD_SECRET_PATH"; \
  31. fi \
  32. && exec postsrsd