A docker image allowing you to sync a folder with a git repository.
To use it, you must pass the following environment variables:
GIT_REPO_URL
: URL of the Git repository to sync to, for examplessh://[email protected]/foo/bar.git
.GIT_REPO_BRANCH
: Branch of the Git repository to sync to, for exampleproduction
. Defaults tomaster
.GIT_USER_EMAIL
: E-Mail address of author to show in commitsGIT_USER_NAME
: Name of author to show in commits
Optionally, you can set
CRON_TIME
: The execution time of the sync cronjob. For the syntax check CronHowto. Default is every minute (*/1 * * * *
).
Furthermore you need to setup the following two volumes:
/root/.ssh
: This volume should contain a valid ssh key (id_rsa
andid_rsa.pub
) with write access to the specified git repository. Also it should contain a validknown_hosts
file./sync-dir
: The contents of this volume will be synced to the speciefied git repository. If this directory is not empty (but does not contain a git repository) the sync will be aborted. In this case you need to pass the flag--overwrite-local
to the container or set the environment variableOVERWRITE_LOCAL
totrue
.
After proper setup this image will execute a cron job every minute and sync the contents of the volume /sync-dir to the specified git repository.
Of course you can mount the volumes to some directories of the host.