From 19bdd3faa9574c3db6693b5ae990b6b4ec255041 Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Tue, 16 Jun 2026 13:20:27 +0300 Subject: [PATCH] build(project): add one-shot dedup compose service Adds a `dedup` task service under the "tools" profile so it's kept out of `docker compose up` and run on demand: docker compose run --rm dedup # hashes, then rebuild pairs docker compose run --rm dedup -pairs # only rebuild pairs docker compose run --rm dedup -hashes # only backfill hashes It reuses the app image, .env, volumes and networks, overriding only the entrypoint to /app/dedup. Unlike `docker exec` on the live server, this runs in its own container and is self-documented for cron/CI use. Co-Authored-By: Claude Opus 4.8 --- docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 8bc9ff8..b5aa3e3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -114,6 +114,40 @@ services: timeout: 5s retries: 10 + # One-shot maintenance task for duplicate detection: computes missing + # perceptual hashes (images + video) and rebuilds the duplicate-pairs table. + # It is NOT a daemon — the "tools" profile keeps it out of `docker compose up`; + # run it on demand, and it exits when done: + # + # docker compose run --rm dedup # hashes, then rebuild pairs + # docker compose run --rm dedup -pairs # only rebuild pairs (after uploads) + # docker compose run --rm dedup -hashes # only backfill hashes + # + # Reuses the app image, .env, volumes and networks; only the entrypoint differs + # (/app/dedup instead of the server). Connects to the same DB the app uses, so + # the app's DB (bundled or host) must be reachable when it runs. + dedup: + build: + context: . + dockerfile: Dockerfile + profiles: ["tools"] + env_file: .env + networks: + - web + - backend + depends_on: + db: + condition: service_healthy + required: false + extra_hosts: + - "host.docker.internal:host-gateway" + user: "${PUID:-42776}:${PGID:-42776}" + volumes: + - "${FILES_DIR:-app_files}:/data/files" + - "${THUMBS_DIR:-app_thumbs}:/data/thumbs" + entrypoint: ["/app/dedup"] + restart: "no" + networks: # Public-facing bridge for this app. The explicit bridge name (instead of # Docker's random br-) makes it identifiable on the host for tcpdump and