I have started using Goatcounter for analytics after reading this LWN article called "Lightweight alternatives to Google Analytics". Goatcounter has an interesting approach to privacy in that it:

tracks sessions using a hash of the browser's user agent and IP address to identify the client without storing any personal information. The salt used to generate these hashes is rotated every 4 hours with a sliding window.

There was no Debian package for the project, so I filed a request for package and instead made a fork of the project to add a Docker image.

This page documents how Goatcounter was setup from there...

  1. Initial server configuration
  2. Remaining issues
  3. Fixed issues
  4. Upgrade procedure

Initial server configuration

Note that this procedure was slightly modified to use docker-compose to ease upgrades, see the upgrade procedure at the end for details.

  1. build the image from this fork

    docker build -t zgoat/goatcounter .
    
  2. create volume for db:

    docker volume create goatcounter
    
  3. start the server:

    exec docker run --restart=unless-stopped --volume="goatcounter:/home/user/db/" --publish 127.0.0.1:8081:8080 --detach zgoat/goatcounter serve -listen :8080 -tls none
    
  4. apache configuration:

    <VirtualHost *:80>
                ServerName analytics.anarc.at
                Redirect / https://analytics.anarc.at/
                DocumentRoot /var/www/html/
        </VirtualHost>
    
    <VirtualHost *:443>
            ServerName analytics.anarc.at
            Use common-letsencrypt-ssl analytics.anarc.at
            DocumentRoot /var/www/html/
            ProxyPass /.well-known/ !
            ProxyPass / http://localhost:8081/
            ProxyPassReverse / http://localhost:8081/
            ProxyPreserveHost on
    </VirtualHost>
    
  5. add analytics.anarc.at to DNS

  6. create a TLS cert with LE:

    certbot certonly --webroot  -d analytics.anarc.at --webroot-path /var/www/html/
    

    note that goatcounter has code to do this on its own, but we avoid it to follow our existing policies and simplify things

  7. create site:

    docker run -it --rm --volume="goatcounter:/home/user/db/" zgoat/goatcounter create -domain analytics.anarc.at -email anarcat+rapports@anarc.at
    
  8. add to ikiwiki template

  9. rebuild wiki:

    ikiwiki --setup ikiwiki.setup --rebuild --verbose
    

Remaining issues

Fixed issues

Upgrade procedure

This procedure was done to upgrade from ~1.4.0 to 1.4.2, 2.0.4, and 2.1.1:

  1. rebase on top of target release

    cd ~anarcat/dist/goatcounter/
    git rebase v2.1.1
    
  2. build image:

    docker build -t anarcat/goatcounter:2.1.1 .
    
  3. stop old container:

    cd ~anarcat/src/composes/goatcounter/
    docker-compose rm --stop
    
  4. backup container data:

    tar -c -z -C /var/lib/docker/volumes/ -f /var/lib/docker/volumes/goatcounter.tgz goatcounter_goatcounter/
    
  5. update the image version:

    sed -i s,anarcat/goatcounter:.*,anarcat/goatcounter:2.1.1, docker-compose.yml
    
  6. run the migrations:

    docker-compose run goatcounter db migrate all
    
  7. start container with new image, make sure to update the image: tag:

    docker-compose up -d
    
Comments on this page are closed.
Created . Edited .