Skip to content

Commit

Permalink
Fix Ofelia integration and enable execution via labels (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanjaw authored Oct 20, 2024
1 parent 8f547aa commit 376b478
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 28 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
docker run --name cronned-rclone \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v $PWD/ofelia.ini:/config/ofelia.ini \
-d ${{ env.DOCKER_IMAGE_TAG }}
-d ${{ env.DOCKER_IMAGE_TAG }} daemon --config=/config/ofelia.ini
# Wait for 10 seconds
sleep 10
Expand All @@ -52,9 +52,4 @@ jobs:
docker logs cronned-rclone # Print logs for debugging
exit 1 # Fail the job
fi
- name: Test Rclone Version
run: |
docker run --rm ${{ env.DOCKER_IMAGE_TAG }} rclone version
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
config.ini
config.ini
docker-compose.yml
compose.yml
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ COPY --from=ofelia /usr/bin/ofelia /usr/local/bin/ofelia

COPY --from=rclone /usr/local/bin/rclone /usr/local/bin/rclone

# Run Ofelia daemon to handle job scheduling
CMD ["ofelia", "daemon", "--config=/config/ofelia.ini"]
RUN mkdir -p /config/rclone

ENV RCLONE_CONFIG=/config/rclone

ENTRYPOINT ["/usr/local/bin/ofelia"]
54 changes: 35 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# 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)

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.
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.

## Features

- **Rclone Integration**: Leverage the powerful [Rclone](https://rclone.org/) for cloud operations (sync, copy, move, etc.).
- **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.

---
Expand All @@ -14,15 +16,17 @@ A lightweight container tool that wraps Rclone with cron jobs using Ofelia. Easi
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).
- 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.
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`:

Expand Down Expand Up @@ -69,7 +73,8 @@ slack-only-on-error = true

### 2. Run the Container

After preparing your configuration file, run the `cronned-rclone` Docker container. Ensure your config file is accessible at the root of your project (e.g., `/project`).
After preparing your configuration file, run the `cronned-rclone` Docker container. Ensure your config file is
accessible at the root of your project (e.g., `/project`).

```bash
docker run --name cronned-rclone \
Expand All @@ -79,6 +84,13 @@ docker run --name cronned-rclone \
-v /path/to/your/rclone/logs:/logs \
-v /path/to/your/rclone/data:/data \
adnanjaw/cronned-rclone:latest
daemon --config=/config/ofelia.ini
```

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

```bash
daemon --docker
```

#### Run with Docker Compose
Expand All @@ -87,20 +99,23 @@ To run the container using Docker Compose, create a `docker-compose.yml` file:

```yaml
services:
cronned-rclone:
image: 'adnanjaw/cronned-rclone:latest'
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /path/to/ofelia/config.ini:/config/ofelia.ini
- /path/to/your/rclone/data:/data
- /path/to/your/rclone/logs:/logs
- /path/to/your/rclone/config:/config/rclone
container_name: cronned-rclone
cronned-rclone:
image: 'adnanjaw/cronned-rclone:latest'
command: daemon --config=/config/ofelia.ini
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /path/to/ofelia/config.ini:/config/ofelia.ini
- /path/to/your/rclone/data:/data
- /path/to/your/rclone/logs:/logs
- /path/to/your/rclone/config:/config/rclone
container_name: cronned-rclone
```
### 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.
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.
---
Expand All @@ -115,10 +130,11 @@ If you want to modify the Docker image or build it locally, follow these steps:

2. Build and run the Docker image using Taskfile:
```bash
task up --
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /path/to/ofelia/config.ini:/config/ofelia.ini \
-v /path/to/your/rclone/config:/config/rclone
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
```

---
Expand Down
7 changes: 7 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ tasks:
- docker build -t {{.IMAGE}} .
- docker run {{.CLI_ARGS}} -d --name {{.CONTAINER_NAME}} {{.IMAGE}}

build:
desc: Build Image
vars:
IMAGE: '{{.image | default "cronned-rclone"}}'
cmds:
- docker build -t {{.IMAGE}} .

down:
desc: Stop and remove services
vars:
Expand Down
17 changes: 17 additions & 0 deletions compose.yml.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
cronned-rclone:
build:
context: .
container_name: cronned-rclone-test
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./config.ini:/config/ofelia.ini
- ./config.conf:/config/rclone/rclone.conf
command: >
daemon --config=/config/ofelia.ini &&
networks:
- rclone
restart: unless-stopped

networks:
rclone:

0 comments on commit 376b478

Please sign in to comment.