Skip to content

Commit ed46164

Browse files
authored
Merge pull request #1 from stakater/develop
run git2consul command from stakater user
2 parents ce5e909 + 596087e commit ed46164

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
FROM stakater/node:6.9
2-
LABEL authors="Ali Tariq <ali.chaudhary2009@gmail.com>"
2+
MAINTAINER "Stakater Team"
33

4-
RUN npm install -g git2consul \
5-
&& apk update && apk upgrade && apk add --no-cache bash git openssh
4+
RUN npm install -g git2consul@0.12.13 \
5+
&& apk -Uuv add --no-cache git openssh 'su-exec>=0.2'
6+
7+
RUN rm -rf /etc/service/node && mkdir -p /etc/service/git2consul
8+
ADD start.sh /etc/service/git2consul/run
9+
10+
11+
ENV COMMAND="git2consul --endpoint 127.0.0.1 --port 80 --config-file /home/git2consul/config.json"

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# dockerfile-git2consul
2-
dockerfile image for git2consul
1+
# Dockerfile-git2consul
2+
Dockerfile image for git2consul
3+
<h3>git2consul </h3>
4+
`git2consul` takes one or more git repositories and then map them on to the consul server. Target is to read configurations from git repo and save them as key value pairs in consul server. <br>
5+
Any change in git repo is mapped on to the consul server after every 1 minute.
6+
<h3>Usage</h3>
7+
To run the docker container of `git2consul`, set command in environment variable `command`.
8+
<br>E.g:<br> ```docker run -d -e COMMAND="git2consul --endpoint 127.0.0.1 --port 80 --config-file /home/git2consul/config.json" -v /home/git2consul/:/home/git2consul stakater/git2consul:0.12.13```
9+
<br>
10+
11+
where endpoint is the location of the consul server, port is the consul server port and config.json file contains the information of git repository and some other configurations of `git2consul`.
12+
<br>
13+
Example `config.json`:
14+
```
15+
{
16+
"version": "1.0",
17+
"repos" : [{
18+
"name" : "keyValue pairs",
19+
"url" : "your git repo link",
20+
"branches" : ["dev"],
21+
"include_branch_name" : false,
22+
"ignore_repo_name" : true,
23+
"ignore_file_extension" : true,
24+
"expand_keys": true,
25+
"hooks": [{
26+
"type" : "polling",
27+
"interval" : "1"
28+
}]
29+
}]
30+
}
31+
```
32+
You can learn more about `git2consul` configurations [here](https://github.com/breser/git2consul).<br>
33+
If you do not set command in environment variable `command`, container will run default command, which is as follow: <br>
34+
`git2consul --endpoint 127.0.0.1 --port 80 --config-file /home/git2consul/config.json`
35+
<h3>Available Versions</h3>
36+
`v0.12.13`
37+
<h3>Layers</h3>
38+
alpine:3.5 > stakater/base-alpine:3.5 > stataker/node/6.9 > stakater/git2consul

start.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Convert COMMAND variable into an array
5+
# Simulating positional parameter behaviour
6+
IFS=' ' read -r -a CMD_ARRAY <<< "$COMMAND"
7+
8+
# explicitly setting positional parameters ($@) to CMD_ARRAY
9+
set -- "${CMD_ARRAY[@]}"
10+
# From this point, positional parameters ($@)will be set to the parameters in the COMMAND variable.
11+
12+
# chown home and data folder
13+
chown -R stakater /home/git2consul
14+
exec su-exec stakater "$@"

0 commit comments

Comments
 (0)