diff --git a/demo/countdash/README.md b/demo/countdash/README.md new file mode 100644 index 000000000..ac4769d92 --- /dev/null +++ b/demo/countdash/README.md @@ -0,0 +1,33 @@ +# countdash + +Nomad makes use of the [demo-consul-101](https://github.com/hashicorp/demo-consul-101) +education material throughout our examples for using Consul Connect. There are many +example jobs that launch tasks with [counting-service](https://github.com/hashicorp/demo-consul-101/tree/master/services/counting-service) +and [dashboard-service](https://github.com/hashicorp/demo-consul-101/tree/master/services/dashboard-service) +configured to communicate under various conditions. + +## Publishing + +When making changes to the `countdash` demo, open a PR against the [demo-consul-101](https://github.com/hashicorp/demo-consul-101) +project. Be sure to preserve backwards compatibility, as these demo files are used +extensively, including with other Consul integrations. + +The docker images specific to Nomad can be rebuilt using [counter-dashboard](counter-dashboard/Dockerfile) +and [counter-api](counter-api/Dockerfile). + +#### Testing locally +```bash +$ docker build -t hashicorpnomad/counter-api:test . +$ docker build -t hashicorpnomad/counter-dashboard:test . + +$ docker run --rm --net=host hashicorpnomad/counter-api:test +$ docker run --rm --net=host --env COUNTING_SERVICE_URL="http://localhost:9001" hashicorpnomad/counter-dashboard:test +``` + +#### Upload to Docker Hub +```bash +# replace with the next version number +docker login +docker build -t hashicorpnomad/counter-dashboard: . +docker push hashicorpnomad/counter-dashboard: +``` diff --git a/demo/countdash/counter-api/Dockerfile b/demo/countdash/counter-api/Dockerfile new file mode 100644 index 000000000..786ecfb5b --- /dev/null +++ b/demo/countdash/counter-api/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:alpine as builder +WORKDIR /build +ADD ./Dockerfile /build + +RUN apk add git && \ + git clone -b 0.0.3 https://github.com/hashicorp/demo-consul-101.git + +WORKDIR /build/demo-consul-101/services/counting-service +ADD ./go.mod . + +RUN go version && \ + go env && \ + go generate && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build + +FROM alpine:latest +MAINTAINER nomadproject.io + +WORKDIR /opt +COPY --from=builder /build/demo-consul-101/services/counting-service/counter-api /opt + +EXPOSE 9001 +ENV PORT 9001 + +ENTRYPOINT ["/opt/counter-api"] diff --git a/demo/countdash/counter-api/go.mod b/demo/countdash/counter-api/go.mod new file mode 100644 index 000000000..3dc459810 --- /dev/null +++ b/demo/countdash/counter-api/go.mod @@ -0,0 +1 @@ +module nomadproject.io/demo/counter-api diff --git a/demo/countdash/counter-dashboard/Dockerfile b/demo/countdash/counter-dashboard/Dockerfile new file mode 100644 index 000000000..6d4a21ab5 --- /dev/null +++ b/demo/countdash/counter-dashboard/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:alpine as builder +WORKDIR /build +ADD ./Dockerfile /build + +RUN apk add git && \ + git clone -b 0.0.3 https://github.com/hashicorp/demo-consul-101.git + +WORKDIR /build/demo-consul-101/services/dashboard-service +ADD ./go.mod . + +RUN go version && \ + go env && \ + go generate && \ + GO111MODULE=on go run github.com/GeertJohan/go.rice/rice embed-go && \ + GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build + +FROM alpine:latest +MAINTAINER nomadproject.io + +WORKDIR /opt +COPY --from=builder /build/demo-consul-101/services/dashboard-service/counter-dashboard /opt + +EXPOSE 9002 +ENV PORT 9002 + +ENTRYPOINT ["/opt/counter-dashboard"] diff --git a/demo/countdash/counter-dashboard/go.mod b/demo/countdash/counter-dashboard/go.mod new file mode 100644 index 000000000..c5a74cff2 --- /dev/null +++ b/demo/countdash/counter-dashboard/go.mod @@ -0,0 +1,5 @@ +module nomadproject.io/demo/counter-dashboard + +require ( + github.com/GeertJohan/go.rice v1.0.0 +) \ No newline at end of file