Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Last active August 29, 2015 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlebkowski/bda94232a266dbdf45d7 to your computer and use it in GitHub Desktop.
Save mlebkowski/bda94232a266dbdf45d7 to your computer and use it in GitHub Desktop.
dokku post-release hook for crontab jobs
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE="dokku/$APP"
CRONTABS_DIR=$DOKKU_ROOT/.crontab
CONFIG_FILE=$CRONTABS_DIR/$APP.conf
mkdir -p "$CRONTABS_DIR";
docker run -i -a stdout "$IMAGE" cat /app/crontab \
| sed s_'%CONTAINER'_"docker run -e CRON=1 -i -a stdout $IMAGE /exec"_g > "$CONFIG_FILE"
[ ! -s "$CONFIG_FILE" ] && echo " Installing crontab" || rm "$CONFIG_FILE" || :
cat "$CRONTABS_DIR"/* > "$CRONTABS_DIR/crontab"
crontab "$CRONTABS_DIR/crontab"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment