forked from cadence-workflow/cadence
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at dockerFile for cadence server (cadence-workflow#199)
- Loading branch information
1 parent
250f52f
commit b1f7b8b
Showing
14 changed files
with
396 additions
and
23 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
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,68 @@ | ||
# Copyright (c) 2017 Uber Technologies, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
FROM debian:jessie | ||
|
||
# get golang 1.8.1 | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
g++ \ | ||
gcc \ | ||
libc6-dev \ | ||
make \ | ||
pkg-config \ | ||
libev4 libev-dev \ | ||
gettext-base \ | ||
wget \ | ||
python-pip \ | ||
git-all \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pip install cqlsh | ||
|
||
ENV GOLANG_VERSION 1.8.2 | ||
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz | ||
ENV GOLANG_DOWNLOAD_SHA256 5477d6c9a4f96fa120847fafa88319d7b56b5d5068e41c3587eebe248b939be7 | ||
|
||
RUN set -eux; \ | ||
wget -O golang.tar.gz "$GOLANG_DOWNLOAD_URL" \ | ||
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ | ||
&& tar -C /usr/local -xzf golang.tar.gz \ | ||
&& rm golang.tar.gz | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
|
||
# get and compile cadence-server | ||
ENV CADENCE_HOME $GOPATH/src/github.com/uber/cadence | ||
|
||
RUN go get -u github.com/Masterminds/glide | ||
RUN go get -u github.com/golang/lint/golint | ||
RUN git clone --depth=50 https://github.com/uber/cadence.git $CADENCE_HOME | ||
RUN cd $CADENCE_HOME; make bins_nothrift | ||
|
||
EXPOSE 7933 7934 7935 | ||
|
||
COPY ./start.sh $CADENCE_HOME/start.sh | ||
COPY ./config_template.yaml $CADENCE_HOME/config/docker_template.yaml | ||
RUN chmod a+x $CADENCE_HOME/start.sh | ||
|
||
WORKDIR $CADENCE_HOME | ||
CMD ./start.sh $CADENCE_HOME |
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,54 @@ | ||
Quickstart | ||
========== | ||
|
||
Following steps will bring up the docker container running cadence server | ||
along with all its dependencies (cassandra, statsd, graphite). Exposes cadence | ||
frontend on port 7933 and grafana metrics frontend on port 8080. | ||
|
||
``` | ||
cd $GOPATH/src/github.com/uber/cadence/docker | ||
docker-compose up | ||
``` | ||
|
||
View metrics at localhost:8080/dashboard | ||
|
||
Building and running the image | ||
============================== | ||
|
||
Build | ||
----- | ||
``` | ||
cd $GOPATH/src/github.com/uber/cadence/docker | ||
docker-compose build | ||
``` | ||
|
||
Run with defaults | ||
----------------- | ||
``` | ||
docker-compose run cadence | ||
``` | ||
|
||
Run with all the config options | ||
------------------------------- | ||
``` | ||
docker-compose run -e CASSANDRA_CONSISTENCY=Quorum \ -- Default cassandra consistency level | ||
-e BIND_ON_LOCALHOST=false \ -- Don't use localhost ip address for cadence services | ||
-e RINGPOP_SEEDS=10.0.0.1 \ -- Use this as the gossip bootstrap hosts for ringpop | ||
-e NUM_HISTORY_SHARDS=1024 \ -- Number of history shards | ||
-e SERVICES=history,matching \ -- Spinup only the provided services | ||
cadence | ||
``` | ||
|
||
Running cadence without dependencies | ||
==================================== | ||
If you prefer to spin up your cassandra / statsd server, use the following | ||
to just bring up cadence server | ||
``` | ||
cd $GOPATH/src/github.com/uber/cadence/docker | ||
docker build -t uber/cadence:master . | ||
docker run uber/cadence | ||
-e CASSANDRA_CONSISTENCY=Quorum \ | ||
-e CASSANDRA_SEEDS=127.0.0.1 \ -- Cassandra server seed list | ||
-e RINGPOP_SEEDS=10.0.0.1 \ -- Use this as the gossip bootstrap hosts for ringpop | ||
-e NUM_HISTORY_SHARDS=1024 \ -- Number of history shards | ||
``` |
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,39 @@ | ||
cassandra: | ||
hosts: "${CASSANDRA_SEEDS}" | ||
keyspace: "${KEYSPACE}" | ||
consistency: "${CASSANDRA_CONSISTENCY}" | ||
numHistoryShards: ${NUM_HISTORY_SHARDS} | ||
|
||
ringpop: | ||
name: cadence | ||
bootstrapMode: hosts | ||
bootstrapHosts: ["${RINGPOP_SEEDS}"] | ||
maxJoinDuration: 30s | ||
|
||
services: | ||
frontend: | ||
tchannel: | ||
port: 7933 | ||
bindOnLocalHost: ${BIND_ON_LOCALHOST} | ||
metrics: | ||
statsd: | ||
hostPort: "${STATSD_ENDPOINT}" | ||
prefix: "cadence" | ||
|
||
matching: | ||
tchannel: | ||
port: 7935 | ||
bindOnLocalHost: ${BIND_ON_LOCALHOST} | ||
metrics: | ||
statsd: | ||
hostPort: "${STATSD_ENDPOINT}" | ||
prefix: "cadence" | ||
|
||
history: | ||
tchannel: | ||
port: 7934 | ||
bindOnLocalHost: ${BIND_ON_LOCALHOST} | ||
metrics: | ||
statsd: | ||
hostPort: "${STATSD_ENDPOINT}" | ||
prefix: "cadence" |
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,26 @@ | ||
version: '3' | ||
services: | ||
cassandra: | ||
image: cassandra:3.9 | ||
ports: | ||
- "9042:9042" | ||
statsd: | ||
image: hopsoft/graphite-statsd | ||
ports: | ||
- "8080:80" | ||
- "2003:2003" | ||
- "8125:8125" | ||
- "8126:8126" | ||
cadence: | ||
build: . | ||
image: uber/cadence:master | ||
ports: | ||
- "7933:7933" | ||
- "7934:7934" | ||
- "7935:7935" | ||
environment: | ||
- "CASSANDRA_SEEDS=cassandra" | ||
- "STATSD_ENDPOINT=statsd:8125" | ||
depends_on: | ||
- cassandra | ||
- statsd |
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,85 @@ | ||
#!/bin/bash -x | ||
|
||
# Copyright (c) 2017 Uber Technologies, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
setup_schema() { | ||
SCHEMA_FILE=$CADENCE_HOME/schema/cadence/schema.cql | ||
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS create -k $KEYSPACE --rf $RF | ||
$CADENCE_HOME/cadence-cassandra-tool --ep $CASSANDRA_SEEDS -k $KEYSPACE setup-schema -d -f $SCHEMA_FILE | ||
} | ||
|
||
wait_for_cassandra() { | ||
server=`echo $CASSANDRA_SEEDS | awk -F ',' '{print $1}'` | ||
until cqlsh --cqlversion=3.4.2 $server < /dev/null; do | ||
echo 'waiting for cassandra to start up' | ||
sleep 1 | ||
done | ||
echo 'cassandra started' | ||
} | ||
|
||
init_env() { | ||
|
||
export HOST_IP="127.0.0.1" # default to localhost binding | ||
|
||
if [ "$BIND_ON_LOCALHOST" == false ]; then | ||
export HOST_IP=`hostname --ip-address` | ||
else | ||
export BIND_ON_LOCALHOST=true | ||
fi | ||
|
||
if [ -z "$KEYSPACE" ]; then | ||
export KEYSPACE="cadence" | ||
fi | ||
|
||
if [ -z "$CASSANDRA_SEEDS" ]; then | ||
export CASSANDRA_SEEDS=$HOST_IP | ||
fi | ||
|
||
if [ -z "$CASSANDRA_CONSISTENCY" ]; then | ||
export CASSANDRA_CONSISTENCY="One" | ||
fi | ||
|
||
if [ -z "$RINGPOP_SEEDS" ]; then | ||
export RINGPOP_SEEDS=$HOST_IP:7933,$HOST_IP:7934,$HOST_IP:7935 | ||
fi | ||
|
||
if [ -z "$NUM_HISTORY_SHARDS" ]; then | ||
export NUM_HISTORY_SHARDS=4 | ||
fi | ||
} | ||
|
||
CADENCE_HOME=$1 | ||
|
||
if [ -z "$RF" ]; then | ||
RF=1 | ||
fi | ||
|
||
if [ -z "$SERVICES" ]; then | ||
SERVICES="history,matching,frontend" | ||
fi | ||
|
||
init_env | ||
wait_for_cassandra | ||
setup_schema | ||
|
||
# fix up config | ||
envsubst < config/docker_template.yaml > config/docker.yaml | ||
./cadence --root $CADENCE_HOME --env docker start --services=$SERVICES |
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
Oops, something went wrong.