From 3977336972d29e55613fe73e6a5fbb0cacfd64bf Mon Sep 17 00:00:00 2001 From: Pavel Astakhov Date: Sat, 26 Oct 2024 18:20:43 +0500 Subject: [PATCH] Update documentation (#4) --- .github/workflows/docker-image.yml | 3 +-- README.md | 12 +++++++----- example_compose.yml | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6d4fd6b..214e166 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -36,10 +36,9 @@ jobs: # Push image to GitHub Packages. # The image tag pattern is: - # for pull-requests: --, eg: 1.35.2-20210125-25 + # for pull-requests: -, eg: 20210125-25 # for tags: # for `master` branch: latest + - - # being parsed from the Dockerfile push: needs: [test] runs-on: ubuntu-latest diff --git a/README.md b/README.md index 8331187..6fd3697 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ services: cron: image: ghcr.io/wikiteq/cron volumes: - - /var/run/docker.sock:/var/run/docker.sock + - /var/run/docker.sock:/var/run/docker.sock:ro - ./logs/cron:/var/log/cron environment: - COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} @@ -34,13 +34,15 @@ services: build: ./app container_name: app labels: - - cron.mytask.schedule="* * * * *" - - cron.mytask.command="/usr/local/bin/app_script.sh" - - cron.another_task.schedule="*/2 * * * *" - - cron.another_task.command="/usr/local/bin/another_app_script.sh" + cron.mytask.schedule: "* * * * *" + cron.mytask.command: "/usr/local/bin/app_script.sh" + cron.another_task.schedule: "*/2 * * * *" + cron.another_task.command: "/usr/local/bin/another_app_script.sh" ``` This example shows how to schedule multiple cron jobs using cron syntax. The Docker container will run `/usr/local/bin/app_script.sh` every minute and `/usr/local/bin/another_app_script.sh` every two minutes, with logs stored in `/var/log/cron/`. +> **Note:** Ensure to mount the Docker socket (read-only mode) in your `docker-compose.yml` file to allow for proper interaction with Docker. + ### Environment Variables The `example_compose.yml` file uses several environment variables. Make sure to define these in a `.env` file in the root directory of your project: - **`COMPOSE_PROJECT_NAME`**: Specifies the name of the Docker Compose project, allowing the cron to target jobs in that specific project. **Note**: If `COMPOSE_PROJECT_NAME` is not defined, the cron container will process jobs from *all* Docker Compose stacks on the computer. In this scenario, cron jobs may be executed multiple times if multiple cron containers are running without `COMPOSE_PROJECT_NAME` defined. diff --git a/example_compose.yml b/example_compose.yml index c5b7ee5..88553f3 100644 --- a/example_compose.yml +++ b/example_compose.yml @@ -12,7 +12,7 @@ services: build: ./app container_name: app labels: - - cron.mytask.schedule="* * * * *" - - cron.mytask.command="/usr/local/bin/app_script.sh" - - cron.another_task.schedule="*/2 * * * *" - - cron.another_task.command="/usr/local/bin/another_app_script.sh" + cron.mytask.schedule: "* * * * *" + cron.mytask.command: "/usr/local/bin/app_script.sh" + cron.another_task.schedule: "*/2 * * * *" + cron.another_task.command: "/usr/local/bin/another_app_script.sh"