Add git-pull functionality 💅

This commit is contained in:
3wc 2022-03-23 11:57:26 +02:00
parent b8dec9d61a
commit 2158fa1fc4
4 changed files with 43 additions and 0 deletions

View File

@ -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 * * * *"

View File

@ -1 +1,2 @@
export NGINX_DEFAULT_CONF_VERSION=v1
export ENTRYPOINT_CONF_VERSION=v3

26
compose.git-pull.yml Normal file
View File

@ -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

11
entrypoint.git-pull.sh Normal file
View File

@ -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