diff --git a/0.7/consul-agent/Dockerfile b/0.7/consul-agent/Dockerfile new file mode 100644 index 0000000..29f6891 --- /dev/null +++ b/0.7/consul-agent/Dockerfile @@ -0,0 +1,6 @@ +FROM gliderlabs/consul:0.7 +ADD ./config /config/ +EXPOSE 8300 8301 8301/udp 8302 8302/udp 8400 8500 8600 8600/udp +ENV DNS_RESOLVES consul +ENV DNS_PORT 8600 +ENTRYPOINT ["/bin/consul", "agent", "-config-dir=/config"] diff --git a/0.7/consul-agent/Makefile b/0.7/consul-agent/Makefile new file mode 100644 index 0000000..ceaa6fd --- /dev/null +++ b/0.7/consul-agent/Makefile @@ -0,0 +1,3 @@ + +build: + docker build -t gliderlabs/consul-agent:$(VERSION) . diff --git a/0.7/consul-agent/config/agent.json b/0.7/consul-agent/config/agent.json new file mode 100644 index 0000000..529b602 --- /dev/null +++ b/0.7/consul-agent/config/agent.json @@ -0,0 +1,9 @@ +{ + "client_addr": "0.0.0.0", + "data_dir": "/data", + "leave_on_terminate": true, + "dns_config": { + "allow_stale": true, + "max_stale": "1s" + } +} diff --git a/0.7/consul-server/Dockerfile b/0.7/consul-server/Dockerfile new file mode 100644 index 0000000..174ce33 --- /dev/null +++ b/0.7/consul-server/Dockerfile @@ -0,0 +1,3 @@ +FROM gliderlabs/consul-agent:0.7 +ADD ./config /config/ +ENTRYPOINT ["/bin/consul", "agent", "-server", "-config-dir=/config"] diff --git a/0.7/consul-server/Makefile b/0.7/consul-server/Makefile new file mode 100644 index 0000000..b853017 --- /dev/null +++ b/0.7/consul-server/Makefile @@ -0,0 +1,3 @@ + +build: + docker build -t gliderlabs/consul-server:$(VERSION) . diff --git a/0.7/consul-server/config/server.json b/0.7/consul-server/config/server.json new file mode 100644 index 0000000..9132902 --- /dev/null +++ b/0.7/consul-server/config/server.json @@ -0,0 +1,6 @@ +{ + "ui": true, + "dns_config": { + "allow_stale": false + } +} diff --git a/0.7/consul/Dockerfile b/0.7/consul/Dockerfile new file mode 100644 index 0000000..566d58b --- /dev/null +++ b/0.7/consul/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.4 + +ENV CONSUL_VERSION 0.7.0 +ENV CONSUL_SHA256 b350591af10d7d23514ebaa0565638539900cdb3aaa048f077217c4c46653dd8 + +RUN apk --no-cache add curl ca-certificates \ + && curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -o /tmp/consul.zip \ + && echo "${CONSUL_SHA256} /tmp/consul.zip" > /tmp/consul.sha256 \ + && sha256sum -c /tmp/consul.sha256 \ + && cd /bin \ + && unzip /tmp/consul.zip \ + && chmod +x /bin/consul \ + && rm /tmp/consul.zip + +ENTRYPOINT ["/bin/consul"] diff --git a/0.7/consul/Makefile b/0.7/consul/Makefile new file mode 100644 index 0000000..33d1bdd --- /dev/null +++ b/0.7/consul/Makefile @@ -0,0 +1,3 @@ + +build: + docker build -t gliderlabs/consul:$(VERSION) . diff --git a/0.7/consul/update_version.sh b/0.7/consul/update_version.sh new file mode 100755 index 0000000..cdd8b6b --- /dev/null +++ b/0.7/consul/update_version.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -eo pipefail +[[ "$TRACE" ]] && set -x || : + +debug() { + [[ "$DEBUG" ]] && echo "-----> $*" 1>&2 +} + +consul_version() { + sed -n "s/ENV CONSUL_VERSION //p" Dockerfile +} + +next_version() { + debug "new version will be calculated ..." + local oldVersion=$(consul_version) + debug "oldVersion: $oldVersion" + echo ${oldVersion%.*}.$((${oldVersion##*.} + 1)) +} + +update_dockerfile() { + declare ver=${1:? required} + + local sha=$(curl -Ls https://releases.hashicorp.com/consul/${ver}/consul_${ver}_SHA256SUMS | sed -n "s/ .*linux_amd64.*//p") + debug "sha=$sha" + + sed -i "s/\(ENV CONSUL_VERSION\) .*/\1 $newVersion/;s/\(ENV CONSUL_SHA256\) .*/\1 $sha/" Dockerfile +} + +main() { + declare desc="Updates Dockerfile url/sha for the provided version, or calculates next patch version if called without params" + declare newVersion=${1:-$(next_version)} + + debug "newVersion=$newVersion" + update_dockerfile $newVersion + git diff + echo "=====> Now you can run: git commit -am 'Upgrade Consul to $newVersion'" +} + +[[ "$0" == "$BASH_SOURCE" ]] && main "$@" || : diff --git a/Makefile b/Makefile index b1f5473..3be5b1b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.6 +VERSION=0.7 build: VERSION=$(VERSION) make -C $(VERSION)/consul