Skip to content

Commit

Permalink
Update documentation (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
pastakhov authored Oct 26, 2024
1 parent 35799a8 commit 3977336
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ jobs:

# Push image to GitHub Packages.
# The image tag pattern is:
# for pull-requests: <MW_CORE_VERSION>-<DATE>-<PR_NUMBER>, eg: 1.35.2-20210125-25
# for pull-requests: <DATE>-<PR_NUMBER>, eg: 20210125-25
# for tags: <TAG>
# for `master` branch: latest + <DATE>-<SHA>
# <MW_CORE_VERSION> being parsed from the Dockerfile
push:
needs: [test]
runs-on: ubuntu-latest
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions example_compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 3977336

Please sign in to comment.