Repository: incubator-gearpump Updated Branches: refs/heads/master 1d15265dc -> c27cd808c
[GEARPUMP-266] Add docker file Author: manuzhang <[email protected]> Closes #141 from manuzhang/docker. Project: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/commit/c27cd808 Tree: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/tree/c27cd808 Diff: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/diff/c27cd808 Branch: refs/heads/master Commit: c27cd808c2d38a9b105fafc1aa0575f7beee2978 Parents: 1d15265 Author: manuzhang <[email protected]> Authored: Wed Feb 8 16:45:10 2017 +0800 Committer: manuzhang <[email protected]> Committed: Wed Feb 8 16:45:20 2017 +0800 ---------------------------------------------------------------------- integrationtest/docker/Dockerfile | 31 +++++++++++ integrationtest/docker/README.md | 28 ++++++++++ integrationtest/docker/start.sh | 94 ++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/c27cd808/integrationtest/docker/Dockerfile ---------------------------------------------------------------------- diff --git a/integrationtest/docker/Dockerfile b/integrationtest/docker/Dockerfile new file mode 100644 index 0000000..f0a436a --- /dev/null +++ b/integrationtest/docker/Dockerfile @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# The base image contains JRE8 +FROM errordeveloper/oracle-jre + +# Add Python Support +RUN opkg-install python + +# Create SUT home, files will be mounted at runtime. +ENV SUT_HOME=/opt/gearpump +WORKDIR $SUT_HOME + +# Setup the entry point +ADD start.sh /opt/start +RUN chmod +x /opt/start + +ENTRYPOINT ["/opt/start"] http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/c27cd808/integrationtest/docker/README.md ---------------------------------------------------------------------- diff --git a/integrationtest/docker/README.md b/integrationtest/docker/README.md new file mode 100644 index 0000000..450bec6 --- /dev/null +++ b/integrationtest/docker/README.md @@ -0,0 +1,28 @@ +# Gearpump Launcher Docker Image + +The image helps developer to setup/test a local [Gearpump](https://github.com/apache/incubator-gearpump.git) cluster quickly. The image is based on a minimal JRE8 environment with Python support. + +## Usage + +Here are the commands to launch a cluster. You can launch as many worker containers as you wish but only one master for the time being. +``` +export GEARPUMP_HOME=/path/to/gearpump + +docker run -d \ + -h master0 --name master0 \ + -v $GEARPUMP_HOME:/opt/gearpump \ + -e JAVA_OPTS=-Dgearpump.cluster.masters.0=master0:3000 \ + -p 8090:8090 \ + stanleyxu2005/gearpump-launcher \ + master -ip master0 -port 3000 + +docker run -d \ + --link master0 \ + -v $GEARPUMP_HOME:/opt/gearpump \ + -e JAVA_OPTS=-Dgearpump.cluster.masters.0=master0:3000 \ + stanleyxu2005/gearpump-launcher \ + worker + +docker exec master0 gear info +docker exec master0 gear app -jar /path/to/userapp.jar [mainclass] [args] +``` http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/c27cd808/integrationtest/docker/start.sh ---------------------------------------------------------------------- diff --git a/integrationtest/docker/start.sh b/integrationtest/docker/start.sh new file mode 100644 index 0000000..76d1f18 --- /dev/null +++ b/integrationtest/docker/start.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +if [ ! -d "$SUT_HOME/bin" ]; then + echo "FATAL: The Gearpump distribution seems to be incomplete. Please build gearpump with 'sbt clean assembly' first, so that the test driver is able to mount the distribution directory to '/opt/gearpump'." + exit 1 +fi + +if [ -z "$JAVA_OPTS" ]; then + echo "FATAL: Environment variable 'JAVA_OPTS' is NOT set." + exit 1 +fi + +update_config_file() { + CONF_FILE="$SUT_HOME"/conf/gear.conf + mkdir /var/log/gearpump + sed -i 's/log\.daemon\.dir\s*=.*$/log.daemon.dir = "\/var\/log\/gearpump\/daemon"/g' $CONF_FILE + sed -i 's/log\.application\.dir\s*=.*$/log.application.dir = "\/var\/log\/gearpump\/app"/g' $CONF_FILE + sed -i 's/#\s*jarstore\.rootpath\s*=.*$/jarstore.rootpath = "\/tmp"/g' $CONF_FILE +} + +set_and_export_java_opts() { + JAVA_OPTS="$JAVA_OPTS $*" + export JAVA_OPTS +} + +COMMAND=$1 +shift + +case "$COMMAND" in + master|local) + # Launch a container with Gearpump cluster and REST interface (in foreground) + HOSTNAME=$(hostname) + update_config_file + set_and_export_java_opts \ + "-Dgearpump.hostname=$HOSTNAME" \ + "-Dgearpump.services.host=$HOSTNAME" + nohup sh "$SUT_HOME"/bin/services & + nohup sh "$SUT_HOME"/bin/"$COMMAND" "$@" + ;; + worker) + # Launch a container with a Gearpump worker (in foreground) + update_config_file + set_and_export_java_opts \ + "-Dgearpump.hostname=$(hostname -i)" + nohup sh "$SUT_HOME"/bin/worker + ;; + gear|storm) + # Launch a container and execute command `gear` or `storm` + # Container will be killed, when command is executed. + update_config_file + set_and_export_java_opts \ + "-Dgearpump.hostname=$(hostname -i)" + sh "$SUT_HOME"/bin/"$COMMAND" "$@" + ;; + storm-drpc) + # Launch a container with a Storm DRPC daemon + # Note that this command has nothing to do with Gearpump, it only uses storm related jar libs. + LIB_HOME="$SUT_HOME"/lib + cat > "$SUT_HOME"/storm.yaml <<- EOF +drpc.servers: + - $(ip route|awk '/default/ {print $3}') +EOF + java -server -Xmx768m -cp "$LIB_HOME"/*:"$LIB_HOME"/storm/* backtype.storm.daemon.drpc + ;; + *) + cat <<- USAGE +Gearpump Commands: + master -ip [HOST] -port [PORT] + worker + gear (app|info|kill) [ARGS] + storm [ARGS] + +Storm Commands: + storm-drpc +USAGE + exit 1 + ;; +esac
