Firefly III on Docker with automation cronjob

Firefly III has a recurring transactions option. In order for that to work, you need to setup a cronjob. Without that, you get an error at the top of the page saying:

It seems the cron job that is necessary to support recurring transactions has never 
run. This is of course normal when you have just installed Firefly III, 
but this should be something to set up as soon as possible. Please check 
out the help-pages using the (?)-icon in the top right corner of the page.

Firefly III has an API to which you make a get request that triggers recurring transactions update. API call URL is:

http://FIREFLY_URL/api/v1/cron/TOKEN

To generate a token, go to your Firefly GUI -> Options -> Profile -> Command line token and copy token to URL.

Example:

http://firefly.example/api/v1/cron/6c57c098904f6f4765b52a4bc493687p

If you go to this URL now, your Firefly will run recurring transactions. Because we don’t want to do that manually, we will do it via cronjob that will run every day at 3 AM.

You can do it on any Linux box with normal cronjob:

crontab -e

and add this line:

0 3 * * * wget -qO- http://firefly.example/api/v1/cron/6c57c098904f6f4765b52a4bc493687p &> /dev/null

Because we are running Firefly 3 in Docker, more neat option is to add Alpine linux image to our docker compose and run it along within stack:

version: '3.3'

services:
  app:
    image: fireflyiii/core:latest
    restart: always
    volumes:
      - firefly_iii_upload:/var/www/html/storage/upload
    env_file: stack.env
    ports:
      - 8080:8080
    depends_on:
      - db
  db:
    image: mariadb:10.8.2
    hostname: fireflyiiidb
    restart: always
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_USER=firefly
      - MYSQL_PASSWORD=secret_firefly_password
      - MYSQL_DATABASE=firefly
    volumes:
      - firefly_iii_db:/var/lib/mysql
  cron:
     image: alpine
     command: sh -c "echo \"0 3 * * * wget -qO- http://firefly.example/api/v1/cron/6c57c098904f6f4765b52a4bc493687p &> /dev/null\" | crontab - && crond -f -L /dev/stdout"
volumes:
   firefly_iii_upload:
   firefly_iii_db:

After the stack is running, enter a shell of your Alpine container and check if cronjob is present:

crontab -l

Leave a Reply

Your email address will not be published. Required fields are marked *