diff --git a/Dockerfile b/Dockerfile index 7643a7a..fa6452b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ FROM stakater/node:6.9 -LABEL authors="Ali Tariq " +MAINTAINER "Stakater Team" -RUN npm install -g git2consul \ - && apk update && apk upgrade && apk add --no-cache bash git openssh +RUN npm install -g git2consul@0.12.13 \ + && apk -Uuv add --no-cache git openssh 'su-exec>=0.2' + +RUN rm -rf /etc/service/node && mkdir -p /etc/service/git2consul +ADD start.sh /etc/service/git2consul/run + + +ENV COMMAND="git2consul --endpoint 127.0.0.1 --port 80 --config-file /home/git2consul/config.json" diff --git a/README.md b/README.md index e5c15ac..28cbe62 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,38 @@ -# dockerfile-git2consul -dockerfile image for git2consul +# Dockerfile-git2consul +Dockerfile image for git2consul +

git2consul

+`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.
+Any change in git repo is mapped on to the consul server after every 1 minute. +

Usage

+To run the docker container of `git2consul`, set command in environment variable `command`. +
E.g:
```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``` +
+ +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`. +
+Example `config.json`: +``` +{ + "version": "1.0", + "repos" : [{ + "name" : "keyValue pairs", + "url" : "your git repo link", + "branches" : ["dev"], + "include_branch_name" : false, + "ignore_repo_name" : true, + "ignore_file_extension" : true, + "expand_keys": true, + "hooks": [{ + "type" : "polling", + "interval" : "1" + }] + }] +} +``` +You can learn more about `git2consul` configurations [here](https://github.com/breser/git2consul).
+If you do not set command in environment variable `command`, container will run default command, which is as follow:
+`git2consul --endpoint 127.0.0.1 --port 80 --config-file /home/git2consul/config.json` +

Available Versions

+`v0.12.13` +

Layers

+alpine:3.5 > stakater/base-alpine:3.5 > stataker/node/6.9 > stakater/git2consul diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..50d8ba6 --- /dev/null +++ b/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +# Convert COMMAND variable into an array +# Simulating positional parameter behaviour +IFS=' ' read -r -a CMD_ARRAY <<< "$COMMAND" + +# explicitly setting positional parameters ($@) to CMD_ARRAY +set -- "${CMD_ARRAY[@]}" +# From this point, positional parameters ($@)will be set to the parameters in the COMMAND variable. + +# chown home and data folder +chown -R stakater /home/git2consul +exec su-exec stakater "$@" \ No newline at end of file