I would like to tell how to setup Firefly III with auto-renewal SSL in docker-compose.
We will use jwilder.
This is NGINX which will be follow all containers and issue Let's encrypt certificates for them.
- Prepare server or rent VPS. I use hostens VPS, you can use my referral link, plus google some promotional code and it will be very cheap and good VPS.
I use Ubuntu 18.04.
You also need the domain name with А DNS record pointed to your server.
-
Install docker and docker-compose
-
Create folder
nginx-proxy
anddocker-compose.yml
inside this folder
mkdir nginx-proxy
cd nginx-proxy
vim docker-compose.yml
docker-compose.yml
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy:alpine
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./current/public:/usr/share/nginx/html
- ./certs:/etc/nginx/certs:ro
- ./vhost:/etc/nginx/vhost.d
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./pass:/etc/nginx/htpasswd:ro
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
environment:
NGINX_PROXY_CONTAINER: nginx-proxy
NGINX_DOCKER_GEN_CONTAINER: nginx-proxy
volumes:
- ./certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./vhost:/etc/nginx/vhost.d
- ./current/public:/usr/share/nginx/html
networks:
default:
external:
name: nginx-proxy
- Create external network first and than you can start this docker-compose
docker network create nginx-proxy
docker-compose up -d
- Return to your home folder and create
firefly-iii
folder. Anddocker-compose.yml
in it. Copy content of officialdocker-compose.yml
file and paste it.
cd
mkdir firefly-iii
cd firefly-iii
vim docker-compose.yml
change this block:
ports:
- 80:8080
to this:
expose:
- 8080
Also add this block in the end of file:
networks:
default:
external:
name: nginx-proxy
It means that firefly instance will be running in one network with nginx-proxy.
Reference: official documentation about Firefly III in docker and cron.
- Create
.env
file near yourdocker-compose.yml
file. Copy content of.env
file from official link and paste it.
vim .env
Add this block to the .env
file:
VIRTUAL_HOST=your_domain
VIRTUAL_PORT=8080
LETSENCRYPT_HOST=your_domain
LETSENCRYPT_EMAIL=info@your_domain
Replace your_domain
with domain pointed to this server.
Please note, that these environment variables required for nginx-proxy jwilder.
firefly-iii and jwilder will work in the same network.
And in order to proxy firefly-iii jwilder need to see these envs.
Also edit TRUSTED_PROXIES
variable to be TRUSTED_PROXIES=**
Check other variables in file.
- You can now start your Firefly III instance
docker-compose up -d
Just after this command jwilder will proxy Firefly III instance with your domain and auto issue SSL for you. It also will check expiration date for SSL cert and auto-renew it when necessary.
BONUS
- Update to the latest version of Firefly III in one command!
This command will connect your VPS via SSH, update your Firefly III and delete unused docker images.
ssh YOU_SERVER_USER@YOUR_SERVER_IP "cd firefly-iii && docker-compose down && docker-compose pull && docker-compose up -d && docker system prune --all"
- Backup your DB every day.
8.1 In your docker-compose.yml
change MYSQL_RANDOM_ROOT_PASSWORD=yes
to MYSQL_ROOT_PASSWORD=SomeStrongPass
.
Restart you docker-compose with docker-compose up -d --force-recreate
8.2 Create create_backup.sh
file and chmod it with command chmod +x create_backup.sh
. Create db-backup
folder for backups.
8.3 Paste this to create_backup.sh
file:
#!/bin/bash
ls -1 ~/firefly-iii/db-backup/backup_* | sort -r | tail -n +6 | xargs rm > /dev/null 2>&1
docker exec -it firefly-iii_fireflyiiidb_1 mysqldump -p'SomeStrongPass' firefly > ~/firefly-iii/db-backup/backup_$(date +"%m-%d-%y").sql
8.4 Setup cronjob.
crontab -e
Paste this:
0 0 * * * bash /home/vigrid/firefly-iii-v/create_backup.sh
add empty line in the end of file.
8.5 This will automaticaly creates backups every day and keeps last 6 backups.
I update my gist, please, check this chages
Both nginx and firefly wants to run on 80 port.
There are no need to expose port of firefly to your host, expose will be enough.