From 96199120221e3eb5827f0c3c938d4bc3ac528155 Mon Sep 17 00:00:00 2001 From: David Riegel <40246197+davidriegel@users.noreply.github.com> Date: Fri, 4 Sep 2026 15:22:14 +0200 Subject: [PATCH] fix: keep the worker's model caches across deploys The image worker downloads a CLIP model when app.services.image_processing is imported, and u2netp on the first job. Both landed in the container layer, so every deploy recreated the container, threw them away and left the worker downloading before it consumed the queue. Uploads sat queued until it finished, and the app gave up polling after 60 seconds. Named volumes for /root/.cache and /root/.u2net keep both across recreations. Only the worker imports the model, so the api and email-worker services do not need them. --- docker-compose.dev.yml | 4 ++++ docker-compose.yml | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 025de54..124bcec 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -100,6 +100,8 @@ services: env_file: .env volumes: - ./:/app + - model_cache_dev:/root/.cache + - u2net_models_dev:/root/.u2net depends_on: redis: condition: service_healthy @@ -138,3 +140,5 @@ networks: volumes: mysql_data_dev: redis_data_dev: + model_cache_dev: + u2net_models_dev: diff --git a/docker-compose.yml b/docker-compose.yml index 2bba8b7..76953c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,6 +104,11 @@ services: - ./app/static:/app/app/static - ./app/uploads:/app/app/uploads - ./logs:/app/logs + # The worker downloads its models on first import and on first job. Without + # these the caches live in the container layer, so every deploy recreates the + # container, wipes them and leaves uploads queued until the models are back. + - model_cache:/root/.cache + - u2net_models:/root/.u2net depends_on: redis: condition: service_healthy @@ -144,3 +149,5 @@ networks: volumes: mysql_data: redis_data: + model_cache: + u2net_models: