Skip to content

feat: deploy the CrateWorks Downloader - #149

Open
johnf wants to merge 3 commits into
mainfrom
feat/downloader
Open

johnf wants to merge 3 commits into
mainfrom
feat/downloader

Conversation

@johnf

@johnf johnf commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the CrateWorks Downloader to the production stack at downloader.<DOMAIN> (e.g. downloader.dev.ldaca.edu.au), with its zips kept in versitygw rather than AWS, and to development under the downloader compose profile.

Changes

  • API: /api/files gives each file memberOf: {id, name}, the same shape arocapi gives entities, or null. The Downloader groups exports by it and refuses any export without it. Proposed upstream in Include memberOf in each file's response crate-works/arocapi#153 and Add memberOf to File crate-works/ro-crate-api#45; src/files.ts goes once arocapi does it.
  • Production (deploy/):
    • The downloader service, pinned to 1.15.2 because the image has no major tag yet (Publish major and minor image tags crate-works/downloader#15). The API registers it as the confidential downloader client, with DOWNLOADER_CLIENT_SECRET. It calls the API at http://api:8080/api, inside the stack.
    • s3: versitygw v1.11.0 over DOWNLOADS_DIR, keeping metadata in a sidecar directory so NFS works. The bucket is downloader on DOMAIN, so signed links are https://downloader.<DOMAIN>/exports/…. Caddy sends /exports/* there without cookies, and everything else to the app. Only the Downloader holds the key (DOWNLOADER_S3_SECRET).
    • downloader-setup creates the bucket idempotently, and downloads-cleanup deletes zips two days old.
    • Caddy has DOMAIN and downloader.<DOMAIN> as network aliases, so sign-in and uploads reach it without hairpin NAT.
    • DOWNLOADER_DOMAIN is gone: the hostname has to be downloader.<DOMAIN> for the bucket addressing to work.
  • Development: docker compose --profile downloader up -d runs the Downloader on localhost:7000 against pnpm dev, with versitygw for the zips and moto for SES.
  • deploy/*.env is now gitignored. ldacapi.env never was.
  • README: hostnames, setup, and a Downloader section.

Testing

  • pnpm lint and pnpm test pass with full coverage. There are tests for the file memberOf and for a confidential client that posts its secret without PKCE, as the Downloader does.
  • Dev stack, end to end in headless Chrome: sign in, browse and search, export open files, and the zip lands in versitygw. The emailed signed link downloads it.
  • Signed links on versitygw: the real link is accepted. These are all refused:
    • unsigned, tampered, or for another object
    • the GET link used for PUT or DELETE
    • expired, valid for more than 7 days, or signed with the wrong secret
    • anonymous list or upload
    • path traversal
  • Production stack locally (Caddy with local certificates on ldaca.localhost, versitygw, setup, cleanup):
    • a 12 MiB multipart upload with the Downloader's own SDK, through Caddy's alias
    • its signed https://downloader.ldaca.localhost/exports/… link served uncompressed, with HSTS and nosniff
    • unsigned and tampered requests and bucket listing refused
    • the app's paths still routed to the app
    • cleanup deleting only zips older than two days
  • docker compose config passes for both stacks, and caddy validate passes.

Still to do

  • Email: the Downloader sends only through SES, so on a host without AWS an export fails at its last step. SMTP support is Send emails through SMTP when SMTP_URL is set crate-works/downloader#16.
  • Dev server: its .env already has the secrets and DOWNLOADS_DIR, on local disk because the NFS mount there is read-only. The branch isn't deployed there yet.
  • Downloader bugs, not yet filed:
    • a 403 on one entity's metadata fails the whole export
    • a file described but not held causes an unhandled rejection, and the job never finishes
    • sessions last 15 minutes, as it doesn't refresh tokens

johnf and others added 2 commits November 26, 2026 16:35
The Downloader groups an export by each file's memberOf, which the RO-Crate API's File leaves out,
so /api/files now adds it as {id, name}, as arocapi gives entities, or null.

Co-Authored-By: Claude <noreply@anthropic.com>
The production stack runs the Downloader behind Caddy as the API's downloader client, calling the
API inside the stack; Caddy takes DOMAIN as an alias so sign-in needs no hairpin NAT. Development
gets it under the downloader profile, with moto standing in for S3 and SES. deploy/*.env is now
ignored, as ldacapi.env never was.

Co-Authored-By: Claude <noreply@anthropic.com>
…OMAIN

The zips are kept in versitygw over DOWNLOADS_DIR, with metadata in a sidecar directory so NFS
works, instead of AWS S3. The bucket downloader on DOMAIN puts the signed links at
https://downloader.DOMAIN/exports/, so the Downloader now lives at downloader.DOMAIN and
DOWNLOADER_DOMAIN is gone. A setup service creates the bucket and a cleanup service deletes zips
two days old. Development uses versitygw too, with moto only for SES.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant