How to make preview generator cronjob using docker?

I like to add a cron job to my docker based nextcloud installation. When I simply add this using crontab in the image it will be gone after updating. However, I do use a seperate docker container in my stack for the cron like this:

  cron:
   image: nextcloud:apache
   container_name: Nextcloud-CRON
   restart: always
   volumes:
     - /volume1/docker/nextcloud/config:/var/www/html/config:rw
     - /volume1/docker/nextcloud/html:/var/www/html:rw
     - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps:rw
     - /volume3/RAID/data/nextcloud:/var/www/html/data:rw
   entrypoint: /cron.sh
   depends_on:
    mariadb:
       condition: service_started
    redis:
       condition: service_started

How could I configure the job for the preview generator?

Hi I’m using this approach at my docker compose for the cron and previewgen as a seperate docker containers

the key point is the environment variable SIDECAR_CRON=1 and SIDECAR_PREVIEWGEN=1

cron:
    container_name: nextcloud-fx-cron
    image: nextcloud:fpm
    environment:
      - CRON_PERIOD=*/5 * * * *
      - MEMORY_LIMIT=1024M
      - OPCACHE_MEM_SIZE=128
      - SIDECAR_CRON=1
      - TZ=Europe/Istanbul
      - UPLOAD_MAX_SIZE=10G
    restart: unless-stopped
    volumes:
      # NOTE: The `volumes` config of the `cron` and `app` containers must match
      - /DATA/AppData/nextcloud-fx/nextcloud:/var/www/html
    entrypoint: /cron.sh

previewgen:
    container_name: nextcloud-fx-previewgen
    hostname: nextcloud-fx-previewgen
    image: nextcloud:fpm
    environment:
      - MEMORY_LIMIT=512M
      - OPCACHE_MEM_SIZE=128
      - PREVIEWGEN_PERIOD=0 * * * *
      - SIDECAR_PREVIEWGEN=1
      - TZ=Europe/Istanbul
      - UPLOAD_MAX_SIZE=512M
    volumes:
      # NOTE: The `volumes` config of the `cron` and `app` containers must match
      # - /DATA/AppData/nextcloud-fx/nextcloud:/var/www/html
      # - /DATA/AppData/nextcloud-fx/previewgen:/var/www/html
      - nextcloud_fx_previewgen_data:/var/www/html

volumes:
  # this volume mounted because i had some issues about binding the main nextcloud container volume for the previewgen
  nextcloud_fx_previewgen_data: