FROM alpine
MAINTAINER Pure Storage version: 0.1

ENV CONSUL_TEMPLATE_VERSION=0.12.2
ENV CONSUL_URL=https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip

# Updata wget to get support for SSL
RUN apk --update add haproxy wget

# Download consul-template
RUN ( wget --no-check-certificate ${CONSUL_URL} -O /tmp/consul_template.zip && \
      unzip -d /tmp/ -o /tmp/consul_template.zip && \
      mv /tmp/consul-template /usr/bin && \
      rm -rf /tmp/* )

COPY *.http /etc/haproxy/errors/

COPY haproxy.ctmpl.cfg /tmp/
COPY haproxy.ctmpl /tmp/

CMD ["consul-template", "-config=/tmp/haproxy.ctmpl.cfg", "-log-level=debug"]
