How to Build a SOGo Docker Image
SOGo is a fully fledged groupware server providing a mail client, calendar, address book, CalDAV, CardDAV, Microsoft ActiveSync and more. Despite its feature set there is no official Docker image yet. So let’s create one for ourselves.
SOGo uses Apache to serve the web frontend. We run SOGo and Apache toghther in one Docker container so Apache can easily use the SOGO static files. To start both processes in one Docker container we use supervisord as suggested in the Docker wiki. Both processes run on their own user.
We use the SOGo nightly builds as one needs a paid support contract to get access to the stable releases.
SOGo lists several compatible Linux Distributions from which we choose Ubuntu 20.04 as a base for the Docker image. We then roughly follow the SOGo software installation guide and their FAQ entry on how to install nightly SOGo on Ubuntu.
This is the apt source list that we copy to the image. It just contains the SOGo repository.
deb https://packages.inverse.ca/SOGo/nightly/5/ubuntu/ focal focal
Starting Two Processes in A Docker Container
We use supervisord to start SOGo and Apache in the same docker container. Below is the configuration file for supervisord. Apache will automatically drop root permissions and execute as
www-data user. SOGo has to be started as the user it will run as. We will use gosu to start SOGo with the
sogo user. We start both processes in foreground as supervisord will take care of them and their output.
Redirecting Logs to Docker
Both SOGo and Apache log to console which will then be picked up by Docker. We set the log target for both processes on the command line. SOGo needs this parameter:
And Apache2 needs a directive to log errors to stderr. (Note: the “c” is intentionally lower case)
-c "ErrorLog /dev/stderr"
Build the container like this:
docker build -t sogo:5.8.2-nightly-0 .
Note that we are using SOGo nightly builds and you should adapt the version number. If you don’t want to build your own container check out my SOGo Docker repository.
Before starting the container you probably should write your own custom SOGo config file as well as a Apache site config, then mount them to the right directory:
docker run -d --name sogo -v /your/sogo.conf:/etc/sogo/sogo.conf -v /your/apache/site.conf:/etc/apache2/sites-enabled/sogo.conf gevattergaul/sogo