Skip to content

Commit

Permalink
Parameterize docker-test and make var names unambiguous.
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed May 16, 2018
1 parent 9db85e3 commit 80ffa49
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
15 changes: 9 additions & 6 deletions Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
FROM ubuntu
COPY consul_1.0.6_linux_amd64.zip /tmp
COPY vault_0.9.6_linux_amd64.zip /tmp
COPY go1.10.2.linux-amd64.tar.gz /tmp
RUN apt-get update && apt-get -y install unzip make git-core
RUN unzip /tmp/consul*.zip -d /usr/local/bin
RUN unzip /tmp/vault*.zip -d /usr/local/bin
RUN tar -C /usr/local -x -f /tmp/go*.tar.gz
ARG consul_version
ARG vault_version
ARG go_version
COPY consul_${consul_version}_linux_amd64.zip /tmp
COPY vault_${vault_version}_linux_amd64.zip /tmp
COPY go${go_version}.linux-amd64.tar.gz /tmp
RUN unzip /tmp/consul_${consul_version}_linux_amd64.zip -d /usr/local/bin
RUN unzip /tmp/vault_${vault_version}_linux_amd64.zip -d /usr/local/bin
RUN tar -C /usr/local -x -f /tmp/go${go_version}.linux-amd64.tar.gz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
WORKDIR /root/go/src/github.com/fabiolb/fabio
COPY . .
Expand Down
36 changes: 26 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ GOVENDOR = $(shell which govendor)
# VENDORFMT is the path to the vendorfmt binary.
VENDORFMT = $(shell which vendorfmt)

CONSUL_VERSION=1.0.6
VAULT_VERSION=0.9.6
GO_VERSION=1.10.2
# pin versions for CI builds
CI_CONSUL_VERSION=1.0.6
CI_VAULT_VERSION=0.9.6
CI_GO_VERSION=1.10.2

# all is the default target
all: test
Expand Down Expand Up @@ -115,19 +116,34 @@ docker-aliases:
docker push magiconair/fabio:$(VERSION)-$(GOVERSION)
docker push magiconair/fabio:latest

# docker-test runs make test in a Docker container with
# pinned versions of the external dependencies
#
# We download the binaries outside the Docker build to
# cache the binaries and prevent repeated downloads since
# ADD <url> downloads the file every time.
docker-test:
test -r consul_$(CONSUL_VERSION)_linux_amd64.zip || wget https://releases.hashicorp.com/consul/$(CONSUL_VERSION)/consul_$(CONSUL_VERSION)_linux_amd64.zip
test -r vault_$(VAULT_VERSION)_linux_amd64.zip || wget https://releases.hashicorp.com/vault/$(VAULT_VERSION)/vault_$(VAULT_VERSION)_linux_amd64.zip unzip -o -d ~/bin ~/consul.zip
test -r go$(GO_VERSION).linux-amd64.tar.gz || wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz
docker build -t test-fabio -f Dockerfile-test .
docker run -it test-fabio
test -r consul_$(CI_CONSUL_VERSION)_linux_amd64.zip || \
wget https://releases.hashicorp.com/consul/$(CI_CONSUL_VERSION)/consul_$(CI_CONSUL_VERSION)_linux_amd64.zip
test -r vault_$(CI_VAULT_VERSION)_linux_amd64.zip || \
wget https://releases.hashicorp.com/vault/$(CI_VAULT_VERSION)/vault_$(CI_VAULT_VERSION)_linux_amd64.zip
test -r go$(CI_GO_VERSION).linux-amd64.tar.gz || \
wget https://dl.google.com/go/go$(CI_GO_VERSION).linux-amd64.tar.gz
docker build \
--build-arg consul_version=$(CI_CONSUL_VERSION) \
--build-arg vault_version=$(CI_VAULT_VERSION) \
--build-arg go_version=$(CI_GO_VERSION) \
-t test-fabio \
-f Dockerfile-test \
.
docker run -it test-fabio make test

# codeship runs the CI on codeship
codeship:
go version
go env
wget -O ~/consul.zip https://releases.hashicorp.com/consul/$(CONSUL_VERSION)/consul_$(CONSUL_VERSION)_linux_amd64.zip
wget -O ~/vault.zip https://releases.hashicorp.com/vault/$(VAULT_VERSION)/vault_$(VAULT_VERSION)_linux_amd64.zip
wget -O ~/consul.zip https://releases.hashicorp.com/consul/$(CI_CONSUL_VERSION)/consul_$(CI_CONSUL_VERSION)_linux_amd64.zip
wget -O ~/vault.zip https://releases.hashicorp.com/vault/$(CI_VAULT_VERSION)/vault_$(CI_VAULT_VERSION)_linux_amd64.zip
unzip -o -d ~/bin ~/consul.zip
unzip -o -d ~/bin ~/vault.zip
vault --version
Expand Down

0 comments on commit 80ffa49

Please sign in to comment.