https://github.com/qodesmith/unraid-cron-jobs
Cron jobs I run on my Unraid server
https://github.com/qodesmith/unraid-cron-jobs
Last synced: 2 months ago
JSON representation
Cron jobs I run on my Unraid server
- Host: GitHub
- URL: https://github.com/qodesmith/unraid-cron-jobs
- Owner: qodesmith
- Created: 2024-06-16T23:58:43.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-11T21:27:21.000Z (over 1 year ago)
- Last Synced: 2025-01-24T22:42:44.594Z (over 1 year ago)
- Language: TypeScript
- Size: 1.12 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# unraid-cron-jobs
## Project List
| Name | Custom Dockerfile | Description |
| ------------------------ | :---------------: | ---------------------------------------------------------------------- |
| `scrape-cassettes` | | Download all the cassettes at [tapedeck.org](http://www.tapedeck.org/) |
| `prune-notion-backups ` | | Keep only `n` number of Notion backups |
| `download-youtube-beats` | ✅ | Download beats from the YouTube playlist |
| `backup-github` | | Archive all Github repos |
## Build / Publish
The root `package.json` file is the entrypoint to building and publishing
the various projects. There are a number of scripts to choose from, all of which
will call `build.ts` in different ways.
### Project-Specific Dependencies
To include project-specific depdencies, simply install that dependency at the
root-level `package.json` file and consume the dependency in the project.
All dependencies for all projects are declared in the root-level `package.json`.
The build process includes analyzing each project's import tree to calculate the
specific depdencies needed for that project. A project-specific `package.json`
will then be created including only those dependencies used by that project.
## Env Vars
### Universal Env Vars
| Env variable | Description |
| ------------- | --------------------------------------------------------------------------------------------- |
| `CRON_TIME` | Sets the cron time value. Each project will also have it's own default value to fall back on. |
| `DESTINATION` | path where data (if applicable) are stored in the container. |
### Project-Specific Env Vars
These env vars should be set in [docker-compose.yml](./docker-compose.yml).
See the [dl-yt-playlist](https://github.com/qodesmith/dl-yt-playlist?tab=readme-ov-file#usage) docs for details on the `download-youtube-beats` env variables.
| Project | Env variable | Description |
| --------------------------- | ---------------------------- | ----------------------------------------------------------------------------------------- |
| `prune-notion-backups` | `BACKUP_LIMIT` | _(optional)_ Max number of backups to keep (defaults to 4) |
| `backup-github` | `GIT_CONFIG_GLOBAL` | `/gitconfig/.gitconfig` - location to the global git config (for git versions >= 2.34) |
| | `GIT_CONFIG` | `/gitconfig/.gitconfig` - location to the global git config (for git versions < 2.34) |
| `download-youtube-playlist` | `FETCHNOW_QUERY_KEY` | Read from a `.env` file on the Unraid server - enables manually triggering a cron job run |
| | `FETCHNOW_QUERY_VALUE` | Read from a `.env` file on the Unraid server - enables manually triggering a cron job run |
| | `BEATS_CRON_CONTAINER_NAME` | Read from a `.env` file on the Unraid server - enables manually triggering a cron job run |
| | `BEATS_CRON_CONTAINER_PORT` | Read from a `.env` file on the Unraid server - enables manually triggering a cron job run |
| | `PLAYLIST_ID` | Read from a `.env` file on the Unraid server |
| | `YOUTUBE_API_KEY` | Read from a `.env` file on the Unraid server |
| | `DOWNLOAD_TYPE` | Type of file to download |
| | `AUDIO_FORMAT` | _(optional)_ |
| | `VIDEO_FORMAT` | _(optional)_ |
| | `DOWNLOAD_THUMBNAILS` | _(optional)_ |
| | `MAX_DURATION_SECONDS` | _(optional)_ |
| | `MOST_RECENT_ITEMS_COUNT` | _(optional)_ |
| | `SILENT` | _(optional)_ |
| | `MAX_CONCURRENT_FETCH_CALLS` | _(optional)_ |
| | `MAX_CONCURRENT_YTDLP_CALLS` | _(optional)_ |
| | `SAVE_RAW_RESPONSES` | _(optional)_ |
## Organization
### Folders === image names
The `/projects` folder will contain _dash-cased_ lowercase names for each Docker
project. These names will turn into an image pushed to Dockerhub in the format
`qodesmith/`.
### Each project...
#### `cronJob.ts`
Each project contains a `cronJob.ts` entrypoint file.
#### Dockerfiles are optional
Since each project is a cron job and follows the same basic rules, individual
`Dockerfile`s aren't necessary. The `Dockerfile.basic` file in the root
directory is used for each project.
Should a project have particular needs, a `Dockerfile` can be created in its
directory and will be used when building the image.
#### `dockerfileArgs.json`
Each project can specify `ARG`s that will be dynamically added to the Docker
build with this file. Keys and values will turn into:
```
--build-arg =
```
## Build
The build happens via `build.ts` at the root.
| npm script | Description |
| ---------------------- | --------------------------------------------------------------------------- |
| `build.all` | Build Docker images for _Unraid_ without pushing to Dockerhub |
| `build.all.local` | Build Docker images for the local environment without pushing to Dockerhub |
| `publishProjects` | Build Docker images for _Unraid_ and push everything to Dockerhub |
| `publishSingleProject` | Build a single project's Docker image for _Unraid_ and push it to Dockerhub |
## Compose
The `docker-compose.yml` file is _only_ for running each project in Unraid. It
is not meant to build the projects.
The point is to build & push everything to Dockerhub first, then in Unraid use a
single compose file to start all the projects, avoiding the need to install them
individually.
### Updating the containers in Unraid
Regardless of if a single project or all projects were built, the Docker Compose
plugin in Unraid will know to pull only the images that have changed.
Simply click the "Update Stack" button. All containers will be restarted.