diff --git a/.env.sample b/.env.sample index e2a81c4..cea333b 100644 --- a/.env.sample +++ b/.env.sample @@ -9,3 +9,8 @@ COMPOSE_FILE="compose.yml" # Single Sign On via Traefik "file provider" #COMPOSE_FILE="$COMPOSE_FILE:compose.sso.yml" + +# Git-pull regularly +#COMPOSE_FILE="$COMPOSE_FILE:compose.git-pull.yml" +#GIT_REPO_URL="https://git.coopcloud.tech/dalmationer/hexbomb.gay" +#CRON_SCHEDULE="*/1 * * * *" diff --git a/abra.sh b/abra.sh index 2b7a61b..d35163d 100644 --- a/abra.sh +++ b/abra.sh @@ -1 +1,2 @@ export NGINX_DEFAULT_CONF_VERSION=v1 +export ENTRYPOINT_CONF_VERSION=v3 diff --git a/compose.git-pull.yml b/compose.git-pull.yml new file mode 100644 index 0000000..4871891 --- /dev/null +++ b/compose.git-pull.yml @@ -0,0 +1,26 @@ +version: "3.8" +services: + git: + environment: + - GIT_REPO_URL + image: alpine/git:v2.32.0 + entrypoint: /docker-entrypoint.sh + volumes: + - content:/git + configs: + - source: entrypoint_conf + target: /docker-entrypoint.sh + mode: 0555 + deploy: + mode: replicated + replicas: 0 + labels: + - "swarm.cronjob.enable=true" + - "swarm.cronjob.schedule=${CRON_SCHEDULE:-*/5 * * * *}" + restart_policy: + condition: none + +configs: + entrypoint_conf: + name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION} + file: entrypoint.git-pull.sh diff --git a/entrypoint.git-pull.sh b/entrypoint.git-pull.sh new file mode 100644 index 0000000..16682ef --- /dev/null +++ b/entrypoint.git-pull.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ ! -d /git/.git ]; then + echo "No repo found, emptying /git/ directory" + rm -r /git/* + echo "Cloning $GIT_REPO_URL into /git" + git clone "$GIT_REPO_URL" /git +else + echo "Updating /git" + git pull +fi