Skip to content

Commit

Permalink
Adding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanjaw committed Oct 29, 2024
1 parent b6581ca commit 2545c8c
Show file tree
Hide file tree
Showing 12 changed files with 705 additions and 178 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Documentation

on:
push:
branches:
- master

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pages
uses: actions/configure-pages@v5

- name: Build docs
run: docker run --rm -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5 build

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release cronned-rclone
name: Release

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test cronned-rclone
name: Testing

on:
push:
Expand Down
182 changes: 6 additions & 176 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,187 +1,17 @@
# Cronned-rclone [![Test cronned-rclone](https://github.com/adnanjaw/cronned-rclone/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/adnanjaw/cronned-rclone/actions/workflows/test.yml) | [![Release cronned-rclone](https://github.com/adnanjaw/cronned-rclone/actions/workflows/release.yml/badge.svg)](https://github.com/adnanjaw/cronned-rclone/actions/workflows/release.yml)
# cronned-rclone

A lightweight container tool that wraps Rclone with cron jobs using Ofelia. Easily schedule Rclone commands with
flexible cron expressions via INI-style configurations or Docker labels, while utilizing all standard Rclone commands.
[![Test image](https://github.com/adnanjaw/cronned-rclone/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/adnanjaw/cronned-rclone/actions/workflows/test.yml)
[![Release image](https://github.com/adnanjaw/cronned-rclone/actions/workflows/release.yml/badge.svg)](https://github.com/adnanjaw/cronned-rclone/actions/workflows/release.yml)

## Features
## Documentation

- **Rclone Integration**: Leverage the powerful [Rclone](https://rclone.org/) for cloud operations (sync, copy, move,
etc.).
- **Ofelia Scheduler**: Schedule tasks easily with [Ofelia](https://github.com/mcuadros/ofelia) and cron jobs.

---

## Prerequisites

Before you begin, ensure you have the following installed on your system:

- [Docker](https://docs.docker.com/get-docker/)
- A basic understanding of [Rclone](https://rclone.org/) and cron job scheduling
using [Ofelia](https://github.com/mcuadros/ofelia).

---

## Usage

### 1. Create a Configuration File

Define your cron jobs using a configuration file (e.g., `config.ini`). Refer to
the [Ofelia documentation](https://github.com/mcuadros/ofelia) for more details on available parameters.

#### Example `config.ini`:

```ini
### Jobs Reference Documentation: https://github.com/mcuadros/ofelia/blob/master/docs/jobs.md ###
[job-exec "job-executed-on-running-container"]
schedule = @hourly
container = my-container
command = touch /tmp/example

[job-run "job-executed-on-new-container"]
schedule = @hourly
image = ubuntu:latest
command = touch /tmp/example

[job-local "job-executed-on-current-host"]
schedule = @hourly
command = touch /tmp/example

[job-service-run "service-executed-on-new-container"]
schedule = 0,20,40 * * * *
image = ubuntu
network = swarm_network
command = touch /tmp/example

[global]
### Logging Settings ###
save-folder = /logs
save-only-on-error = false

### Email Settings ###
smtp-host = smtp.example.com
smtp-port = 587
smtp-user = username
smtp-password = password
email-to = recipient@example.com
email-from = sender@example.com
mail-only-on-error = true

### Slack Notifications ###
slack-webhook = https://hooks.slack.com/services/your/webhook/url
slack-only-on-error = true
```

### 2. Run the Container

After preparing your configuration file, run the `cronned-rclone` Docker container.

```bash
docker run --name cronned-rclone \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ${PWD}/ofelia/config.ini:/config/ofelia.ini \
-v ${PWD}/rclone/rclone.conf:/config/rclone/rclone.conf \
-v ${PWD}/rclone/logs:/logs \
-v ${PWD}/rclone/data:/data \
adnanjaw/cronned-rclone:latest daemon --config=/config/ofelia.ini
```

#### Labels

In case you are using Ofelia labels, you can add this command at the end of your Docker run or Docker Compose command.

```bash
docker run --name cronned-rclone \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ${PWD}/rclone/rclone.conf:/config/rclone/rclone.conf \
-v ${PWD}/rclone/logs:/logs \
-v ${PWD}/rclone/data:/data \
-v ${PWD}/test.txt:/tmp/test.txt \
--label ofelia.enabled=true \
--label ofelia.job-local.upload-file.schedule="@every 60s" \
--label ofelia.job-local.upload-file.command="rclone copy /tmp/test.txt s3:/bucket/directory" \
adnanjaw/cronned-rclone:latest daemon --docker
```

#### Run with Docker Compose

To run the container using Docker Compose, create a `compose.yaml` file:

```yaml
services:
cronned-rclone:
image: adnanjaw/cronned-rclone:latest
command: daemon --config=/config/ofelia.ini
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./ofelia/config.ini:/config/ofelia.ini
- ./rclone/data:/data
- ./rclone/logs:/logs
- ./rclone/config:/config/rclone
```
#### Labels
```yaml
services:
cronned-rclone:
image: adnanjaw/cronned-rclone:latest
command: daemon --docker
labels:
ofelia.enabled: true
ofelia.job-local.upload-file.schedule: "@every 60s"
ofelia.job-local.upload-file.command: "rclone copy /tmp/test.txt s3:/bucket/directory"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./rclone/data:/data
- ./rclone/logs:/logs
- ./rclone/config:/config/rclone
- ./test.txt:/tmp/test.txt
```
### 3. Verify Cron Jobs
The cron jobs will execute according to the schedule specified in your configuration file. Logs will be saved in the
respective log files you specify in the configuration, or you can receive notifications via Slack or email based on your
setup.
---
## Building the Image Locally
If you want to modify the Docker image or build it locally, follow these steps:
1. Clone this repository:
```bash
git clone git@github.com:adnanjaw/cronned-rclone.git
```

2. Build and run the Docker image using Taskfile:
```bash
docker run --name cronned-rclone \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ./config.ini:/config/ofelia.ini \
-v ./config.conf:/config/rclone \
cronned-rclone daemon --config=/config/ofelia.ini
```

---

## Contributing

We welcome contributions! Here’s how you can help:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes.
4. Commit your changes (`git commit -m 'Add new feature'`).
5. Push to the branch (`git push origin feature-branch`).
6. Open a pull request.
The documentation is available at [https://github.com/adnanjaw/cronned-rclone](https://adnanjaw.github.io/cronned-rclone).

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.

---

Expand Down
12 changes: 12 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,15 @@ tasks:
- docker image tag {{.IMAGE}} {{.IMAGE}}:{{.TAG}}
- docker push {{.IMAGE}}:{{.TAG}}
- printf "\033[32m%s\033[0m\n" "Built and pushed image '{{.IMAGE}}:{{.TAG}}'"

mkdocs:
desc: MkDocs build
cmds:
- docker run --rm -it -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5 build

mkdocs:live:
desc: MkDocs development server
vars:
PORT: '{{.p | default "8001"}}'
cmds:
- docker run --rm -it -p {{.PORT}}:8000 -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5
31 changes: 31 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contributing

We welcome contributions! Here’s how you can help:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes.
4. Commit your changes (`git commit -m 'Add new feature'`).
5. Push to the branch (`git push origin feature-branch`).
6. Open a pull request.

---

## Building the Image Locally

If you want to modify the Docker image or build it locally, follow these steps:

1. Clone this repository:
```bash
git clone git@github.com:adnanjaw/cronned-rclone.git
```

2. Build and run the Docker image using Taskfile:
```bash
docker run --name cronned-rclone \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v ./config.ini:/config/ofelia.ini \
-v ./config.conf:/config/rclone \
cronned-rclone daemon --config=/config/ofelia.ini
```

Loading

0 comments on commit 2545c8c

Please sign in to comment.