The gitsync module that syncs git repositories in your project
961
gitsync is a lightweight bash-based tool designed to automatically check for remote changes in a specified Git repository and pull updates if necessary. The tool is containerized using Docker, allowing easy deployment in various environments. It can be used as a module in Docker Compose setups for seamless synchronization of repositories.
To build and run gitsync locally using Docker:
git clone https://github.com/TheArqsz/gitsync.git
cd gitsync
docker build -t gitsync .
docker run -e BASIC_AUTH=1 -e USERNAME=YourUsername -e PASSWORD_OR_KEY_FILE=/run/secrets/password_or_key_secret -v /path/to/your/repo:/workspace -v git_password:/run/secrets/password_or_key_secret gitsync
or
docker run -e SSH_PRIVATE_KEY_FILE=/id_rsa -v /path/to/your/repo:/workspace -v ~/.ssh/id_rsa:/id_rsa -e TIMEOUT=10 gitsync
etc.
The Docker image runs a bash script (entrypoint.sh) that will:
| Variable | Description | Required | Default Value | Example Values |
|---|---|---|---|---|
BASIC_AUTH | Enables basic authentication for HTTP/HTTPS Git remotes. Set to 1 to use. | Yes (if http authentication required) | None | 1 |
USERNAME | The Git username for basic authentication. | Yes (if http authentication required) | None | GithubUser |
PASSWORD_OR_KEY_FILE | Path to the file containing the password or API key for basic authentication. | No (needs to be passed through secrets) | None | /run/secrets/password_or_key_secret |
MAIN_BRANCH | The main branch to track and pull from. | No | main | main, master |
TIMEOUT | The interval in seconds between sync checks. | No | 60 | 120, 300 |
SSH_PRIVATE_KEY_FILE | Path to the SSH private key for SSH Git remotes. | No | /id_rsa | /root/.ssh/id_rsa |
VERBOSE | Enables verbose logging if set (useful for debugging). | No | None | 1 (any value) |
gitsync can be easily integrated as a module in a docker-compose.yml setup. Below is an example configuration:
services:
gitsync:
image: thearqsz/gitsync:latest
container_name: gitsync
volumes:
- $HOME/example-repo:/workspace
environment:
- BASIC_AUTH=1
- USERNAME=GithubUser
- PASSWORD_OR_KEY_FILE=/run/secrets/password_or_key_secret
secrets:
- password_or_key_secret
secrets:
password_or_key_secret:
environment: PASSWORD_OR_KEY
In this example:
$HOME/example-repo is mounted to the container's /workspace directory.Other examples:
This project is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:60bcbf357…
Size
11.9 MB
Last updated
almost 2 years ago
docker pull thearqsz/gitsync