use Oban for startup variant processing, add vips-heif

VariantCache now enqueues missing variants via OptimizeWorker instead
of processing directly with Task.async_stream. Simpler and uses the
existing job queue. Adds vips-heif to Docker runtime for HEIF support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey 2026-02-22 09:24:34 +00:00
parent 19d8c7d0fd
commit 75b9ff3156
2 changed files with 3 additions and 27 deletions

View File

@ -87,7 +87,7 @@ RUN mix release
FROM ${RUNNER_IMAGE} AS runner FROM ${RUNNER_IMAGE} AS runner
# Runtime deps only — no compilers, no -dev packages # Runtime deps only — no compilers, no -dev packages
RUN apk add --no-cache libstdc++ openssl ncurses-libs vips RUN apk add --no-cache libstdc++ openssl ncurses-libs vips vips-heif
WORKDIR /app WORKDIR /app

View File

@ -75,33 +75,9 @@ defmodule Berrypod.Images.VariantCache do
if to_process == [] do if to_process == [] do
Logger.info("[VariantCache] All database image variants up to date") Logger.info("[VariantCache] All database image variants up to date")
else else
Logger.info( Logger.info("[VariantCache] Enqueueing #{length(to_process)} images with missing variants")
"[VariantCache] Processing #{length(to_process)} images with missing variants..."
)
# Process directly instead of round-tripping through Oban — more reliable at startup Enum.each(to_process, fn {id, _source_width} -> OptimizeWorker.enqueue(id) end)
to_process
|> Task.async_stream(
fn {id, _source_width} ->
case Optimizer.process_for_image(id) do
{:ok, _} ->
:ok
{:error, reason} ->
Logger.warning("[VariantCache] Failed to process #{id}: #{inspect(reason)}")
end
end,
max_concurrency: 4,
timeout: :timer.seconds(30),
on_timeout: :kill_task
)
|> Enum.count(fn
{:ok, :ok} -> true
_ -> false
end)
|> then(fn count ->
Logger.info("[VariantCache] Processed #{count}/#{length(to_process)} image variants")
end)
end end
end end