Skip to content

Commit

Permalink
Adding support for neglected env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Titmus committed Dec 27, 2018
1 parent 7a8bbbe commit e9e83de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 13 additions & 3 deletions build/generate-crontab.sh
@@ -1,6 +1,6 @@
#!/bin/bash

DEFAULT_CRON="0 0 * * *"
DEFAULT_CRON="0 9 * * *"

if [ "$CRON" ]
then
Expand All @@ -12,11 +12,21 @@ fi

GC_ARGS=""

if [ "$CLEAN_UP_VOLUMES" ]
then
GC_ARGS="$GC_ARGS CLEAN_UP_VOLUMES=$CLEAN_UP_VOLUMES"
fi

if [ "$DRY_RUN" ]
then
GC_ARGS="$GC_ARGS DRY_RUN=$DRY_RUN"
fi

if [ "$EXCLUDE_VOLUMES_IDS_FILE" ]
then
GC_ARGS="$GC_ARGS EXCLUDE_VOLUMES_IDS_FILE=$EXCLUDE_VOLUMES_IDS_FILE"
fi

if [ "$FORCE_CONTAINER_REMOVAL" ]
then
GC_ARGS="$GC_ARGS FORCE_CONTAINER_REMOVAL=$FORCE_CONTAINER_REMOVAL"
Expand All @@ -32,9 +42,9 @@ then
GC_ARGS="$GC_ARGS GRACE_PERIOD_SECONDS=$GRACE_PERIOD_SECONDS"
fi

if [ "$CLEAN_UP_VOLUMES" ]
if [ "$MINIMUM_IMAGES_TO_SAVE" ]
then
GC_ARGS="$GC_ARGS CLEAN_UP_VOLUMES=$CLEAN_UP_VOLUMES"
GC_ARGS="$GC_ARGS MINIMUM_IMAGES_TO_SAVE=$MINIMUM_IMAGES_TO_SAVE"
fi

echo -e "$CRON" "$GC_ARGS sh /executed-by-cron.sh" '>> /var/log/cron.log 2>&1'"\n" > crontab.tmp
4 changes: 2 additions & 2 deletions compose/docker-compose.yml
Expand Up @@ -8,7 +8,7 @@ dockergc:
- ./docker-gc-exclude:/etc/docker-gc-exclude
environment:
# By default, docker-gc is run every night at midnight. Change this variable to override.
- CRON=0 0 * * *
- CRON=0 9,21 * * *

# By default, docker will not remove an image if it is tagged in multiple repositories. If
# you have a server running docker where this is the case, for example in CI environments
Expand All @@ -18,7 +18,7 @@ dockergc:
# By default, if an error is encountered when cleaning up a container, Docker will report the
# error back and leave it on disk. This can sometimes lead to containers accumulating. If
# you run into this issue, you can force the removal of the container by setting this flag.
- FORCE_CONTAINER_REMOVAL=0
- FORCE_CONTAINER_REMOVAL=1

# By default, docker-gc will not remove a container if it exited less than 1 hour ago.
# Set the GRACE_PERIOD_SECONDS variable to override this default.
Expand Down
5 changes: 3 additions & 2 deletions compose/docker-gc-exclude
Expand Up @@ -6,5 +6,6 @@
#
####################################################################################################

clockworksoul/docker-gc-cron:latest
e61267dbe31b
clockworksoul/docker-gc-cron:latest

jupyter/tensorflow-notebook:latest

0 comments on commit e9e83de

Please sign in to comment.