Manage your Finance with Firefly III and Raspberry PI
Last Updated on 2nd September 2023 by peppe8o
In this tutorial, I’m going to show you how to install FireFly III with Docker on a credit card-sized, cheap computer: Raspberry PI.
Having finance under control is a good way to correctly manage money and analyze what expenses can be reduced to save. Usually, many internet services offer solutions to manage your money, but privacy issues raised attention on data saved in the cloud, so more and more people look for self-hosted solutions able to grant data reside in their homes. An answer to this need is Firefly III
What is Firefly III
Firefly III, a free and open-source personal finance manager, aims to get you aware of where your money is spent so that you can organize better your payments and verify where you should look if you want to make savings.
It is self-hosted, meaning that it can run on a home computer or you can alternatively find a hosting service where to install it.
Firefly III installation can be performed on Docker, Kubernetes, LAMP server or via hosting tools (like Softaculous). For this project, I’m going to use the Docker procedure on Raspberry PI 3 model A+, but this guide applies also to newer Raspberry PI computer boards.
What We Need
As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:
- Raspberry PI 3 Model A+ (including proper power supply or using a smartphone micro USB charger with at least 3A) or newer Raspberry PI Board
- high speed micro SD card (at least 16 GB, at least class 10)
Check hardware prices with the following links:
Step-by-Step Procedure
Preparing Environment
Start installing Raspberry PI OS Lite.
Make your operating system up to date, from the command line:
sudo apt update -y && sudo apt upgrade -y
Then install Docker and Docker compose:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker pi
sudo apt install docker-compose
Reboot or reload your profile to get docker privileges to the pi user.
Preparing Build and Compose Files
You will need to set your favourite values for some credentials/parameters. It is better to prepare their values from now so that you will be ready to set them. This tutorial will include the following values, so you have to change them with your ones:
- “fireflyiiiDb” (the name for the database in MariaDB dedicated to your Firefly III)
- “fireflyiiiUser” (user for database access in MariaDB)
- “fireflyiiiPassword” (password for database access in MariaDB)
You will also need an APP_KEY, which needs to be a random string of 32 characters. This APP_KEY can be generated from your terminal with the command:
head /dev/urandom | LANG=C tr -dc 'A-Za-z0-9' | head -c 32
Start preparing the folder where files will be collected. Folder name will be used, by default, from docker-compose to name container services. Create and enter it:
mkdir fireflyIII
cd fireflyIII
The folder will include the following files, which I’m going to show you one by one:
Dockerfile
mySqlScript.sql
docker-compose.yml
.env
Dockerfile
This file is used to build a MariaDB container from a lite Debian base image. Please refer to Create custom MariaDB container article for more detailed info:
mySqlScript.sql
Also, this script refers to MariaDB’s custom container creation. It differs from the original one because the create database command is issued at the start. Consider that this script will run only once at first boot during the building process:
CREATE DATABASE fireflyiiiDb;
create user fireflyiiiUser@'%' identified by 'fireflyiiiPassword';
grant all privileges on fireflyiiiDb.* to fireflyiiiUser@'%';
flush privileges;
quit
docker-compose.yml
This is a mix of MariaDB compose file and Firefly III file.
# My Firefly III
# by peppe8o.com
version: '3.3'
services:
fireflyiii:
image: fireflyiii/core:latest
volumes:
- firefly_iii_upload:/var/www/firefly-iii/storage/upload
env_file: .env
ports:
- 80:8080
depends_on:
- db
db:
build: .
restart: always
volumes:
- firefly_iii_db:/var/lib/mysql
volumes:
firefly_iii_upload:
firefly_iii_db:
.env
env file includes all configurations needed by the Firefly III service. Get the .env file from the FireflyIII example file and save it with the correct name:
wget -O .env https://raw.githubusercontent.com/firefly-iii/firefly-iii/main/.env.example
Customize .env file:
nano .env
Identify and change the following parameters:
APP_KEY=SomeRandomStringOf32CharsExactly -> change with your random generated APP_KEY
DB_DATABASE=firefly -> change to DB_DATABASE=fireflyiiiDb
DB_USERNAME=firefly -> change to DB_USERNAME=fireflyiiiUser
DB_PASSWORD=secret_firefly_password -> change to DB_PASSWORD=fireflyiiiPassword
You can edit or leave with default values remaining parameters.
Run Firefly III
Finally, start service by issuing the following terminal command:
docker-compose up -d
Your Raspberry PI will automatically start from the Debian image. It will update the base image and install MariaDB, then use SQL script to initialize your database container.
Then, still, it will automatically download all FireFly III packages to initialize the related container. Once finished you will have back your terminal prompt. Setup operations could continue also after containers creation, so check Firefly III web container logs with the following command:
docker logs fireflyiii_fireflyiii_1
Please, note that if you used a different folder name, you will have firefly service named with the folder name before the underscore character. Operations should finish when this command results in something similar to the following one:
...
Updated version.
+------------------------------------------------------------------------------+
| |
| Thank you for installing Firefly III, v5.4.2! |
| |
| |
+------------------------------------------------------------------------------+
Go!
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
[Fri Sep 25 23:22:55.451094 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.10 configured -- resuming normal operations
[Fri Sep 25 23:22:55.451308 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
From here your FireflyIII service should be ready. In your favourite web browser, use Raspberry PI IP address (mine is 192.168.1.177) for the URL. The page will redirected to Firefly III registration URL (give more minutes in case of connection refused error and try again):
Insert your email address and choose your password (consider that your password must be at least 16 digits, including upper case, symbol, chars and number).
Then click the register button. This will redirect you to the Firefly III home page:
You are now ready to use your Firefly III service!
For more info and a user guide, please refer to Firefly III official documentation page.
Final Operations
At the procedure end, it is a good practice to enter the MariaDB container to change the root password for security.
Next Steps
Interested in more RPI projects? Take a look at peppe8o Raspberry PI tutorials to get new ways to use your powerful board!
Enjoy!
Hi and thanks for that. Your Dockerfile contains an error : “source /mysql_scripts/mySqlScript.$ (I found the corrected version in the linked page which has more details).
Also, when I run docker-compose up -d I am getting the following error:
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in “./docker-compose.yml”, line 2, column 8
Thank you Angelos, found and corrected error in docker compose file. This is a common copy (from terminal) – paste (to editor) problem with WordPress editor which sometimes skips spaces or chars.
I’m also going to publish files from a download area which will solve these issues.
Thank you! It worked now! Stupid me, I didn’t realise the first line should be a comment
Hi Peppe!
With this guide i was able to run Firefly III on the raspberry and use it. Unfortunatly if I try to connect from my PC to the IP of the raspberry i got a connection time out (raspberry and PC are in the same network). There are other passagges to reach this goal?
Hi Andrea,
does your comment mean that you are running on Raspberry PI OS Desktop and it works only locally?
Yes, if I type “localhost” from the browser on the raspberry everything is work. From my pc if I use in http the ip address of my raspberry i got a connection time out. I work from my pc in ssh so everything in the network is ok.
I think that docker is binding only in localhost.
Ok. Please, can you provide me result from “docker ps” terminal command?
I solved the problem.
Basically i had to open the http port on my router (it seeems that the fastweb router has a firewall always active).
Thank you for your guide!
Ottimo. Thank you, Andrea
Unfortunately i get an error when building:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
I followed exactly the instructions and am using an raspberry pi 4 (4gb)
What does “docker ps -a” command give to you?
I get this
Step 2/7 : RUN apt update -y && apt install mariadb-server -y
—> Running in e68a5c1249b4
/bin/sh: 1: Syntax error: “&” unexpected
Check the dockerfile, the “&&” should just be “&&”
it worked for me when I changed it. I believe & is & for HMTL
Thank you Will, HTML error found and corrected
I followed your instructions and attempted an install on an older pi 2 board. Everything seemed to go well until I attempted to start the service with the docker-compose command. Step 6/7 resulted in an error. Is this a limitation with the Pi 2 or is something else required?
Step 6/7 : RUN /etc/init.d/mysql start && mysql -uroot –password=”” -e “source /mysql_scripts/mySqlScript.sql”
—> Running in 5779d8309d80
/bin/sh: 1: /etc/init.d/mysql: not found
ERROR: Service ‘fireflyiiidb’ failed to build: The command ‘/bin/sh -c /etc/init.d/mysql start && mysql -uroot –password=”” -e “source /mysql_scripts/mySqlScript.sql”‘ returned a non-zero code: 127
Hi Bob, you are right. From a few time MariaDB doesn’t like anymore being called as “mysql”, so they changed its executable name from mysql to mariadb.
The post has been updated, please copy the new Dockerfile (the rest should remain unchanged).
Many thanks, Giuseppe
Thanks again Giuseppe. I successfully started the docker-compose but firefly will not start.
When issuing the docker logs command, the pi response is:
standard_init_linux.go:219: exec user process caused: exec format error
Hi Bob,
sorry, but also the previous docker image for firefly III has changed and now doesn’t support armv7 architecture (that’s the reason of your error). In the meanwhile, Firefly added their own docker image and now they support armv7, so please try the updated docker-compose.yml file from this post and let me know.
Giuseppe — thanks so much. Everything is working now. on an older Pi 2. Couldn’t have done it without you.
Hello
Thanks for this walk through unfortunately I am a UNIX / raspberrypi newbie and am banging my head trying to get firefly3 installed and running. I think all was going well untill i ran the following.
pi@raspberrypi:~/fireflyIII $ docker-compose up -d
Building db
Step 1/7 : FROM debian
latest: Pulling from library/debian
c0b863d4b31f: Pull complete
Digest: sha256:3e82b1af33607aebaeb3641b75d6e80fd28d36e17993ef13708e9493e30e8ff9
Status: Downloaded newer image for debian:latest
---> 05db4696ee37
Step 2/7 : RUN apt update -y && apt install mariadb-server -y
---> Running in 0eb2178ef0ca
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Err:1 http://deb.debian.org/debian bullseye InRelease
At least one invalid signature was encountered.
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Err:2 http://deb.debian.org/debian-security bullseye-security InRelease
At least one invalid signature was encountered.
Err:3 http://deb.debian.org/debian bullseye-updates InRelease
At least one invalid signature was encountered.
Reading package lists...
W: GPG error: http://deb.debian.org/debian bullseye InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian bullseye InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian-security bullseye-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian-security bullseye-security InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian bullseye-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian bullseye-updates InRelease' is not signed.
ERROR: Service 'db' failed to build: The command '/bin/sh -c apt update -y && apt install mariadb-server -y' returned a non-zero code: 100
pi@raspberrypi:~/fireflyIII $ docker logs fireflyiii_fireflyiii_1
Error: No such container: fireflyiii_fireflyiii_1
pi@raspberrypi:~/fireflyIII $ docker-compose up -d
Building db
Step 1/7 : FROM debian
---> 05db4696ee37
Step 2/7 : RUN apt update -y && apt install mariadb-server -y
---> Running in a3bdc1fca179
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Err:1 http://deb.debian.org/debian bullseye InRelease
At least one invalid signature was encountered.
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Err:2 http://deb.debian.org/debian-security bullseye-security InRelease
At least one invalid signature was encountered.
Err:3 http://deb.debian.org/debian bullseye-updates InRelease
At least one invalid signature was encountered.
Reading package lists...
W: GPG error: http://deb.debian.org/debian bullseye InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian bullseye InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian-security bullseye-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian-security bullseye-security InRelease' is not signed.
W: GPG error: http://deb.debian.org/debian bullseye-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://deb.debian.org/debian bullseye-updates InRelease' is not signed.
ERROR: Service 'db' failed to build: The command '/bin/sh -c apt update -y && apt install mariadb-server -y' returned a non-zero code: 100
Could you shed some light on what went wrong?
Hi
I did the additional step listed on the “Create a Custom MariaDB Container with Raspberry PI and Docker” but the work around didn’t work..
pi@raspberrypi:~/myMariaDB $ wget http://ftp.de.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
--2022-10-03 20:07:27-- http://ftp.de.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
Resolving ftp.de.debian.org (ftp.de.debian.org)... 141.76.2.4
Connecting to ftp.de.debian.org (ftp.de.debian.org)|141.76.2.4|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-10-03 20:07:28 ERROR 404: Not Found.
pi@raspberrypi:~/myMariaDB $ sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb
dpkg: error: cannot access archive 'libseccomp2_2.5.1-1_armhf.deb': No such file or directory
pi@raspberrypi:~/myMariaDB $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
pi@raspberrypi:~/myMariaDB $
Also I’m being thick but should i be be running each in their own directories. myMariaDB and /fireflyIII as each tutorial states?
Sorry but have been trying various tutorials to get this running for days and am getting nowhere fast.