New import methodology, done from static directory mapped in FireFly

This commit is contained in:
2026-03-06 20:49:37 -05:00
parent 0c39445d71
commit 7e17ec1fea
3 changed files with 75 additions and 86 deletions

View File

@@ -19,13 +19,15 @@ imports/
checking.csv
↓ import.sh
↓ (POST each JSON+CSV pair to FIDI /autoimport)
↓ (POST to FIDI /autoimport — FIDI reads the directory itself)
Firefly III ✓
```
CSV files are paired with their FIDI config by base name: `checking.json` + `checking.csv`.
FIDI scans the mounted import directory and imports all JSON+CSV pairs it finds.
## Requirements
- bash
@@ -50,16 +52,48 @@ chmod +x import.sh watch-imports.sh
# e.g.: imports/checking.json, imports/jerickdiscover.json
```
## FIDI Docker configuration
FIDI must be able to read the `imports/` directory. Mount it as a volume and whitelist it:
**docker-compose.yml:**
```yaml
fidi:
image: fireflyiii/data-importer:latest
restart: always
env_file: .fidi.env
volumes:
- /path/to/.fidi.env:/var/www/html/.env:ro
- /var/vault/Finances/firefly-importer/imports:/imports:ro
ports:
- 8082:8080
```
**.fidi.env** (add these lines):
```
CAN_POST_AUTOIMPORT=true
AUTO_IMPORT_SECRET=<your-secret>
IMPORT_DIR_WHITELIST=/imports
```
> **Note:** PHP-FPM does not inherit Docker container environment variables. The `.fidi.env` file must be volume-mounted as `/var/www/html/.env` inside the container (in addition to being referenced by `env_file`).
After updating docker-compose.yml, restart FIDI:
```bash
docker compose up -d fidi
```
## Configuration
All config lives in `.env` (never committed to git):
| Variable | Required | Default | Description |
|---------------------|----------|---------------|--------------------------------------------------------------------|
|---------------------|----------|---------------|-----------------------------------------------------------------------|
| `FIDI_URL` | Yes | — | URL of your FIDI instance, e.g. `http://localhost:8080` |
| `FIDI_SECRET` | No | — | FIDI `AUTO_IMPORT_SECRET` value |
| `FIDI_ACCESS_TOKEN` | No | — | Firefly III Personal Access Token |
| `IMPORT_DIR` | No | `./imports` | Directory with JSON configs and staged CSVs |
| `FIDI_IMPORT_DIR` | No | `/imports` | Path to imports dir *inside the FIDI container* (must match volume mount target and `IMPORT_DIR_WHITELIST`) |
| `IMPORT_DIR` | No | `./imports` | Local directory with JSON configs and staged CSVs |
| `INCOMING_DIR` | No | `./incoming` | Drop zone for raw CSV files |
| `AUTO_IMPORT` | No | `false` | Run `import.sh` automatically after a file is staged |
| `POLL_INTERVAL` | No | `10` | Seconds between directory scans |
@@ -85,7 +119,7 @@ Useful for batch runs or cron jobs:
### Run the importer
Posts all staged JSON+CSV pairs to FIDI:
Tells FIDI to import all staged JSON+CSV pairs from the mounted directory:
```bash
./import.sh
@@ -138,7 +172,7 @@ sudo journalctl -u firefly-importer -f
```
firefly-importer/
├── import.sh # Batch importer — POSTs JSON+CSV pairs to FIDI
├── import.sh # Batch importer — triggers FIDI /autoimport for the mounted directory
├── watch-imports.sh # File watcher — processes and stages incoming CSVs
├── firefly-importer.service # systemd unit file
├── .env.example # Config template