Skip to content

Commit 30d3e18

Browse files
authored
Publish hotrod image to docker hub (#702)
* Publish hotrod to dockerub Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Fix review comments Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Add env to dockerfile to handle collector hostport Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Use alpine Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Use scratch and entrypoint hotrod all Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Remove cd - Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Fix cd Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Add ls Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Remove bindata.go Signed-off-by: Pavol Loffay <ploffay@redhat.com> * Add wait until 200 Signed-off-by: Pavol Loffay <ploffay@redhat.com>
1 parent ff666cd commit 30d3e18

File tree

11 files changed

+320
-18
lines changed

11 files changed

+320
-18
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ matrix:
2323
- go: 1.9
2424
env:
2525
- ES_INTEGRATION_TEST=true
26+
- go: 1.9
27+
env:
28+
- HOTROD=true
2629

2730
services:
2831
- docker
@@ -50,6 +53,7 @@ script:
5053
- if [ "$CROSSDOCK" == true ]; then bash ./scripts/travis/build-crossdock.sh ; else echo 'skipping crossdock'; fi
5154
- if [ "$DOCKER" == true ]; then bash ./scripts/travis/build-docker-images.sh ; else echo 'skipping docker images'; fi
5255
- if [ "$ES_INTEGRATION_TEST" == true ]; then bash ./scripts/travis/es-integration-test.sh ; else echo 'skipping elastic search integration test'; fi
56+
- if [ "$HOTROD" == true ]; then bash ./scripts/travis/hotrod-integration-test.sh ; else echo 'skipping hotrod example'; fi
5357

5458
after_success:
5559
- if [ "$COVERAGE" == true ]; then travis_retry goveralls -coverprofile=cover.out -service=travis-ci || true ; else echo 'skipping coverage'; fi

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,20 @@ install-glide:
122122
install: install-glide
123123
glide install
124124

125+
.PHONY: install-go-bindata
126+
install-go-bindata:
127+
go get github.com/jteeuwen/go-bindata/...
128+
go get github.com/elazarl/go-bindata-assetfs/...
129+
125130
.PHONY: build-examples
126-
build-examples:
127-
go build -o ./examples/hotrod/hotrod-demo ./examples/hotrod/main.go
131+
build-examples: install-go-bindata
132+
(cd ./examples/hotrod/services/frontend/ && go-bindata-assetfs -pkg frontend web_assets/...)
133+
rm ./examples/hotrod/services/frontend/bindata.go
134+
CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./examples/hotrod/hotrod-linux ./examples/hotrod/main.go
135+
136+
.PHONE: docker-hotrod
137+
docker-hotrod: build-examples
138+
docker build -t $(DOCKER_NAMESPACE)/example-hotrod:${DOCKER_TAG} ./examples/hotrod
128139

129140
.PHONY: build_ui
130141
build_ui:
@@ -177,7 +188,7 @@ docker-push:
177188
if [ $$CONFIRM != "y" ] && [ $$CONFIRM != "Y" ]; then \
178189
echo "Exiting." ; exit 1 ; \
179190
fi
180-
for component in agent cassandra-schema collector query ; do \
191+
for component in agent cassandra-schema collector query example-hotrod; do \
181192
docker push $(DOCKER_NAMESPACE)/jaeger-$$component ; \
182193
done
183194

examples/hotrod/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
hotrod-demo
1+
hotrod-linux

examples/hotrod/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
FROM scratch
22
EXPOSE 8080 8081 8082 8083
3-
COPY hotrod-linux /
4-
CMD ["./hotrod-linux", "all"]
3+
COPY hotrod-linux /go/bin/
4+
ENTRYPOINT ["/go/bin/hotrod-linux", "all"]

examples/hotrod/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,27 @@ to view the traces. A tutorial / walkthough is available:
2323

2424
An all-in-one Jaeger backend is packaged as a Docker container with in-memory storage.
2525

26-
```
27-
docker run -d -p6831:6831/udp -p16686:16686 jaegertracing/all-in-one:latest
26+
```bash
27+
docker run -d --name jaeger -p6831:6831/udp -p16686:16686 jaegertracing/all-in-one:latest
2828
```
2929

3030
Jaeger UI can be accessed at http://localhost:16686.
3131

32-
### Run HotROD Application
32+
### Run HotROD from source
3333

34-
```
34+
```bash
3535
go get github.com/jaegertracing/jaeger
3636
cd $GOPATH/src/github.com/jaegertracing/jaeger
3737
make install
3838
cd examples/hotrod
3939
go run ./main.go all
4040
```
4141

42+
### Run HotROD from docker
43+
```bash
44+
docker run --rm -it --link jaeger -p8080-8083:8080-8083 jaegertracing/example-hotrod:latest --jaeger-agent.host-port=jaeger:6831
45+
```
46+
4247
Then open http://127.0.0.1:8080
4348

4449

examples/hotrod/create-image.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/hotrod/services/frontend/bindata_assetfs.go

Lines changed: 248 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/hotrod/services/frontend/server.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/opentracing/opentracing-go"
2222
"go.uber.org/zap"
23+
"github.com/elazarl/go-bindata-assetfs"
2324

2425
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/httperr"
2526
"github.com/jaegertracing/jaeger/examples/hotrod/pkg/log"
@@ -32,6 +33,7 @@ type Server struct {
3233
tracer opentracing.Tracer
3334
logger log.Factory
3435
bestETA *bestETA
36+
assetFs *assetfs.AssetFS
3537
}
3638

3739
// NewServer creates a new frontend.Server
@@ -41,6 +43,7 @@ func NewServer(hostPort string, tracer opentracing.Tracer, logger log.Factory) *
4143
tracer: tracer,
4244
logger: logger,
4345
bestETA: newBestETA(tracer, logger),
46+
assetFs: assetFS(),
4447
}
4548
}
4649

@@ -60,7 +63,12 @@ func (s *Server) createServeMux() http.Handler {
6063

6164
func (s *Server) home(w http.ResponseWriter, r *http.Request) {
6265
s.logger.For(r.Context()).Info("HTTP", zap.String("method", r.Method), zap.Stringer("url", r.URL))
63-
http.ServeFile(w, r, "services/frontend/web_assets/index.html")
66+
b, err := s.assetFs.Asset("web_assets/index.html")
67+
if err != nil {
68+
http.Error(w, "Could not load index page", http.StatusInternalServerError)
69+
s.logger.Bg().Error("Could lot load static assets", zap.Error(err))
70+
}
71+
w.Write(b)
6472
}
6573

6674
func (s *Server) dispatch(w http.ResponseWriter, r *http.Request) {

scripts/import-order-cleanup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -e
44

5-
python scripts/import-order-cleanup.py -o $1 -t $(git ls-files "*\.go" | grep -v -e thrift-gen -e swagger-gen -e thrift-0.9.2)
5+
python scripts/import-order-cleanup.py -o $1 -t $(git ls-files "*\.go" | grep -v -e thrift-gen -e swagger-gen -e thrift-0.9.2 -e bindata_assetfs.go)

0 commit comments

Comments
 (0)