Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

TrueCommand Auto-Update

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,044
Want to ensure that you're always running the latest version of TrueCommand in a Docker container? Docker Compose is the enabler for automatic updates.

This technique I first used on resources for Nextcloud-OnlyOffice and Nextcloud-Collabora integration. It can be used in a more general sense with other Docker images to keep Docker containers up-to-date, but what better example to demonstrate it on in the FreeNAS forum than TrueCommand.

A check is done daily for a new version of the TrueCommand image. If a new version exists, it is downloaded and the TrueCommand container updated. The old image is then removed.

Outline of the steps
  1. Install TrueCommand using Docker Compose.
  2. Set up automatic updates.
Step 1: Install TrueCommand using Docker Compose

Install Docker Compose. This assumes you already have Docker installed on your Ubuntu host. If not, install Docker first.

In the example below, note that TrueCommand data is stored in a nested folder under the home directory i.e. $HOME/truecommand/data.

Code:
sudo docker run --detach -v "$HOME/truecommand/data:/data" -p 8080:80 -p 8081:443 --restart always --name=truecommand -e TZ=Australia/Perth ixsystems/truecommand

Run everything after sudo docker run through Composerize to convert the command to Docker-Compose format.

Change to the TrueCommand folder cd $HOME/truecommand. Create the Compose file nano docker-compose.yml and paste in the output from Composerize.

Code:
version: '3.3'
services:
    truecommand:
        volumes:
            - '$HOME/truecommand/data:/data'
        ports:
            - '8080:80'
            - '8081:443'
        restart: always
        container_name: truecommand
        environment:
            - TZ=Australia/Perth
        image: ixsystems/truecommand

Build and run TrueCommand with Compose sudo docker-compose up -d.

Step 2: TrueCommand Automatic Updates

Make sure you're in the TrueCommand folder cd $HOME/truecommand. Create the update.sh script nano update.sh and paste the following:

Code:
#!/bin/bash
date
cd "`dirname "$0"`"
docker-compose pull
docker-compose up -d
docker image prune -f
date
echo

Make the file executable chmod +x update.sh.

Next, we're going to add a line, that takes the form below, to the system-wide crontab.

Code:
m h * * * /path/to/script >> /path/to/log 2>&1

Standard and error output will be appended to /path/to/log. By design, the log file will be placed in the TrueCommand folder as well, so:

Code:
/path/to/script = $HOME/truecommand/update.sh
/path/to/log = $HOME/truecommand/update.log

However, we need to use the evaluated version of $HOME for the system-wide crontab. Make a note of what this is echo $HOME.

For example:

screenshot.341


For this example:

Code:
/path/to/script = /home/administrator/truecommand/update.sh
/path/to/log = /home/administrator/truecommand/update.log

NOTE: If you've referred to environmental variables such as $HOME in the docker-compose.yml file, these will need to be replaced there as well.

Now, edit the system-wide crontab sudo crontab -e and set up the cron job.

The script should be run at a time when it's unlikely anyone will be using TrueCommand. In the example below, I'm checking for updates daily at half-past midnight.

Code:
30 0 * * *  /home/administrator/truecommand/update.sh >> /home/administrator/truecommand/update.log 2>&1


If there isn't an update when the job is run, a typical log entry will look something like the following:

screenshot.349


If an update is available, the log entry will instead look more like this:

screenshot.350
 
Last edited:

Patrick M. Hausen

Neophyte Sage
Joined
Nov 25, 2013
Messages
1,439
Works like a charm. Applied it to my onlyoffice container, too. Thanks!
 

danb35

Wizened Sage
Joined
Aug 16, 2011
Messages
11,291
Thanks for this write-up--this is how iX should have configured the VM image to begin with. Slight quibble, though:

This assumes you already have Docker installed on your Ubuntu host. If not, you may find Step 3 of the Nextcloud-OnlyOffice resource useful.
No, it really isn't useful--step 3 in that resource just links to the FreeNAS manual, and that in turn just links to the Docker docs (and not even directly to the installation page). Suggest changing this to (1) give a link to the actual Docker installation instructions (https://docs.docker.com/engine/install/ubuntu/, since you're assuming a Ubuntu host), or (2) better yet, just include the few steps to do the installation (and while you're at it, change the deprecated apt-get to apt).
Run everything after sudo docker run through Comperize
Typo here, the name of the page is Composerize. The link is fine, just the typo in the text.

But with that said, it's up and running. Thanks again.
 

Basil Hendroff

Neophyte Sage
Joined
Jan 4, 2014
Messages
1,044
@danb35 I've made some changes to the OP based on your feedback. Thank you.
 
Top