1
0

Dockerfile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # SOGo built from source to enable security patch application
  2. # Repository: https://github.com/Alinto/sogo
  3. # Version: SOGo-5.12.4
  4. #
  5. # Applied security patches:
  6. # -
  7. #
  8. # To add new patches, modify SOGO_SECURITY_PATCHES ARG below with space-separated commit hashes
  9. FROM debian:bookworm
  10. LABEL maintainer="The Infrastructure Company GmbH <[email protected]>"
  11. ARG DEBIAN_FRONTEND=noninteractive
  12. ARG SOGO_VERSION=SOGo-5.12.5
  13. ARG SOPE_VERSION=SOPE-5.12.5
  14. # Security patches to apply (space-separated commit hashes)
  15. ARG SOGO_SECURITY_PATCHES=""
  16. # renovate: datasource=github-releases depName=tianon/gosu versioning=semver-coerced extractVersion=^(?<version>.*)$
  17. ARG GOSU_VERSION=1.19
  18. ENV LC_ALL=C
  19. # Install dependencies, build SOPE and SOGo, then clean up (all in one layer to minimize image size)
  20. RUN apt-get update && apt-get install -y --no-install-recommends \
  21. # Build dependencies
  22. git \
  23. build-essential \
  24. gobjc \
  25. pkg-config \
  26. gnustep-make \
  27. gnustep-base-runtime \
  28. libgnustep-base-dev \
  29. libxml2-dev \
  30. libldap2-dev \
  31. libssl-dev \
  32. zlib1g-dev \
  33. libpq-dev \
  34. libmariadb-dev-compat \
  35. libmemcached-dev \
  36. libsodium-dev \
  37. libcurl4-openssl-dev \
  38. libzip-dev \
  39. libytnef0-dev \
  40. libwbxml2-dev \
  41. curl \
  42. ca-certificates \
  43. # Runtime dependencies
  44. apt-transport-https \
  45. gettext \
  46. gnupg \
  47. mariadb-client \
  48. rsync \
  49. supervisor \
  50. syslog-ng \
  51. syslog-ng-core \
  52. syslog-ng-mod-redis \
  53. dirmngr \
  54. netcat-traditional \
  55. psmisc \
  56. wget \
  57. patch \
  58. libobjc4 \
  59. libxml2 \
  60. libldap-2.5-0 \
  61. libssl3 \
  62. zlib1g \
  63. libmariadb3 \
  64. libmemcached11 \
  65. libsodium23 \
  66. libcurl4 \
  67. libzip4 \
  68. libytnef0 \
  69. libwbxml2-1 \
  70. # Download gosu
  71. && dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
  72. && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
  73. && chmod +x /usr/local/bin/gosu \
  74. && gosu nobody true \
  75. # Build SOPE
  76. && git clone --depth 1 --branch ${SOPE_VERSION} https://github.com/Alinto/sope.git /tmp/sope \
  77. && cd /tmp/sope \
  78. && rm -rf .git \
  79. && . /usr/share/GNUstep/Makefiles/GNUstep.sh \
  80. && ./configure --prefix=/usr --disable-debug --disable-strip \
  81. && make -j$(nproc) \
  82. && make install \
  83. && cd / \
  84. && rm -rf /tmp/sope \
  85. # Build SOGo with security patches
  86. && git clone --depth 1 --branch ${SOGO_VERSION} https://github.com/Alinto/sogo.git /tmp/sogo \
  87. && cd /tmp/sogo \
  88. && git config user.email "[email protected]" \
  89. && git config user.name "SOGo Builder" \
  90. && for patch in ${SOGO_SECURITY_PATCHES}; do \
  91. echo "Applying security patch: ${patch}"; \
  92. git fetch origin ${patch} && git cherry-pick ${patch}; \
  93. done \
  94. && rm -rf .git \
  95. && . /usr/share/GNUstep/Makefiles/GNUstep.sh \
  96. && ./configure --disable-debug --disable-strip \
  97. && make -j$(nproc) \
  98. && make install \
  99. && cd /tmp/sogo/ActiveSync \
  100. && . /usr/share/GNUstep/Makefiles/GNUstep.sh \
  101. && make -j$(nproc) install \
  102. && cd / \
  103. && rm -rf /tmp/sogo \
  104. # Strip binaries
  105. && strip --strip-unneeded /usr/local/sbin/sogod 2>/dev/null || true \
  106. && strip --strip-unneeded /usr/local/sbin/sogo-tool 2>/dev/null || true \
  107. && strip --strip-unneeded /usr/local/sbin/sogo-ealarms-notify 2>/dev/null || true \
  108. && strip --strip-unneeded /usr/local/sbin/sogo-slapd-sockd 2>/dev/null || true \
  109. # Remove build dependencies and clean up
  110. && apt-get purge -y --auto-remove \
  111. git \
  112. build-essential \
  113. gobjc \
  114. gnustep-make \
  115. libgnustep-base-dev \
  116. libxml2-dev \
  117. libldap2-dev \
  118. libssl-dev \
  119. zlib1g-dev \
  120. libpq-dev \
  121. libmariadb-dev-compat \
  122. libmemcached-dev \
  123. libsodium-dev \
  124. libcurl4-openssl-dev \
  125. libzip-dev \
  126. libytnef0-dev \
  127. curl \
  128. && apt-get autoremove -y \
  129. && apt-get clean \
  130. && rm -rf /var/lib/apt/lists/* \
  131. && rm -rf /usr/share/doc/* \
  132. && rm -rf /usr/share/man/* \
  133. && rm -rf /var/cache/debconf/* \
  134. && rm -rf /tmp/* \
  135. && rm -rf /root/.cache \
  136. && find /usr/local/lib -name '*.a' -delete \
  137. && find /usr/lib -name '*.a' -delete \
  138. && mkdir -p /usr/share/doc/sogo \
  139. && touch /usr/share/doc/sogo/empty.sh \
  140. && touch /etc/default/locale
  141. # Configure library paths
  142. RUN echo "/usr/lib64" > /etc/ld.so.conf.d/sogo.conf \
  143. && echo "/usr/local/lib/sogo" >> /etc/ld.so.conf.d/sogo.conf \
  144. && echo "/usr/local/lib/GNUstep/Frameworks/SOGo.framework/Versions/5/sogo" >> /etc/ld.so.conf.d/sogo.conf \
  145. && ldconfig
  146. # Create sogo user and group
  147. RUN groupadd -r -g 999 sogo \
  148. && useradd -r -u 999 -g sogo -d /var/lib/sogo -s /bin/bash -c "SOGo Daemon" sogo \
  149. && mkdir -p /var/lib/sogo /var/run/sogo /var/log/sogo /var/spool/sogo \
  150. && chown -R sogo:sogo /var/lib/sogo /var/run/sogo /var/log/sogo /var/spool/sogo
  151. # Create symlinks for SOGo binaries
  152. RUN ln -s /usr/local/sbin/sogod /usr/sbin/sogod \
  153. && ln -s /usr/local/sbin/sogo-tool /usr/sbin/sogo-tool \
  154. && ln -s /usr/local/sbin/sogo-ealarms-notify /usr/sbin/sogo-ealarms-notify \
  155. && ln -s /usr/local/sbin/sogo-slapd-sockd /usr/sbin/sogo-slapd-sockd
  156. # Copy configuration files and scripts
  157. COPY ./bootstrap-sogo.sh /bootstrap-sogo.sh
  158. COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
  159. COPY syslog-ng-redis_slave.conf /etc/syslog-ng/syslog-ng-redis_slave.conf
  160. COPY supervisord.conf /etc/supervisor/supervisord.conf
  161. COPY acl.diff /acl.diff
  162. COPY navMailcowBtns.diff /navMailcowBtns.diff
  163. COPY stop-supervisor.sh /usr/local/sbin/stop-supervisor.sh
  164. COPY docker-entrypoint.sh /
  165. RUN chmod +x /bootstrap-sogo.sh \
  166. /usr/local/sbin/stop-supervisor.sh
  167. ENTRYPOINT ["/docker-entrypoint.sh"]
  168. CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]