Ranch2Git keeps track of your Rancher stacks. It is supposed to be deployed as a Dockerimage. As such, it can be easily deployed with Rancher, making it really easy to use.
Automated builds of the image are available on Dockerhub and is the recommended method of installation.
docker pull gmentsik/ranch2git
Alternatively you can build the image yourself.
docker build -t ranch2git github.com/gmentsik/ranch2git
The recommended way of running ranch2git is to deploy it directly as service in Rancher.
-
Create a new Git-Repository on your host. This can be any Git-Repo on any host. Please note that currently only HTTP(S) is supported, since the main target is Github and GitLab
-
Make sure you have access to your repo with a username + password combination. (HTTP Simple Auth)
-
Add a new Account API Key in Rancher Rancher Web UI -> API -> Add Account API Key
-
You can copy&paste this docker-compose file in a new rancher-stack.
-
Replace the
RANCHER_API_USER
andRANCHER_API_PASS
environmental variables with the generated User and Password.
version: '2'
services:
ranch2github:
image: gmentsik/ranch2git:latest
environment:
RANCHER_APIV2_URL: http://rancher-url.com/v2-beta
RANCHER_API_USER: api-user
RANCHER_API_PASS: api-user-password
GIT_REPO_URL: https://github.com/username/repo.git
GIT_REPO_USER: username
GIT_REPO_PASS: password
UPDATE_EVERY: 5m
stdin_open: true
network_mode: host
tty: true
labels:
io.rancher.container.pull_image: always
*OR you can use the v1 API for older rancher versions
version: '2'
services:
ranch2github:
image: gmentsik/ranch2git
environment:
GIT_REPO_URL: https://github.com/username/repo.git
GIT_REPO_USER: git-user
GIT_REPO_PASS: git-password
UPDATE_EVERY: 1h
labels:
io.rancher.container.create_agent: "true"
io.rancher.container.agent.role: "environment"
stdin_open: true
network_mode: host
tty: true
Alternatively, you can use the sample docker-compose.yml file to start the container using Docker Compose
Variable | Default Value | Description | Examples |
---|---|---|---|
RANCHER_APIV2_URL | "" | The full URL to your Rancher API V2 | http://rancher.company1.com/v2-beta |
RANCHER_API_USER | "" | The generated rancher API User | 2CE23B40FA3761K91C66 |
RANCHER_API_PASS | "" | The generated password of your rancher API User | A2nO8r43jAMrXMQeJd5VpFvEYHKzYgKPSuuTt7ct |
GIT_REPO_URL | "" | Full http URL to your Git-Repository | https://github.com/company1/rancher-conf.git |
GIT_REPO_USER | "" | Your Git-Username | company1 |
GIT_REPO_PASS | "" | Your Git Password | soVeryStrongPasswordCannotBeHacked |
UPDATE_EVERY | "5m" | The Frequency of the script execution. | 1m , 10s , 2h |
You can use the v1 API by adding two labels to your service
io.rancher.container.create_agent=true
io.rancher.container.agent.role=environment
This will provide the three environment variables required to access the rancher api.
For debugging and maintenance purposes you may want access the containers shell. If you are using Docker version 1.3.0
or higher you can access a running containers shell by starting bash
using docker exec
:
docker exec -it ranch2git bash
everything happens inside the /root
folder.
If you find this image useful here's how you can help:
- Send a pull request with your awesome features and bug fixes, to the
dev branch
. - Help users resolve their issues.
Before reporting your issue please try updating Docker to the latest version and check if it resolves the issue. Refer to the Docker installation guide for instructions.
SELinux users should try disabling SELinux using the command setenforce 0
to see if it resolves the issue.
If the above recommendations do not help then report your issue along with the following information:
- Output of the
docker version
anddocker info
commands - The
docker run
command ordocker-compose.yml
used to start the image. Mask out the sensitive bits. - Please state if you are using Boot2Docker, VirtualBox, etc.