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