⚠️:你必须准备
域名:国内可能需要备案
服务器:Linux
‼️‼️‼️新买的服务器一定要做一些安全的防护具体可参考
日期: 2023-06-04 标签: #安全 #服务器
1、首先新建文件夹,比如fireflyiii
cd fireflyiii
,创建docker-compose.yml
拷贝下面,把{{}}
内的改为自己的,不要{{}}
version: '3.3'
services:
nginx-proxy:
image: nginxproxy/nginx-proxy
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs:ro
- ./vhost:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
nginx-proxy-acme:
image: nginxproxy/acme-companion
container_name: nginx-proxy-acme
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme:/etc/acme.sh
- ./certs:/etc/nginx/certs
- ./vhost:/etc/nginx/vhost.d
- ./html:/usr/share/nginx/html
environment:
# 警告接收email地址
- DEFAULT_EMAIL={{acme@fireflyiii.com}}
- NGINX_PROXY_CONTAINER=nginx-proxy
depends_on:
- nginx-proxy
app:
image: fireflyiii/core:latest
container_name: firefly_app
restart: always
volumes:
- firefly_iii_upload:/var/www/html/storage/upload
env_file: .env
depends_on:
- db
expose:
- "8080"
environment:
# 这里要改为自己的域名
- VIRTUAL_HOST={{fireflyiii.com}}
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST={{fireflyiii.com}}
- LETSENCRYPT_EMAIL={{acme@fireflyiii.com}}
db:
# docker 20.10.10 以上使用最新
image: mariadb:latest
# image: mariadb:10.7.8-focal
container_name: firefly_db
hostname: fireflyiiidb
restart: always
environment:
# 和下面.env 配置文件内一致
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=firefly
- MYSQL_PASSWORD={{.env内的}}
- MYSQL_DATABASE=firefly
volumes:
- ./firefly_iii_db:/var/lib/mysql
cron:
image: alpine
container_name: firefly_cron
# 使用登录之后的选项--命令行令牌的
command: sh -c "echo \"0 3 * * * wget -qO- http://app:8080/api/v1/cron/{{登录之后的选项--命令行令牌获取}}\" | crontab - && crond -f -L /dev/stdout"
redis:
image: redis:6.0.9
container_name: redis
restart: always
volumes:
- ./redis/data:/data
- ./redis/logs:/var/log/redis
- ./redis/conf/redis.conf:/etc/redis/redis.conf
- /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
environment:
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
command:
redis-server /etc/redis/redis.conf # 启动redis命令
volumes:
firefly_iii_upload:
firefly_iii_db:
certs:
vhost:
html:
caddy版:
version: '3.3'
services:
caddy:
image: caddy:2.7.6
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy/site:/srv
- ./caddy/caddy_data:/data
- ./caddy/caddy_config:/config
depends_on:
- app
app:
image: fireflyiii/core:version-6.0.30
container_name: firefly_app
restart: always
volumes:
- firefly_iii_upload:/var/www/html/storage/upload
env_file: .env
depends_on:
- redis
db:
# docker 20.10.10 以上使用最新
image: mariadb:10.11.6
# image: mariadb:10.7.8-focal
container_name: firefly_db
hostname: fireflyiiidb
restart: always
env_file: .db.env
volumes:
- ./firefly_iii_db:/var/lib/mysql
- ./my.cnf:/etc/mysql/conf.d/my.cnf --rm
cron:
image: alpine:3.19
restart: always
container_name: firefly_cron
command: sh -c "echo \"0 3 * * * wget -qO- http://app:8080/api/v1/cron/sEkDhFJ9UDfm6HiGm647YaYV5CFz7qRZ\" | crontab - && crond -f -L /dev/stdout"
redis:
image: redis:6.0.9
container_name: redis
restart: always
# ports:
# - 6379:6379
volumes:
- ./redis/data:/data
- ./redis/logs:/var/log/redis/redis.log
- ./redis/conf/redis.conf:/etc/redis/redis.conf
- /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
environment:
- TZ=Asia/Shanghai
- LANG=en_US.UTF-8
command:
redis-server /etc/redis/redis.conf # 启动redis命令
depends_on:
- db
volumes:
firefly_iii_upload:
firefly_iii_db:
2、修改配置文件
下载wget https://raw.githubusercontent.com/firefly-iii/firefly-iii/v6.0.11/.env.example
cp .env.example .env
根据自己需要自行修改即可,简单说下配置redis
# If you're looking for performance improvements, you could install memcached or redis
CACHE_DRIVER=redis
SESSION_DRIVER=redis
# If you set either of the options above to 'redis', you might want to update these settings too
# If you use Docker or similar, you can set REDIS_HOST_FILE, REDIS_PASSWORD_FILE or
# REDIS_PORT_FILE to set the value from a file instead of from an environment variable
# can be tcp, unix or http
REDIS_SCHEME=tcp
# use only when using 'unix' for REDIS_SCHEME. Leave empty otherwise.
REDIS_PATH=
# use only when using 'tcp' or 'http' for REDIS_SCHEME. Leave empty otherwise.
REDIS_HOST=redis
REDIS_PORT=6379
# Use only with Redis 6+ with proper ACL set. Leave empty otherwise.
REDIS_USERNAME=
REDIS_PASSWORD=
# always use quotes and make sure redis db "0" and "1" exists. Otherwise change accordingly.
REDIS_DB="0"
REDIS_CACHE_DB="1"
下载wget https://raw.githubusercontent.com/redis/redis/unstable/redis.conf
根据自己需要自行修改即可
最后docker-compose up -d
启动
docker-compose logs -f --tail=500
查看日志
现在fireflyiii已成功启动了,你可能会遇到很多错误,养成看日志的习惯,接下来就是使用了,不难😎
选项-偏好设定
修改语言为中文
空了再写吧!🤣
财务数据特别重要,所以一定要备份
这个shell 根据命令执行即可备份
新建backup.sh
#!/bin/bash
#本地备份
echo "开始备份"
bash /path/to/fireflyiii/firefly-iii-backuper.sh backup /path/to/fireflyiii/backup/firefly-$(date '+%F').tar
echo "备份完成"
#备份到tg群里,不要删掉即可
# Define variables
token=""
chat_id=""
message_thread_id=""
file_path="/path/to/fireflyiii/backup/firefly-$(date '+%F').tar"
text="备份成功"
# Send file to telegram
curl -F chat_id="$chat_id" -F message_thread_id="$message_thread_id" -F document=@"$file_path" https://api.telegram.org/bot$token/sendDocument
添加到cron内
3 1 * * * bash /path/to/fireflyiii/backup.sh