Skip to content

Commit

Permalink
Fix and update docker (uber#368)
Browse files Browse the repository at this point in the history
* Add param to Dockerfile for build_tag; fix issue about RINGPOP_SEEDS; use Cassandra 3.11; fix Readme for docker; add debug tools/log

* Venkat's comments
  • Loading branch information
longquanzheng authored Oct 9, 2017
1 parent 90b11d9 commit 73ffdeb
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
12 changes: 10 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

FROM debian:jessie

# Specify the cadence version to be built into this docker image
# See https://github.com/uber/cadence/tags
ARG git_branch
RUN if [ -z "$git_branch" ]; then echo "ERROR: git_branch NOT SET. Usage: docker build . --build-arg git_branch=YOUR_CHECKOUT_BRANCH"; exit 1; else : ; fi

# get golang 1.8.1
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
Expand All @@ -30,6 +35,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libev4 libev-dev \
gettext-base \
wget \
vim \
tcpdump \
netcat \
python-pip \
git-all \
&& rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -57,7 +65,7 @@ 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
RUN cd $CADENCE_HOME; git checkout $git_branch; make bins_nothrift

EXPOSE 7933 7934 7935

Expand All @@ -66,4 +74,4 @@ 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
CMD ./start.sh $CADENCE_HOME
20 changes: 14 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,29 @@ Using a pre-built image
-----------------------
With every tagged release of the cadence server, there is also a corresponding
docker image that's uploaded to docker hub. In addition, the release will also
contain a docker.tar.gz file (docker-compose startup scripts). Execute the following
contain a **docker.tar.gz** file (docker-compose startup scripts).
Go [here](https://github.com/uber/cadence/releases/latest) to download a latest **docker.tar.gz**

Execute the following
commands to start a pre-built image along with all dependencies (cassandra/statsd).

```
wget https://github.com/uber/cadence/releases/download/v0.1.0-beta/docker.tar.gz
tar -xzvf docker.tar.gz
cd docker
docker-compose up
```

Updating an existing image and restarting
Building an image for any branch and restarting
-----------------------------------------
Replace **YOUR_TAG** and **YOUR_CHECKOUT_BRANCH** in the below command to build:
```
cd $GOPATH/src/github.com/uber/cadence/docker
docker-compose stop
docker-compose build
docker build . -t ubercadence/server:YOUR_TAG --build-arg git_branch=YOUR_CHECKOUT_BRANCH
```
Replace the tag of **image: ubercadence/server** to **YOUR_TAG** in docker-compose.yml .
Then stop service and remove all containers using the below commands.
```
docker-compose down
docker-compose up
```

Expand All @@ -51,9 +58,10 @@ docker run -e CASSANDRA_CONSISTENCY=Quorum \ -- Default cassandra con
-e KEYSPACE=<keyspace> -- Cassandra keyspace
-e VISIBILITY_KEYSPACE=<visibility_keyspace> -- Cassandra visibility keyspace
-e SKIP_SCHEMA_SETUP=true -- do not setup cassandra schema during startup
-e RINGPOP_SEEDS=10.x.x.x \ -- csv of ipaddrs for gossip bootstrap
-e RINGPOP_SEEDS=10.x.x.x,10.x.x.x \ -- csv of ipaddrs for gossip bootstrap
-e STATSD_ENDPOINT=10.x.x.x:8125 -- statsd server endpoint
-e NUM_HISTORY_SHARDS=1024 \ -- Number of history shards
-e SERVICES=history,matching \ -- Spinup only the provided services
-e LOG_LEVEL=debug,info \ -- Logging level
ubercadence/server:<tag>
```
6 changes: 5 additions & 1 deletion docker/config_template.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
log:
stdout: true
level: "${LOG_LEVEL}"

cassandra:
hosts: "${CASSANDRA_SEEDS}"
keyspace: "${KEYSPACE}"
Expand All @@ -8,7 +12,7 @@ cassandra:
ringpop:
name: cadence
bootstrapMode: hosts
bootstrapHosts: ["${RINGPOP_SEEDS}"]
bootstrapHosts: ${RINGPOP_SEEDS_JSON_ARRAY}
maxJoinDuration: 30s

services:
Expand Down
7 changes: 3 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
cassandra:
image: cassandra:3.9
image: cassandra:3.11
ports:
- "9042:9042"
statsd:
Expand All @@ -12,8 +12,7 @@ services:
- "8125:8125"
- "8126:8126"
cadence:
build: .
image: ubercadence/server:master
image: ubercadence/server:0.3.2
ports:
- "7933:7933"
- "7934:7934"
Expand All @@ -23,4 +22,4 @@ services:
- "STATSD_ENDPOINT=statsd:8125"
depends_on:
- cassandra
- statsd
- statsd
24 changes: 21 additions & 3 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,24 @@ setup_schema() {

wait_for_cassandra() {
server=`echo $CASSANDRA_SEEDS | awk -F ',' '{print $1}'`
until cqlsh --cqlversion=3.4.2 $server < /dev/null; do
until cqlsh --cqlversion=3.4.4 $server < /dev/null; do
echo 'waiting for cassandra to start up'
sleep 1
done
echo 'cassandra started'
}

json_array() {
echo -n '['
while [ $# -gt 0 ]; do
x=${1//\\/\\\\}
echo -n \"${x//\"/\\\"}\"
[ $# -gt 1 ] && echo -n ', '
shift
done
echo ']'
}

init_env() {

export HOST_IP=`hostname --ip-address`
Expand Down Expand Up @@ -65,12 +76,19 @@ init_env() {
fi

if [ -z "$RINGPOP_SEEDS" ]; then
export RINGPOP_SEEDS=$HOST_IP:7933
export RINGPOP_SEEDS_JSON_ARRAY="[\"$HOST_IP:7933\",\"$HOST_IP:7934\",\"$HOST_IP:7935\"]"
else
array=(${RINGPOP_SEEDS//,/ })
export RINGPOP_SEEDS_JSON_ARRAY=$(json_array "${array[@]}")
fi

if [ -z "$NUM_HISTORY_SHARDS" ]; then
export NUM_HISTORY_SHARDS=4
fi

if [ -z "$LOG_LEVEL" ]; then
export LOG_LEVEL="debug"
fi
}

CADENCE_HOME=$1
Expand All @@ -92,4 +110,4 @@ fi

# fix up config
envsubst < config/docker_template.yaml > config/docker.yaml
./cadence --root $CADENCE_HOME --env docker start --services=$SERVICES
./cadence --root $CADENCE_HOME --env docker start --services=$SERVICES

0 comments on commit 73ffdeb

Please sign in to comment.