Files
opencloud-compose/thumbnails/imagor.yml
Jörn Friedrich Dreyer 9456bdbdd7 run the thumbnails service in its own container (#435)
* run the thumbnails service in its own container

Since 9.0.0 the thumbnails service is a stateless resizer: webdav posts
the source image to WEBDAV_THUMBNAILS_GENERATOR_URL and keeps the
cache. We now start it as `opencloud thumbnails server` in a dedicated
container from the same image and exclude it from the main container.

Decoding untrusted images is a classic attack surface. The new
container has no access to the config, the secrets or the data, runs
read-only without capabilities and is only reachable on the internal
thumbnails-net. The service has no authentication, so it must not be
exposed. It costs about 50MB of RAM for the extra process.

The exclude list becomes static, so the idm files simply add
thumbnails to it. This avoids the order dependent
EXCLUDE_ADDITIONAL_SERVICES workaround of
https://github.com/opencloud-eu/opencloud-compose/pull/422, the imagor
module only has to point the generator URL at imagor.

The container registers with an in memory registry, there is no nats
to talk to and webdav uses the URL anyway.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* let imagor replace the thumbnails container

thumbnails/imagor.yml now scales the built-in thumbnails container to
0 instead of leaving it idle next to imagor. opencloud only waits for
imagor, the depends_on of the base file is replaced with !override,
which needs docker compose 2.24.4 or newer.

Scaling to 0 instead of a profile also stops a running thumbnails
container when imagor is added to an existing deployment. Removing
imagor.yml again brings it back, --remove-orphans cleans up imagor.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2026-11-25 14:49:44 +01:00

52 lines
1.4 KiB
YAML

---
services:
imagor:
image: ${IMAGOR_DOCKER_IMAGE:-shumc/imagor}:${IMAGOR_DOCKER_TAG:-1.10.5}
environment:
IMAGOR_UNSAFE: "true"
UPLOAD_LOADER_ENABLE: "true"
UPLOAD_LOADER_MAX_ALLOWED_SIZE: ${IMAGOR_MAX_SOURCE_SIZE:-50000000}
HTTP_LOADER_DISABLE: "true"
VIPS_MAX_WIDTH: "7680"
VIPS_MAX_HEIGHT: "7680"
VIPS_MAX_ANIMATION_FRAMES: "100"
networks:
imagor-net:
read_only: true
tmpfs:
- /tmp:size=256m
cap_drop:
- ALL
security_opt:
- no-new-privileges:true
restart: always
logging:
driver: ${LOG_DRIVER:-local}
healthcheck:
test: ["CMD", "curl", "-sf", "http://127.0.0.1:8000/healthcheck"]
interval: 5s
timeout: 5s
retries: 10
start_period: 5s
opencloud:
environment:
WEBDAV_THUMBNAILS_GENERATOR_URL: http://imagor:8000
OC_THUMBNAILS_ADDITIONAL_SOURCE_TYPES: ${THUMBNAILS_ADDITIONAL_SOURCE_TYPES:-image/heic,image/heif,image/avif,image/heic-sequence,image/heif-sequence}
networks:
imagor-net:
# replaces the thumbnails container, so opencloud must not wait for it
depends_on: !override
imagor:
condition: service_healthy
# imagor replaces the built-in thumbnails container. Scaling it to 0 also stops
# it when imagor is added to an existing deployment.
thumbnails:
deploy:
replicas: 0
networks:
imagor-net:
internal: true