This is an automated email from the ASF dual-hosted git repository. nwang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-heron.git
The following commit(s) were added to refs/heads/master by this push: new d950db5 Add a script to start docker container with development environment (#3366) d950db5 is described below commit d950db583b8097443bd0de29338d8b0d25ed63f4 Author: Ning Wang <nw...@twitter.com> AuthorDate: Fri Oct 18 23:05:48 2019 -0700 Add a script to start docker container with development environment (#3366) * Add a script to start docker container with development environment * update * update comments for starting a new shell * map ports 8888 and 8889 --- docker/compile/Dockerfile.centos7 | 6 +-- docker/compile/Dockerfile.ubuntu18.04 | 8 ++-- docker/scripts/dev-env.sh | 87 +++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/docker/compile/Dockerfile.centos7 b/docker/compile/Dockerfile.centos7 index 3865b5b..3eda6c4 100644 --- a/docker/compile/Dockerfile.centos7 +++ b/docker/compile/Dockerfile.centos7 @@ -41,9 +41,9 @@ RUN yum -y install \ zip \ unzip \ wget \ - which - -RUN yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel + which \ + java-1.8.0-openjdk \ + java-1.8.0-openjdk-devel ENV JAVA_HOME /usr/lib/jvm/java-1.8.0 diff --git a/docker/compile/Dockerfile.ubuntu18.04 b/docker/compile/Dockerfile.ubuntu18.04 index 28b8f23..48a62ef 100644 --- a/docker/compile/Dockerfile.ubuntu18.04 +++ b/docker/compile/Dockerfile.ubuntu18.04 @@ -31,9 +31,11 @@ RUN apt-get update && apt-get -y install \ python-dev \ wget \ zip \ - unzip - -RUN apt-get -y install openjdk-8-jdk-headless + virtualenv \ + unzip \ + git \ + curl \ + openjdk-8-jdk-headless ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 diff --git a/docker/scripts/dev-env.sh b/docker/scripts/dev-env.sh new file mode 100755 index 0000000..17e37ed --- /dev/null +++ b/docker/scripts/dev-env.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# 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. + +# This is a script to start a docker container that has all +# tools needed to compire Heron. Developer should be able to +# compile Heron in the container without any setup works. +# usage: +# To create a clean development environment with docker and run it, +# execute the following scripts in the source directory of Heron: +# sh docker/scripts/dev-env.sh +# +# After the container is started, build Heron with bazel +# (ubuntu config is used in the example): +# ./bazel_configure.py +# bazel build --config=ubuntu heron/... +# +# To enter an existing container with a new shell, find the container +# id with this command: +# docker ps -a +# And then : +# docker exec -it CONTAINER_ID bash + +set -o nounset +set -o errexit + +# Default platform is ubuntu18.04. Other available platforms +# include centos7, debian9 +TARGET_PLATFORM=${1:-"ubuntu18.04"} +SCRATCH_DIR=${2:-"$HOME/.heron-docker"} +REPOSITORY="heron-dev" + + +realpath() { + echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" +} + +DOCKER_DIR=$(dirname $(dirname $(realpath $0))) +PROJECT_DIR=$(dirname $DOCKER_DIR) + +verify_dockerfile_exists() { + if [ ! -f $1 ]; then + echo "The Dockerfiler $1 does not exist" + exit 1 + fi +} + +dockerfile_path_for_platform() { + echo "$DOCKER_DIR/compile/Dockerfile.$1" +} + +copy_extra_files() { + mkdir -p $SCRATCH_DIR/scripts + cp $PROJECT_DIR/tools/docker/bazel.rc $SCRATCH_DIR/bazelrc + cp $DOCKER_DIR/scripts/compile-docker.sh $SCRATCH_DIR/scripts/compile-platform.sh +} + +DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM) +verify_dockerfile_exists $DOCKER_FILE +copy_extra_files + +echo "Building docker image for Heron development environment on $TARGET_PLATFORM" +docker build -t $REPOSITORY:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR + +echo "Creating and starting container and mapping the current dir to /heron" +docker container run -it \ + -e TARGET_PLATFORM=$TARGET_PLATFORM \ + -e SCRATCH_DIR="/scratch" \ + -v $PROJECT_DIR:/heron \ + -w "/heron" \ + -p 8888:8888 \ + -p 8889:8889 \ + -t $REPOSITORY:$TARGET_PLATFORM bash