Downloads official instruction PDFs from LEGO, located via the Brickset API, one set per interval (10 minutes by default) so neither API gets hammered. Official sets only; MOCs are excluded throughout. - New admin page at /admin/instruction-fetch: queue builder, pacing controls, live countdown and per-set job history - Database-backed queue (instruction_fetch_jobs) and last-run timestamp, so pacing survives restarts - Background worker thread, plus 'flask instructions queue/run/status' for Task Scheduler or cron - SHA-256 dedupe (instructions.sha256), PDF header check, size cap and streaming downloads via temp files - brickset_api: getInstructions2 by set number and getInstructions by setID (the old code sent a set number to the setID method); getSets params now proper JSON; getKeyUsageStats added - Schema top-ups applied automatically at boot: new table plus instructions.sha256/source - Docker: fetcher env vars passed through compose, no worker thread in the entrypoint bootstrap
69 lines
2.3 KiB
YAML
69 lines
2.3 KiB
YAML
# LEGO Instructions Manager - Docker Compose stack
|
|
#
|
|
# docker compose up -d --build
|
|
#
|
|
# Configuration lives in .env next to this file (copy .env.docker.example).
|
|
# Created by: Jess Rogerson (yelling commands at Claude.AI)
|
|
|
|
services:
|
|
db:
|
|
image: postgres:16-alpine
|
|
container_name: lim-db
|
|
restart: unless-stopped
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-lim}
|
|
POSTGRES_USER: ${POSTGRES_USER:-lim}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD must be set in .env}
|
|
# Keeps index/sort behaviour stable across Postgres upgrades.
|
|
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
|
|
volumes:
|
|
- lim-db:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-lim} -d ${POSTGRES_DB:-lim}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 10
|
|
start_period: 20s
|
|
# Not published to the host: only the app container needs to reach it.
|
|
expose:
|
|
- "5432"
|
|
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
image: lim:latest
|
|
container_name: lim-app
|
|
restart: unless-stopped
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
FLASK_APP: run.py
|
|
FLASK_ENV: production
|
|
SECRET_KEY: ${SECRET_KEY:?SECRET_KEY must be set in .env}
|
|
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER:-lim}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB:-lim}
|
|
UPLOAD_FOLDER: /data/uploads
|
|
BACKUP_FOLDER: /data/backups
|
|
BACKUP_KEEP: ${BACKUP_KEEP:-7}
|
|
MAX_CONTENT_LENGTH: ${MAX_CONTENT_LENGTH:-52428800}
|
|
SETS_PER_PAGE: ${SETS_PER_PAGE:-20}
|
|
BRICKSET_API_KEY: ${BRICKSET_API_KEY:-}
|
|
BRICKSET_USERNAME: ${BRICKSET_USERNAME:-}
|
|
BRICKSET_PASSWORD: ${BRICKSET_PASSWORD:-}
|
|
# Automatic instruction fetcher. Safe to leave on: gunicorn runs a
|
|
# single worker here, so there is exactly one ticker, and it does
|
|
# nothing until an admin enables it in the UI.
|
|
INSTRUCTION_FETCH_WORKER: ${INSTRUCTION_FETCH_WORKER:-1}
|
|
INSTRUCTION_FETCH_TICK_SECONDS: ${INSTRUCTION_FETCH_TICK_SECONDS:-20}
|
|
FETCH_MAX_FILE_MB: ${FETCH_MAX_FILE_MB:-150}
|
|
FETCH_TIMEOUT_SECONDS: ${FETCH_TIMEOUT_SECONDS:-60}
|
|
volumes:
|
|
- lim-data:/data
|
|
ports:
|
|
- "${LIM_PORT:-8000}:8000"
|
|
|
|
volumes:
|
|
lim-db:
|
|
lim-data:
|