diff --git a/sites/005-hugo-extended/docker-compose.yml b/sites/005-hugo-extended/docker-compose.yml index cb0af64..f80afaa 100644 --- a/sites/005-hugo-extended/docker-compose.yml +++ b/sites/005-hugo-extended/docker-compose.yml @@ -13,5 +13,10 @@ services: - ./site/output:/app ports: - 8080:8080 + watcher: + image: gm2sup/git-auto-pull + volumes: + - ./site:/repo + - ~/.ssh:/ssh diff --git a/sites/005-hugo-extended/git-auto-pull/Dockerfile b/sites/005-hugo-extended/git-auto-pull/Dockerfile new file mode 100644 index 0000000..2c328ae --- /dev/null +++ b/sites/005-hugo-extended/git-auto-pull/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine as alpine + +RUN apk add --no-cache git openssh-client + +ADD pull.sh entrypoint.sh / +RUN chmod +x pull.sh entrypoint.sh + +RUN echo "*/2 * * * * /pull.sh" > crontab.txt +RUN crontab crontab.txt + +WORKDIR /repo +VOLUME /repo +VOLUME /ssh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/sites/005-hugo-extended/git-auto-pull/entrypoint.sh b/sites/005-hugo-extended/git-auto-pull/entrypoint.sh new file mode 100644 index 0000000..8e95c64 --- /dev/null +++ b/sites/005-hugo-extended/git-auto-pull/entrypoint.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +mkdir /root/.ssh && cp /ssh/* /root/.ssh && crond -f diff --git a/sites/005-hugo-extended/git-auto-pull/pull.sh b/sites/005-hugo-extended/git-auto-pull/pull.sh new file mode 100644 index 0000000..1c69e25 --- /dev/null +++ b/sites/005-hugo-extended/git-auto-pull/pull.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +LOG=/var/log/pull.log +touch $LOG +echo `date`": start pulling" >> $LOG +cd /repo && git pull +echo `date`": done" >> $LOG + +