diff --git a/GNUmakefile b/GNUmakefile index a822e0246..9f32667f1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -59,6 +59,10 @@ vet: echo "and fix them if necessary before submitting the code for reviewal."; \ fi +# build the static web ui +ui: + @sh -c "'$(CURDIR)/scripts/ui.sh'" + # generates the static web ui that's compiled into the binary static-assets: @echo "--> Generating static assets" @@ -69,4 +73,4 @@ static-assets: tools: go get -u -v $(GOTOOLS) -.PHONY: all ci bin dev dist cov test cover format vet static-assets tools +.PHONY: all ci bin dev dist cov test cover format vet ui static-assets tools diff --git a/scripts/consul-builder/Dockerfile b/scripts/consul-builder/Dockerfile index da267c010..3c6b90c2b 100644 --- a/scripts/consul-builder/Dockerfile +++ b/scripts/consul-builder/Dockerfile @@ -27,4 +27,3 @@ ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH RUN mkdir -p $GOPATH/src/github.com/hashicorp/consul WORKDIR $GOPATH/src/github.com/hashicorp/consul -CMD ./scripts/dist_build.sh diff --git a/scripts/dist.sh b/scripts/dist.sh index 282a029d7..da5d5e21f 100755 --- a/scripts/dist.sh +++ b/scripts/dist.sh @@ -28,7 +28,7 @@ fi # Do a hermetic build inside a Docker container. if [ -z $NOBUILD ]; then docker build -t hashicorp/consul-builder scripts/consul-builder/ - docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/consul hashicorp/consul-builder + docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/consul hashicorp/consul-builder ./scripts/dist_build.sh fi # Zip all the files. diff --git a/scripts/ui.sh b/scripts/ui.sh new file mode 100755 index 000000000..321ed6c1e --- /dev/null +++ b/scripts/ui.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +# Get the parent directory of where this script is. +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" + +# Change into that dir because we expect that. +cd $DIR + +# Do a hermetic build inside a Docker container. +if [ -z $NOBUILD ]; then + docker build -t hashicorp/consul-builder scripts/consul-builder/ + docker run --rm -v "$(pwd)":/gopath/src/github.com/hashicorp/consul hashicorp/consul-builder ./scripts/ui_build.sh +fi + +exit 0 diff --git a/scripts/ui_build.sh b/scripts/ui_build.sh new file mode 100755 index 000000000..ab9a15d13 --- /dev/null +++ b/scripts/ui_build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +# Get the parent directory of where this script is. +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done +DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" + +# Change into that dir because we expect that. +cd $DIR + +# Build the web assets. +pushd ui +bundle +make dist +popd + +exit 0