mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Merge pull request #7781 from hashicorp/demo-countdash-docker
demo: create build scripts for our countdash demo
This commit is contained in:
33
demo/countdash/README.md
Normal file
33
demo/countdash/README.md
Normal file
@@ -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 <version> with the next version number
|
||||
docker login
|
||||
docker build -t hashicorpnomad/counter-dashboard:<version> .
|
||||
docker push hashicorpnomad/counter-dashboard:<version>
|
||||
```
|
||||
25
demo/countdash/counter-api/Dockerfile
Normal file
25
demo/countdash/counter-api/Dockerfile
Normal file
@@ -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"]
|
||||
1
demo/countdash/counter-api/go.mod
Normal file
1
demo/countdash/counter-api/go.mod
Normal file
@@ -0,0 +1 @@
|
||||
module nomadproject.io/demo/counter-api
|
||||
26
demo/countdash/counter-dashboard/Dockerfile
Normal file
26
demo/countdash/counter-dashboard/Dockerfile
Normal file
@@ -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"]
|
||||
5
demo/countdash/counter-dashboard/go.mod
Normal file
5
demo/countdash/counter-dashboard/go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module nomadproject.io/demo/counter-dashboard
|
||||
|
||||
require (
|
||||
github.com/GeertJohan/go.rice v1.0.0
|
||||
)
|
||||
Reference in New Issue
Block a user