diff --git a/containers/apps/sogo/BASE b/containers/apps/sogo/BASE new file mode 100644 index 00000000000..033f0d09f23 --- /dev/null +++ b/containers/apps/sogo/BASE @@ -0,0 +1 @@ +focal-20210827 diff --git a/containers/apps/sogo/Dockerfile b/containers/apps/sogo/Dockerfile new file mode 100644 index 00000000000..92e56ecb516 --- /dev/null +++ b/containers/apps/sogo/Dockerfile @@ -0,0 +1,91 @@ +# hadolint ignore=DL3007 +FROM ghcr.io/truecharts/ubuntu:latest + + +ARG TARGETPLATFORM +ARG VERSION + +ARG DEBIAN_FRONTEND=noninteractive +ARG SOGO_UBUNTU_REPOSITORY=https://packages.inverse.ca/SOGo/nightly/5/ubuntu/ +ENV LC_ALL C +ENV GOSU_VERSION 1.12 + +# hadolint ignore=DL3002 +USER root + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,DL3015,SC2086,SC2155,DL3047 +RUN \ + apt-get -qq update \ + && \ + apt-get -qq install -y \ + libicu66 \ + jq \ + && \ + case "${TARGETPLATFORM}" in \ + 'linux/amd64') export ARCH='linux-x64' ;; \ + esac \ + && \ + echo "Building from repository $SOGO_UBUNTU_REPOSITORY" \ + && apt-get update && apt-get install -y --no-install-recommends \ + apt-transport-https \ + ca-certificates \ + gettext \ + gnupg \ + mariadb-client \ + rsync \ + supervisor \ + syslog-ng \ + syslog-ng-core \ + syslog-ng-mod-redis \ + dirmngr \ + netcat \ + psmisc \ + wget \ + patch \ + && dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \ + && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + && mkdir /usr/share/doc/sogo \ + && touch /usr/share/doc/sogo/empty.sh \ + && apt-key adv --keyserver keyserver.ubuntu.com --recv-key 0x810273C4 \ + && echo "deb ${SOGO_UBUNTU_REPOSITORY} focal focal" > /etc/apt/sources.list.d/sogo.list \ + && apt-get update && apt-get install -y --no-install-recommends \ + sogo \ + sogo-activesync \ + && apt-get autoclean \ + && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/sogo.list \ + && touch /etc/default/locale \ + && apt-get remove -y \ + jq \ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ + && apt-get autoremove -y \ + && apt-get clean \ + && \ + rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/ \ + && chmod -R u=rwX,go=rX /app \ + && printf "umask %d" "${UMASK}" >> /etc/bash.bashrc \ + && update-ca-certificates + +EXPOSE 80 443 + +COPY ./containers/apps/sogo/entrypoint.sh /entrypoint.sh +COPY ./containers/apps/sogo/bootstrap-sogo.sh /bootstrap-sogo.sh +COPY ./containers/apps/sogo/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf +COPY ./containers/apps/sogo/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./containers/apps/sogo/stop-supervisor.sh /usr/local/sbin/stop-supervisor.sh + +RUN chmod +x /bootstrap-sogo.sh \ + /usr/local/sbin/stop-supervisor.sh + +ENTRYPOINT ["/entrypoint.sh"] +# hadolint ignore=DL3025 +CMD exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf + +LABEL "maintainer"="TrueCharts " +LABEL "org.opencontainers.image.source"="https://github.com/truecharts/apps" diff --git a/containers/apps/sogo/VERSION b/containers/apps/sogo/VERSION new file mode 100644 index 00000000000..152d80331bf --- /dev/null +++ b/containers/apps/sogo/VERSION @@ -0,0 +1 @@ +4.0.1474 diff --git a/containers/apps/sogo/bootstrap-sogo.sh b/containers/apps/sogo/bootstrap-sogo.sh new file mode 100755 index 00000000000..b0c48910f96 --- /dev/null +++ b/containers/apps/sogo/bootstrap-sogo.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exec gosu sogo /usr/sbin/sogod diff --git a/containers/apps/sogo/entrypoint.sh b/containers/apps/sogo/entrypoint.sh new file mode 100755 index 00000000000..5a2ec0feb40 --- /dev/null +++ b/containers/apps/sogo/entrypoint.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +#shellcheck disable=SC1091 +source "/shim/umask.sh" +source "/shim/vpn.sh" + + +if [[ "${SKIP_SOGO}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then + echo "SKIP_SOGO=y, skipping SOGo..." + sleep 365d + exit 0 +fi + +# Run hooks +for file in /hooks/*; do + if [ -x "${file}" ]; then + echo "Running hook ${file}" + "${file}" + fi +done + +exec "$@" diff --git a/containers/apps/sogo/latest-base.sh b/containers/apps/sogo/latest-base.sh new file mode 100755 index 00000000000..cee4f14a2ce --- /dev/null +++ b/containers/apps/sogo/latest-base.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +cat "./containers/base/ubuntu/VERSION" diff --git a/containers/apps/sogo/stop-supervisor.sh b/containers/apps/sogo/stop-supervisor.sh new file mode 100755 index 00000000000..5394490ceb0 --- /dev/null +++ b/containers/apps/sogo/stop-supervisor.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +printf "READY\n"; + +while read line; do + echo "Processing Event: $line" >&2; + kill -3 $(cat "/var/run/supervisord.pid") +done < /dev/stdin diff --git a/containers/apps/sogo/supervisord.conf b/containers/apps/sogo/supervisord.conf new file mode 100644 index 00000000000..4946d98ccc8 --- /dev/null +++ b/containers/apps/sogo/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +nodaemon=true +user=root + +[program:syslog-ng] +command=/usr/sbin/syslog-ng --foreground --no-caps +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autostart=true +priority=1 + +[program:bootstrap-sogo] +command=/bootstrap-sogo.sh +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +priority=2 +startretries=10 +autorestart=true +stopwaitsecs=120 + +[eventlistener:processes] +command=/usr/local/sbin/stop-supervisor.sh +events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL diff --git a/containers/apps/sogo/syslog-ng.conf b/containers/apps/sogo/syslog-ng.conf new file mode 100644 index 00000000000..537038efd4f --- /dev/null +++ b/containers/apps/sogo/syslog-ng.conf @@ -0,0 +1,45 @@ +@version: 3.19 +@include "scl.conf" +options { + chain_hostnames(off); + flush_lines(0); + use_dns(no); + use_fqdn(no); + owner("root"); group("adm"); perm(0640); + stats_freq(0); + bad_hostname("^gconfd$"); +}; +source s_src { + unix-stream("/dev/log"); + internal(); +}; +source s_sogo { + pipe("/dev/sogo_log" owner(sogo) group(sogo)); +}; +destination d_stdout { pipe("/dev/stdout"); }; +destination d_redis_ui_log { + redis( + host("redis-mailcow") + persist-name("redis1") + port(6379) + command("LPUSH" "SOGO_LOG" "$(format-json time=\"$S_UNIXTIME\" priority=\"$PRIORITY\" program=\"$PROGRAM\" message=\"$MESSAGE\")\n") + ); +}; +destination d_redis_f2b_channel { + redis( + host("redis-mailcow") + persist-name("redis2") + port(6379) + command("PUBLISH" "F2B_CHANNEL" "$(sanitize $MESSAGE)") + ); +}; +log { + source(s_sogo); + destination(d_redis_ui_log); + destination(d_redis_f2b_channel); +}; +log { + source(s_sogo); + source(s_src); + destination(d_stdout); +};