Skip to content

Commit

Permalink
Merge pull request #335 from jolicode/cron
Browse files Browse the repository at this point in the history
fix cron cookbook
  • Loading branch information
lyrixx authored Nov 28, 2024
2 parents cf04ef9 + 8b9428f commit 857a26a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,12 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
COPY crontab /etc/cron.d/crontab
COPY --link cron/crontab /etc/cron.d/crontab
COPY --link cron/entrypoint.sh /entrypoint.sh
RUN crontab /etc/cron.d/crontab
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["cron", "-f"]
```

Expand All @@ -740,13 +743,26 @@ And you can add all your crons in the `services/php/crontab` file:
* * * * * su app -c "/usr/local/bin/php -r 'echo time().PHP_EOL;'" > /proc/1/fd/1 2>&1
```

And you can add the following content to the `services/php/entrypoint.sh` file:
```bash
#!/usr/bin/env bash
if ! id -u ${USER_ID} &>/dev/null; then
useradd -u ${USER_ID} -o -m -s /bin/bash ${USER_ID}
fi
exec "$@"
```

Finally, add the following content to the `docker-compose.yml` file:
```yaml
services:
cron:
build:
context: services/php
target: cron
environment:
- "USER_ID=${USER_ID}"
volumes:
- "../..:/var/www:cached"
profiles:
Expand Down

0 comments on commit 857a26a

Please sign in to comment.