From bf984e10062473fcdc1a14c0eb6e0ac35a8653c3 Mon Sep 17 00:00:00 2001 From: Son Date: Wed, 15 May 2024 11:28:23 -0400 Subject: [PATCH] docker: switch to apache as web server --- Dockerfile | 27 +++++----- default-configs/nginx.conf | 107 ------------------------------------- entrypoint.sh | 16 +++--- supervisord.conf | 10 ++-- 4 files changed, 29 insertions(+), 131 deletions(-) delete mode 100644 default-configs/nginx.conf diff --git a/Dockerfile b/Dockerfile index 7f607b2..ae6c139 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,6 @@ ENV PGID=1000 RUN apt-get update -y && \ apt-get install -y \ ca-certificates \ - rsync \ tzdata \ wget \ make \ @@ -71,7 +70,7 @@ RUN apt-get update -y && \ gnupg2 \ default-mysql-client \ postgresql-client \ - nginx \ + apache2 \ supervisor \ gnustep-base-runtime \ libc6 \ @@ -102,29 +101,33 @@ RUN apt-get update -y && \ rm -rf /var/lib/apt/lists/* # add config, binaries, libraries, and init files -COPY --from=builder /usr/local/sbin/ /usr/sbin/ -COPY --from=builder /usr/local/lib/sogo/ /usr/lib/sogo/ -COPY --from=builder /usr/lib/GNUstep/ /usr/lib/GNUstep/ +COPY --from=builder /usr/local/sbin/ /usr/local/sbin/ +COPY --from=builder /usr/local/lib/sogo/ /usr/local/lib/sogo/ COPY --from=builder /usr/local/lib/GNUstep/ /usr/local/lib/GNUstep/ -COPY --from=builder /usr/include/GNUstep/ /usr/include/GNUstep/ COPY --from=builder /usr/local/include/GNUstep/ /usr/local/include/GNUstep/ -COPY --from=builder /usr/share/GNUstep/ /usr/share/GNUstep/ +COPY --from=builder /usr/share/GNUstep/Makefiles/ /usr/share/GNUstep/Makefiles/ +COPY --from=builder /etc/GNUstep/ /etc/GNUstep/ COPY --from=builder /tmp/SOGo/Scripts/sogo-default /etc/default/sogo COPY --from=builder /tmp/SOGo/Scripts/sogo.cron /etc/cron.d/sogo COPY --from=builder /tmp/SOGo/Scripts/sogo.conf /etc/sogo/sogo.conf COPY --from=builder /tmp/SOGo/Scripts/ /usr/share/doc/sogo/ +COPY --from=builder /tmp/SOGO/Apache/SOGo.conf /etc/apache2/conf-available/SOGo.conf -COPY default-configs/nginx.conf /etc/nginx/sites-enabled/default COPY supervisord.conf /opt/supervisord.conf COPY config_parser.sh /opt/config_parser.sh COPY entrypoint.sh /opt/entrypoint.sh ADD https://github.com/mikefarah/yq/releases/latest/download/yq_linux_${TARGETARCH} /usr/bin/yq -RUN rsync -avLkq /usr/local/lib/GNUstep/ /usr/lib/GNUstep && \ - rsync -avLkq /usr/local/include/GNUstep/ /usr/include/GNUstep && \ - rm -rf /usr/local/lib/GNUstep && \ - rm -rf /usr/local/include/GNUstep && \ +RUN echo "/usr/local/lib/sogo" > /etc/ld.so.conf.d/sogo.conf && \ + ldconfig && \ + groupadd --system sogo && \ + useradd --system --gid sogo sogo && \ + mkdir -p /usr/lib/GNUstep/ && \ + ln -s /usr/local/lib/GNUstep/SOGo /usr/lib/GNUstep/SOGo && \ + ln -s /usr/local/sbin/sogo-tool /usr/sbin/sogo-tool && \ + ln -s /usr/local/sbin/sogo-ealarms-notify /usr/sbin/sogo-ealarms-notify && \ + ln -s /usr/local/sbin/sogo-slapd-sockd /usr/sbin/sogo-slapd-sockd && \ chmod +rx /usr/bin/yq && \ chmod +rx /opt/entrypoint.sh diff --git a/default-configs/nginx.conf b/default-configs/nginx.conf deleted file mode 100644 index 0e655d4..0000000 --- a/default-configs/nginx.conf +++ /dev/null @@ -1,107 +0,0 @@ -server -{ - listen 80 default; - root /usr/lib/GNUstep/SOGo/WebServerResources/; - - index index.php index.html; - autoindex off; - - ## requirement to create new calendars in Thunderbird ## - proxy_http_version 1.1; - - # Message size limit - client_max_body_size 50m; - client_body_buffer_size 128k; - - location = / - { - rewrite ^(.*)$ /SOGo; - allow all; - } - - # For iOS 7 - location = /principals/ - { - rewrite ^(.*)$ /SOGo/dav; - allow all; - } - - location = /.well-known/caldav - { - rewrite ^(.*)$ /SOGo/dav; - allow all; - } - - location = /.well-known/carddav - { - rewrite ^(.*)$ /SOGo/dav; - allow all; - } - - location ^~/SOGo - { - proxy_pass http://127.0.0.1:20000; - proxy_redirect http://127.0.0.1:20000 default; - # forward user's IP address - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_set_header x-webobjects-server-protocol HTTP/1.0; - proxy_set_header x-webobjects-remote-host 127.0.0.1; - proxy_set_header x-webobjects-server-name $server_name; - proxy_set_header x-webobjects-server-url $scheme://$host; - proxy_set_header x-webobjects-server-port $server_port; - proxy_connect_timeout 90; - proxy_send_timeout 90; - proxy_read_timeout 90; - proxy_buffer_size 4k; - proxy_buffers 4 32k; - proxy_busy_buffers_size 64k; - proxy_temp_file_write_size 64k; - break; - } - - location /SOGo.woa/WebServerResources/ - { - alias /usr/lib/GNUstep/SOGo/WebServerResources/; - allow all; - expires max; - } - - location /SOGo/WebServerResources/ - { - alias /usr/lib/GNUstep/SOGo/WebServerResources/; - allow all; - expires max; - } - - location ^/SOGo/so/ControlPanel/Products/([^/]*)/Resources/(.*)$ - { - alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2; - expires max; - } - - location ^/SOGo/so/ControlPanel/Products/[^/]*UI/Resources/.*\.(jpg|png|gif|css|js)$ - { - alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2; - expires max; - } - location ^~ /Microsoft-Server-ActiveSync - { - access_log /var/log/nginx/activesync.log; - error_log /var/log/nginx/activesync-error.log; - #resolver your.dns-server.ip.address; - - proxy_connect_timeout 75; - proxy_send_timeout 3600; - proxy_read_timeout 3600; - proxy_buffers 64 256k; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - - proxy_pass http://127.0.0.1:20000/SOGo/Microsoft-Server-ActiveSync; - proxy_redirect http://127.0.0.1:20000/SOGo/Microsoft-Server-ActiveSync /; - } -} diff --git a/entrypoint.sh b/entrypoint.sh index 3c5d5c6..ac6d7f4 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,13 +2,15 @@ . /usr/share/GNUstep/Makefiles/GNUstep.sh -set -e - -# Check if user "sogo" does not exist -if ! id "sogo" &>/dev/null; then - # Create user "sogo" - useradd -ms /bin/bash sogo - echo "User 'sogo' has been created." +#Solve libssl bug for Mail View +if [[ -z "${LD_PRELOAD}" ]]; then + LIBSSL_LOCATION=$(find / -type f -name "libssl.so.*" -print -quit);echo "LD_PRELOAD=$LIBSSL_LOCATION" >> /etc/default/sogo + echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:$LD_LIBRARY_PATH" >> /etc/default/sogo + export LD_PRELOAD=$LIBSSL_LOCATION +else + echo "LD_PRELOAD=$LD_PRELOAD" >> /etc/default/sogo + echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:$LD_LIBRARY_PATH" >> /etc/default/sogo + export LD_PRELOAD=$LD_PRELOAD fi # Set process UID and GID at runtime diff --git a/supervisord.conf b/supervisord.conf index 7ee4ac7..c0a5c88 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -5,28 +5,28 @@ logfile=/dev/null logfile_maxbytes=0 [program:sogo] -command=/usr/sbin/sogod -WONoDetach YES -WOLogFile /var/log/sogo/runtime.log -WOPort localhost:20000 +command=/bin/bash -c '/usr/sbin/sogod -WONoDetach YES -WOLogFile /var/log/sogo/sogo.log' user=sogo stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true [program:sogo_logs] -command=/bin/bash -c 'log_file="/var/log/sogo/runtime.log"; while [ ! -f "$log_file" ]; do sleep 0.1; done; tail -f "$log_file"' +command=/bin/bash -c 'log_file="/var/log/sogo/sogo.log"; while [ ! -f "$log_file" ]; do sleep 0.1; done; tail -f "$log_file"' user=sogo stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true -[program:nginx] -command=/usr/sbin/nginx -g "daemon off;" +[program:apache] +command=/usr/sbin/apache2ctl -c "ErrorLog /dev/fd/1" -DFOREGROUND user=root stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 redirect_stderr=true [program:crond] -command=cron -f -L 15 +command=/bin/bash -c 'cron -f -L 15' autostart=true user=root stdout_logfile=/dev/fd/1