Simple utility to setup a git repository in a docker and update it periodically
- 3 Jun 17 - This is under development! Currently only tested with user+token
I wanted a
docker image that only did one thing - setup up a
git repository in your docker and take care of refreshing it on a schedule.
That way it could be more easily pulled into other builds as needed and resused for multiple repositories
alpine:latest as this is a popular base for other lightweight builds.
What it does
git-setupto run everyminute until
$REPOis set and it runs successfully
git-refreshto run periodically (default 10m)
in standalone mode
crondin the foreground to keep the docker running.
as inherited build
What it doesn't do
- Start your app
- Expose ports
docker build -t repo-refresher:latest . docker run -d -e REPO=test -e GIT_BASE=github.com/ITealist --name=my-test:0.1
You set the configuration with environment variables. This allows the utility to be run outside docker as well if desired.
REFRESH- _in cron syntax eg
* * * * *or the current default
*/10 * * * *See [Cron Tutorial[(https://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800) if you need help
Note These settings can also be set by mounting a directory
gitwith corresponding files. See the
GIT_BASE- _the host and username/orgname where the repository resides. eg
GIT_USER- the username for authentication, if needed.
GIT_KEY- _the auth token for GIT_USER, if needed._
REPOrequired - the name of the repository to pull. Is also used as the name of the file repository is pulled into
BRANCHdefault=master allows you to sync to a specific branch. useful for version branches or comparison testing
STAGEdefaults to branch _allows you to specify the stage (eg
prod) if working in staged environments
GIT_FULL_allows you to fully specify the target repo
Credentials can either be supplied as
ENVs or via files in the mounted
git Environment Variables will take precedence. When using the file, the value is expected to be the only contents and on the first line without any quotes
- User: Either
- Key: Either
- Base: Either
This break-down of parameters is intended to facilitate a higher degree of reuse by allowing the same
git directory to be mounted onto multiple docker. In cases where that is not needed,
$GIT_FULL can be used to completely bypass.
Example of file contents