Skip to content

Instantly share code, notes, and snippets.

@exonomyapp
Last active August 24, 2024 16:23
Show Gist options
  • Save exonomyapp/1066edaca3cd3e57a806c5178c79a71f to your computer and use it in GitHub Desktop.
Save exonomyapp/1066edaca3cd3e57a806c5178c79a71f to your computer and use it in GitHub Desktop.

Managing SOGo Webmail Theming with Docker Volumes

Introduction

This guide is designed for our team of system administrators and developers who want to customize the appearance of our SOGo webmail instance without modifying the Docker image. By using Docker volumes and a GitHub repository, we can dynamically inject a custom theme into our running SOGo container, allowing for easy maintenance and updates.

Prerequisites

Before proceeding, we need to ensure the following:

  • Basic Docker knowledge: Understanding of Docker containers, images, and volumes.
  • SSH access to our VPS.
  • GitHub account to host our custom theme files.

Step 1: Create a GitHub Repository for Our Theme

  1. Set Up Repository: We've already set up a GitHub repository at ExoTheme to store our custom theme files.

  2. Organize Files: We should structure our repository to match the directory where SOGo expects its theme files. According to the SOGo documentation, the theme files should be placed in the WebServerResources directory:

    sogo-theme/
    ├── css/
    │   └── custom.css
    ├── images/
    │   └── logo.png
    └── README.md
    

    We can create these files and directories in our repository to start customizing our SOGo theme.

Step 2: Clone the Repository to Our VPS

  1. Clone Repo: We SSH into our VPS and clone our GitHub repository into the /opt/projects/sogo directory:

    git clone https://github.com/ExonomyOrg/ExoTheme.git /opt/projects/sogo/sogo-theme

Step 3: Mount the Theme Directory as a Docker Volume

  1. Identify SOGo Container: Based on the SOGo documentation, SOGo's theme files are located in /usr/lib/GNUstep/SOGo/WebServerResources/ within the container.

  2. Stop the Container: If the container needs to be stopped to apply changes, we can stop it with:

    docker stop sogo
  3. Mount the Volume and Restart the Container: We can run the following command to mount our theme directory into the SOGo container:

    docker run -d \
       --name sogo \
       -v /opt/projects/sogo/sogo-theme:/usr/lib/GNUstep/SOGo/WebServerResources/ \
       -p 8080:8080 \
       our-sogo-image

    Explanation:

    • -v /opt/projects/sogo/sogo-theme:/usr/lib/GNUstep/SOGo/WebServerResources/: This option mounts our local theme directory to the expected path within the container, overriding the default theme with our custom one.
    • Replace our-sogo-image with the exact name of the SOGo Docker image we are using.

Step 4: Update the Theme

When we update the theme files in our GitHub repository, we can follow these steps to apply the changes to our SOGo instance:

  1. Pull Changes Locally: On our VPS, we navigate to the theme directory and pull the latest changes:

    cd /opt/projects/sogo/sogo-theme
    git pull origin main
  2. Restart the Container: We restart the SOGo container to apply the updated theme:

    docker restart sogo

Step 5: Automate the Workflow (Optional)

If we ever decide to automate this process, we can create a script and run it manually whenever we want to update the theme.

  1. Create the Script: Save the following script as /opt/projects/sogo/scripts/update-sogo-theme.sh:

    #!/bin/bash
    cd /opt/projects/sogo/sogo-theme
    git pull origin main
    docker restart sogo

    Make sure the script is executable:

    chmod +x /opt/projects/sogo/scripts/update-sogo-theme.sh
  2. Manual Activation: We can run the script manually whenever we want to update the theme:

    /opt/projects/sogo/scripts/update-sogo-theme.sh

Step 6: Monitor and Maintain

  1. Monitor: Regularly check the Docker logs to ensure that the theme is applied correctly:

    docker logs -f sogo
  2. Rollback if Needed: If we encounter issues, we can revert to a previous commit in our GitHub repository, pull the changes, and restart the container:

    cd /opt/projects/sogo/sogo-theme
    git reset --hard <commit_id>
    git pull origin main
    docker restart sogo

Conclusion

By leveraging Docker volumes and our GitHub repository, we can effectively manage and apply custom themes to our SOGo instance without modifying the Docker image. This approach provides flexibility and allows for easy updates via version control, ensuring that our SOGo instance always runs the latest version of our theme with minimal manual intervention.

References


This version of the guide is now fully tailored to our team, using precise references to our specific files, folders, and setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment