A Docker-based service that automatically keeps your docker-compose.yml file in sync with a GitHub repository and applies changes.
The Self-Updater service:
- Checks a GitHub repository every minute for updates to a docker-compose.yml file
- If changes are detected, updates your local docker-compose.yml file
- Preserves your local
name:
field when updating - Automatically runs
docker compose up -d --remove-orphans
to apply the changes
-
Deploy the service using the provided docker-compose.yml:
docker compose up -d
-
The service will automatically start monitoring for updates to your docker-compose.yml file.
You can customize the service using the following environment variable:
ENV_NAME
: Determines which environment configuration to use (default:prod
)- Affects the Docker image used:
backenddevelopersltd/luxor-updater-${ENV_NAME}:latest
- Affects which GitHub branch is monitored:
deploy-compose-${ENV_NAME}
- Affects the Docker image used:
Example with custom environment:
ENV_NAME=staging docker compose up -d
This will use the backenddevelopersltd/luxor-updater-staging:latest
image and monitor the deploy-compose-staging
branch.
The service is designed to be configurable at build time to point to different GitHub repositories:
ORG_NAME
: The GitHub organization name (default:backend-developers-ltd
)PROJECT_NAME
: The GitHub project name (default:self-updater
)
These values are baked into the Docker image at build time and determine which GitHub repository the service will monitor.
Use the provided build.sh
script to build custom images:
# Using defaults
./build.sh
# With custom organization and project
ORG_NAME=my-org PROJECT_NAME=my-project ./build.sh
# With custom environment
ENV_NAME=dev ./build.sh
# With all custom values
ORG_NAME=my-org PROJECT_NAME=my-project ENV_NAME=dev ./build.sh
The script will build a Docker image with the specified configuration and tag it appropriately.
- The service runs a cron job that executes the
update-check.sh
script every minute - The script fetches the docker-compose.yml from the configured GitHub repository
- It compares the remote file with the local file (ignoring the
name:
field) - If differences are detected:
- The local
name:
value is preserved - The local file is updated with the content from GitHub
docker compose up -d --remove-orphans
is executed to apply changes
- The local
For the service to work properly, your GitHub repository should:
- Have a docker-compose.yml file in the root directory of each branch
- Use branch names in the format
deploy-compose-{environment}
(e.g.,deploy-compose-prod
,deploy-compose-staging
)
If you encounter issues:
-
Check the logs:
docker logs -f updater
-
Ensure the Docker socket is properly mounted
-
Verify that the GitHub repository and branch are accessible
-
Check that your environment variables are set correctly