diff --git a/docs/docs/configuration/scheduled.md b/docs/docs/configuration/scheduled.md new file mode 100644 index 0000000..f968b56 --- /dev/null +++ b/docs/docs/configuration/scheduled.md @@ -0,0 +1,33 @@ +--- +sidebar_position: 3 +title: Scheduling +description: "How to run configarr regulary/schedueld" +keywords: [configarr configuration, schedule, scheduler, regular, cron] +--- + +# Scheduling configarr + +This section describes how you could run configarr in a scheduled manner. + +:::info +Configarr does not support scheduled execution inside the container and most likely never will. +Scheduling functionalities should be something which is handled outside of the container and something which should be bundled inside each app. +::: + +## Kubernetes + +Kubernetes support for scheduling jobs is straigthforward. +We have explicit resources for this tasks: `CronJobs` +See [Kubernetes Setup](/docs/installation/kubernetes) for more information. + +## Docker + +For docker and docker-compose we do not have explicit functionalities. +Therefore we have to create our own scheduled tasks. +There are different ways we could achieve this: + +- default cron scheduler on linux systems +- running scheduler containers which executes other docker containers + +We have create examples for how to run the container based solutions. +Check [examples/scheduled](/docs/examples#scheduled-example) for more information. diff --git a/docs/docs/examples.md b/docs/docs/examples.md index 8d8dbb4..b406636 100644 --- a/docs/docs/examples.md +++ b/docs/docs/examples.md @@ -52,3 +52,11 @@ To remove all containers and volumes: ```bash docker-compose down -v ``` + +## Scheduled Example + +This is an example of how to execute configarr in a scheduled manner. + +You can find the full example at: [configarr/examples/scheduled](https://github.com/raydak-labs/configarr/tree/main/examples/scheduled) + +Please check the documentation for how to configure and use the variants. diff --git a/examples/scheduled/.gitignore b/examples/scheduled/.gitignore new file mode 100644 index 0000000..dc67370 --- /dev/null +++ b/examples/scheduled/.gitignore @@ -0,0 +1,2 @@ +!config/*.yml +dockerrepos/ diff --git a/examples/scheduled/README.md b/examples/scheduled/README.md new file mode 100644 index 0000000..34958c5 --- /dev/null +++ b/examples/scheduled/README.md @@ -0,0 +1,89 @@ +# Configarr - scheduled exammple + +This is an example how you could run configarr in a scheduled manner outside of kubernetes. +Kubernetes has built in support with CronJobs. + +URLs: + +- radarr: http://localhost:6501 + +Cleanup: + +```bash +docker-compose -f docker-compose.ofelia.yml down -v +docker-compose -f docker-compose.cron.yml -p cron down -v +docker-compose down -v +``` + +## Variant: Ofelia (recommended) + +Compose file: `docker-compose.ofelia.yml` + +This is run with the `ofelia` image (https://github.com/mcuadros/ofelia). +Check guide of ofelia for more configs. +We can rerun an existing container and reuse it or create new containers. +Check `ofelia.ini` for example. + +The example shows two variants. +Please just use one which matches your needs. +Both solutions work: + +- running with an existing container which always exits and will be restarted +- always running a fresh new container. + +```bash +# full path is needed in multiple docker-compose files. Either set direct in file or via env variable +export CONFIGARR_FULL_PATH=$(pwd) +docker-compose up -d + +# ofelia +# Please update paths in ofelia.ini before running +docker-compose -f docker-compose.ofelia.yml -p ofelia up -d +docker-compose -f docker-compose.ofelia.yml -p ofelia logs +# clean +docker-compose -f docker-compose.ofelia.yml -p ofelia down -v +``` + +## Variant: Cron-Like + +Compose file: `docker-compose.cron.yml` + +This starts a container (https://github.com/BlackDark/dockerfiles/tree/main/cron-dind) which will run cron and we have to mount cron like configurations. +Check the compose file and mounted volumes for how this works. +In summary: mount folder with cron files, cron triggers commands defined there. + +The example shows two variants. +Please just use one which matches your needs. +Both solutions work: + +- running with an existing container which always exits and will be restarted +- always running a fresh new container. + +```bash +# full path is needed in multiple docker-compose files. Either set direct in file or via env variable +export CONFIGARR_FULL_PATH=$(pwd) +docker-compose up -d + +# cron like +# please update the paths and uncomment in dir ./cron/* +docker-compose -f docker-compose.cron.yml -p cron up -d cron + +# Optional: If using the container reuse functionality: +docker-compose -f docker-compose.cron.yml -p cron up -d configarr + +docker-compose -f docker-compose.cron.yml -p cron logs + +# clean +docker-compose -f docker-compose.cron.yml -p cron down -v +``` + +## Side notes + +With approaches like this you can easily extends functionalities like: + +- notifications (errored state or not) +- cleanup procedures + +## Drawbacks with some solutions + +- because we are reusing the `docker.sock` (this means running containers on the host) we have to use absolute paths for mounts. diff --git a/examples/scheduled/config/config.yml b/examples/scheduled/config/config.yml new file mode 100644 index 0000000..943a254 --- /dev/null +++ b/examples/scheduled/config/config.yml @@ -0,0 +1,21 @@ +#trashGuideUrl: https://github.com/BlackDark/fork-TRASH-Guides +#recyclarrConfigUrl: https://github.com/BlackDark/fork-recyclarr-configs +localCustomFormatsPath: /app/cfs +localConfigTemplatesPath: /app/templates + +radarr: + instance1: + # Set the URL/API Key to your actual instance + base_url: http://radarr:7878 + #base_url: https://sonarr.oci.eduard-marbach.de/ + api_key: !secret RADARR_API_KEY + + quality_definition: + type: movies + + include: + - template: radarr-quality-definition-movie + - template: radarr-quality-profile-hd-bluray-web + - template: radarr-custom-formats-hd-bluray-web + + custom_formats: [] diff --git a/examples/scheduled/config/secrets.yml b/examples/scheduled/config/secrets.yml new file mode 100644 index 0000000..640d892 --- /dev/null +++ b/examples/scheduled/config/secrets.yml @@ -0,0 +1 @@ +RADARR_API_KEY: 0daa3a2b940f4e08bac991e9a30e9e12 diff --git a/examples/scheduled/cron/configarr-reuse b/examples/scheduled/cron/configarr-reuse new file mode 100644 index 0000000..2887047 --- /dev/null +++ b/examples/scheduled/cron/configarr-reuse @@ -0,0 +1,4 @@ +LOGFILE_DEFAULT=/var/log/cron.log +#CONFIGARR_FULL_PATH=/tmp/configarr/full/path + +* * * * * root docker compose -f /app/docker-compose.yaml -p cron start configarr >> $LOGFILE_DEFAULT 2>&1 diff --git a/examples/scheduled/cron/configarr-run b/examples/scheduled/cron/configarr-run new file mode 100644 index 0000000..a6c0ec5 --- /dev/null +++ b/examples/scheduled/cron/configarr-run @@ -0,0 +1,4 @@ +LOGFILE_DEFAULT=/var/log/cron.log +#CONFIGARR_FULL_PATH=/tmp/configarr/full/path + +* * * * * root docker compose -f /app/docker-compose.yaml -p cron run --rm configarr-run >> $LOGFILE_DEFAULT 2>&1 diff --git a/examples/scheduled/docker-compose.cron.yml b/examples/scheduled/docker-compose.cron.yml new file mode 100644 index 0000000..da1691a --- /dev/null +++ b/examples/scheduled/docker-compose.cron.yml @@ -0,0 +1,32 @@ +services: + configarr: + image: ghcr.io/raydak-labs/configarr:latest + networks: + - configarr-full + volumes: + - ${CONFIGARR_FULL_PATH:?"missing"}/config:/app/config + - ${CONFIGARR_FULL_PATH:?"missing"}/dockerrepos:/app/repos + #- ${CONFIGARR_FULL_PATH:?"missing"}/cfs:/app/cfs + #- ${CONFIGARR_FULL_PATH:?"missing"}/templates:/app/templates + + configarr-run: + image: ghcr.io/raydak-labs/configarr:latest + networks: + - configarr-full + volumes: + - ${CONFIGARR_FULL_PATH:?"missing"}/config:/app/config + - ${CONFIGARR_FULL_PATH:?"missing"}/dockerrepos:/app/repos + #- ${CONFIGARR_FULL_PATH:?"missing"}/cfs:/app/cfs + #- ${CONFIGARR_FULL_PATH:?"missing"}/templates:/app/templates + + cron: + image: blackdark93/dockerfiles-cron-dind:main + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ${CONFIGARR_FULL_PATH:?"missing"}/cron:/app/schedules:ro + - ${CONFIGARR_FULL_PATH:?"missing"}/docker-compose.cron.yml:/app/docker-compose.yaml:ro + +networks: + configarr-full: + name: configarr-full + external: true diff --git a/examples/scheduled/docker-compose.ofelia.yml b/examples/scheduled/docker-compose.ofelia.yml new file mode 100644 index 0000000..f56b5ad --- /dev/null +++ b/examples/scheduled/docker-compose.ofelia.yml @@ -0,0 +1,24 @@ +services: + configarr: + container_name: configarr-reused + image: ghcr.io/raydak-labs/configarr:latest + networks: + - configarr-full + volumes: + - ./config:/app/config + - ./dockerrepos:/app/repos + #- ./cfs:/app/cfs + #- ./templates:/app/templates + + ofelia: + image: mcuadros/ofelia:latest + command: daemon --config=/opt/config.ini + #command: daemon --docker + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ./ofelia.ini:/opt/config.ini + +networks: + configarr-full: + name: configarr-full + external: true diff --git a/examples/scheduled/docker-compose.yml b/examples/scheduled/docker-compose.yml new file mode 100644 index 0000000..6fcb279 --- /dev/null +++ b/examples/scheduled/docker-compose.yml @@ -0,0 +1,22 @@ +services: + radarr: + image: lscr.io/linuxserver/radarr:5.15.1 + networks: + - configarr-full + environment: + - PUID=1000 + - PGID=1000 + - TZ=Etc/UTC + volumes: + - radarr:/config + - ${PWD}/radarr.xml:/config/config.xml:rw + ports: + - 6501:7878 + restart: unless-stopped + +networks: + configarr-full: + name: configarr-full + +volumes: + radarr: diff --git a/examples/scheduled/ofelia.ini b/examples/scheduled/ofelia.ini new file mode 100644 index 0000000..6231d58 --- /dev/null +++ b/examples/scheduled/ofelia.ini @@ -0,0 +1,15 @@ +; Example of how to run on existing container which will be restarted +[job-run "run-configarr-existing-container"] +schedule = @every 10s +container = configarr-reused + +; Creates new container and executes with given parameters +[job-run "run-configarr-new-container"] +schedule = @every 10s +image = ghcr.io/raydak-labs/configarr:latest +; Full path for volume +volume = /tmp/configarr/full/path/config:/app/config +volume = /tmp/configarr/full/path/dockerrepos:/app/repos +;volume = /tmp/configarr/full/path/cfs:/app/cfs +;volume = /tmp/configarr/full/path/templates:/app/templates +network = configarr-full diff --git a/examples/scheduled/radarr.xml b/examples/scheduled/radarr.xml new file mode 100644 index 0000000..2c2cb84 --- /dev/null +++ b/examples/scheduled/radarr.xml @@ -0,0 +1,17 @@ + + * + 7878 + 9898 + False + True + 0daa3a2b940f4e08bac991e9a30e9e12 + Basic + DisabledForLocalAddresses + master + info + + + + Radarr + Docker + \ No newline at end of file