This project allows you to monitor multiple private Git repositories for Docker Compose projects and automatically deploy them when changes are detected.
- Per-project configuration using
configfiles - Zero-downtime Docker Compose deployment logic
- Supports commit message directives for control:
[compose:down]: Force full restart (compose down/up)[compose:up]: Force in-place update (compose up --build)[compose:restart:<service>]: Restart a specific service[compose:noop]: Skip deployment
- Discord notifications on changes, errors, and deployment actions (with commit message and hash)
- systemd timers for periodic polling
- Robust error handling and validation of required config/environment variables
- Cross-platform (Linux/macOS) shell scripting, no third-party dependencies
Before installing, create a dedicated Linux user to securely manage Docker Compose deployments.
sudo useradd --system --create-home --shell /usr/sbin/nologin composebotsudo usermod -aG docker composebotIf your GitHub repository is private, configure SSH keys for composebot:
sudo -u composebot ssh-keygen -t ed25519 -f /home/composebot/.ssh/github_compose -N ""sudo -u composebot mkdir -p /home/composebot/.ssh
sudo -u composebot bash -c 'echo -e "Host github.com\n HostName github.com\n IdentityFile ~/.ssh/github_compose\n IdentitiesOnly yes" > /home/composebot/.ssh/config'
sudo chown -R composebot:composebot /home/composebot/.ssh
chmod 700 /home/composebot/.ssh
sudo chmod 600 /home/composebot/.ssh/github_compose
sudo chmod 600 /home/composebot/.ssh/github_compose.pub
sudo chmod 600 /home/composebot/.ssh/configsudo ssh-keyscan github.com | sudo -u composebot tee /home/composebot/.ssh/known_hosts > /dev/null
sudo chmod 600 /home/composebot/.ssh/known_hostsThis ensures git clone and git fetch work without prompting to trust GitHub the first time.
/opt/git-docker-compose-monitor/
common/
compose-deploy.sh
projects/
project1/
config
/etc/systemd/system/
git-docker-compose-monitor.service
git-docker-compose-monitor.timer-
Edit the config file:
Editprojects/project1/configwith your Git repo and webhook details.
Required variables:PROJECT_NAMEPROJECT_DIRREPO_URL- (Optional)
DISCORD_WEBHOOK_URL(can also be set as an environment variable)
-
Copy the script and config to your target location:
Placecompose-deploy.shand yourconfigfile in a directory on your server, for example:sudo mkdir -p /opt/git-docker-compose-monitor/projects/project1 sudo cp common/compose-deploy.sh /opt/git-docker-compose-monitor/common/ sudo cp projects/project1/config /opt/git-docker-compose-monitor/projects/project1/config sudo chmod +x /opt/git-docker-compose-monitor/common/compose-deploy.sh
-
Install the systemd service and timer:
Copy the provided unit files to/etc/systemd/system/:sudo cp systemd/git-docker-compose-monitor.service /etc/systemd/system/ sudo cp systemd/git-docker-compose-monitor.timer /etc/systemd/system/
-
Enable and start the timer:
sudo systemctl daemon-reload sudo systemctl enable --now git-docker-compose-monitor.timer -
View logs:
journalctl -u git-docker-compose-monitor
-
Manual run (for testing):
You can manually run the script at any time:/opt/git-docker-compose-monitor/common/compose-deploy.sh --config-file=/opt/git-docker-compose-monitor/projects/project1/config
Example usage:
/opt/git-docker-compose-monitor/common/compose-deploy.sh --config-file=/opt/git-docker-compose-monitor/projects/project1/config--config-file=PATH: (Required) Specify the configuration file for the project.--test-discord: Send a test notification to the configured Discord webhook and exit. The test message includes a realistic multi-line commit message and a full-length commit hash.--log-level=LEVEL: Set log verbosity. Options areDEBUG,INFO,WARN,ERROR. Default isINFO.--force-sync: Force agit pullfrom the remote repository before any other actions.--force-up: Rundocker compose up -dregardless of git or Compose file changes. If used with--force-sync, the git pull will happen first.--helpor-h: Show usage information.
Example:
./compose-deploy.sh --config-file=./projects/project1/config --force-sync --force-up --log-level=DEBUG- yq is required for YAML parsing.
Install with:The script will exit with an error ifsudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 sudo chmod +x /usr/local/bin/yq
yqis not installed.
- The interval for checking floating tag images (e.g.,
latest,develop,edge,nightly) is controlled byFLOATING_IMAGE_PULL_INTERVAL_MINUTESin your config file. - Set to
0to disable floating tag image checks entirely. - When enabled, the script will only redeploy containers if the image ID of the running container differs from the latest pulled image.
- The script validates that all required variables are set in the config file.
- The
DISCORD_WEBHOOK_URLmust be set in the environment or config. - All user-facing messages are timestamped and respect the configured log level.
- If Docker Compose commands fail, error output is sent to Discord.
- All Discord notifications are properly escaped for Markdown and JSON.
- Deployment notifications include the action, commit hash (as code), and commit message.
- Errors and important events are sent to Discord with full context.
- Markdown formatting is preserved for commit hashes and messages.
MIT