-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
3,267 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM rnburn/nginx-opentracing | ||
|
||
WORKDIR /app | ||
ADD . /app | ||
RUN set -x \ | ||
# new directory for storing sources and .deb files | ||
&& tempDir="$(mktemp -d)" \ | ||
&& chmod 777 "$tempDir" \ | ||
\ | ||
# save list of currently-installed packages so build dependencies can be cleanly removed later | ||
&& savedAptMark="$(apt-mark showmanual)" \ | ||
\ | ||
# set up go | ||
&& apt-get update \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y \ | ||
git \ | ||
ca-certificates \ | ||
software-properties-common \ | ||
wget \ | ||
curl \ | ||
&& wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz \ | ||
&& tar -xvf go1.8.3.linux-amd64.tar.gz \ | ||
&& mv go $tempDir \ | ||
&& export GOROOT=$tempDir/go \ | ||
&& export GOPATH=$tempDir/gopath \ | ||
&& mkdir -p $GOPATH/bin \ | ||
&& export PATH=$GOPATH/bin:$GOROOT/bin:$PATH \ | ||
# install glide | ||
&& curl https://glide.sh/get | sh \ | ||
# build the hotrod demo | ||
&& mkdir -p $GOPATH/src/github.com/rnburn/ \ | ||
&& mv /app/hotrod $GOPATH/src/github.com/rnburn/hotrod-docker \ | ||
&& cd $GOPATH/src/github.com/rnburn/hotrod-docker \ | ||
&& glide install \ | ||
&& go build -o hotrod \ | ||
&& mv hotrod /app/hotrod \ | ||
&& mkdir -p /app/services/frontend/web_assets \ | ||
&& cp services/frontend/web_assets/index.html /app/services/frontend/web_assets/index.html \ | ||
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies | ||
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) | ||
&& apt-mark showmanual | xargs apt-mark auto > /dev/null \ | ||
&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ | ||
\ | ||
# purge leftovers from building them (including extra, unnecessary build deps) | ||
&& apt-get purge -y --auto-remove \ | ||
&& rm -rf "$tempDir" | ||
|
||
EXPOSE 8080 | ||
|
||
STOPSIGNAL SIGTERM | ||
|
||
CMD ["/app/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
An OpenTracing example demonstrating usage of the nginx-opentracing docker | ||
image with jaeger. It builds on Jaeger's HotROD example (see blog post | ||
[Take OpenTracing for a HotROD ride](https://medium.com/opentracing/take-opentracing-for-a-hotrod-ride-f6e3141f7941)), | ||
but inserts nginx as a load balancer for the HotROD services. | ||
|
||
Use these commands to run: | ||
```bash | ||
docker build -t nginx-example-hotrod . | ||
docker run -d -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \ | ||
-p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 --name jaeger jaegertracing/all-in-one:latest | ||
docker run -d -p 8080:80 --link jaeger:jaeger nginx-example-hotrod | ||
``` | ||
Visit http://localhost:8080 to interact with the demo and http://localhost:16686 | ||
to view the traces in Jaeger. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import "github.com/spf13/cobra" | ||
|
||
// allCmd represents the all command | ||
var allCmd = &cobra.Command{ | ||
Use: "all", | ||
Short: "Starts all services", | ||
Long: `Starts all services.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
logger.Info("Starting all services") | ||
go customerCmd.RunE(customerCmd, args) | ||
go driverCmd.RunE(driverCmd, args) | ||
go routeCmd.RunE(routeCmd, args) | ||
frontendCmd.RunE(frontendCmd, args) | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(allCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"net" | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
|
||
"github.com/rnburn/hotrod-docker/pkg/log" | ||
"github.com/rnburn/hotrod-docker/pkg/tracing" | ||
"github.com/rnburn/hotrod-docker/services/customer" | ||
) | ||
|
||
// customerCmd represents the customer command | ||
var customerCmd = &cobra.Command{ | ||
Use: "customer", | ||
Short: "Starts Customer service", | ||
Long: `Starts Customer service.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
logger := log.NewFactory(logger.With(zap.String("service", "customer"))) | ||
server := customer.NewServer( | ||
net.JoinHostPort(customerOptions.serverInterface, strconv.Itoa(customerOptions.serverPort)), | ||
tracing.Init("customer", metricsFactory.Namespace("customer", nil), logger), | ||
metricsFactory, | ||
logger, | ||
) | ||
return server.Run() | ||
}, | ||
} | ||
|
||
var ( | ||
customerOptions struct { | ||
serverInterface string | ||
serverPort int | ||
} | ||
) | ||
|
||
func init() { | ||
RootCmd.AddCommand(customerCmd) | ||
|
||
customerCmd.Flags().StringVarP(&customerOptions.serverInterface, "bind", "", "127.0.0.1", "interface to which the Customer server will bind") | ||
customerCmd.Flags().IntVarP(&customerOptions.serverPort, "port", "p", 8081, "port on which the Customer server will listen") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"net" | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
|
||
"github.com/rnburn/hotrod-docker/pkg/log" | ||
"github.com/rnburn/hotrod-docker/pkg/tracing" | ||
"github.com/rnburn/hotrod-docker/services/driver" | ||
) | ||
|
||
// driverCmd represents the driver command | ||
var driverCmd = &cobra.Command{ | ||
Use: "driver", | ||
Short: "Starts Driver service", | ||
Long: `Starts Driver service.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
logger := log.NewFactory(logger.With(zap.String("service", "driver"))) | ||
server := driver.NewServer( | ||
net.JoinHostPort(driverOptions.serverInterface, strconv.Itoa(driverOptions.serverPort)), | ||
tracing.Init("driver", metricsFactory.Namespace("driver", nil), logger), | ||
metricsFactory, | ||
logger, | ||
) | ||
return server.Run() | ||
}, | ||
} | ||
|
||
var ( | ||
driverOptions struct { | ||
serverInterface string | ||
serverPort int | ||
} | ||
) | ||
|
||
func init() { | ||
RootCmd.AddCommand(driverCmd) | ||
|
||
driverCmd.Flags().StringVarP(&driverOptions.serverInterface, "bind", "", "127.0.0.1", "interface to which the driver server will bind") | ||
driverCmd.Flags().IntVarP(&driverOptions.serverPort, "port", "p", 8082, "port on which the driver server will listen") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) 2017 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"net" | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
|
||
"github.com/rnburn/hotrod-docker/pkg/log" | ||
"github.com/rnburn/hotrod-docker/pkg/tracing" | ||
"github.com/rnburn/hotrod-docker/services/frontend" | ||
) | ||
|
||
// frontendCmd represents the frontend command | ||
var frontendCmd = &cobra.Command{ | ||
Use: "frontend", | ||
Short: "Starts Frontend service", | ||
Long: `Starts Frontend service.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
logger := log.NewFactory(logger.With(zap.String("service", "frontend"))) | ||
server := frontend.NewServer( | ||
net.JoinHostPort(frontendOptions.serverInterface, strconv.Itoa(frontendOptions.serverPort)), | ||
tracing.Init("frontend", metricsFactory.Namespace("frontend", nil), logger), | ||
logger, | ||
) | ||
return server.Run() | ||
}, | ||
} | ||
|
||
var ( | ||
frontendOptions struct { | ||
serverInterface string | ||
serverPort int | ||
} | ||
) | ||
|
||
func init() { | ||
RootCmd.AddCommand(frontendCmd) | ||
|
||
frontendCmd.Flags().StringVarP(&frontendOptions.serverInterface, "bind", "", "", "interface to which the frontend server will bind") | ||
frontendCmd.Flags().IntVarP(&frontendOptions.serverPort, "port", "p", 8080, "port on which the frontend server will listen") | ||
} |
Oops, something went wrong.