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 3b66e97 Improve docker dev env script (#3441)
3b66e97 is described below
commit 3b66e971c811b4258b3bd375ef5b0066857a373b
Author: Ning Wang <[email protected]>
AuthorDate: Sun Feb 2 22:48:42 2020 -0800
Improve docker dev env script (#3441)
---
docker/scripts/{dev-env.sh => dev-env-create.sh} | 40 +++++++++++-----------
docker/scripts/dev-env-run.sh | 42 ++++++++++++++++++++++++
2 files changed, 62 insertions(+), 20 deletions(-)
diff --git a/docker/scripts/dev-env.sh b/docker/scripts/dev-env-create.sh
old mode 100755
new mode 100644
similarity index 74%
rename from docker/scripts/dev-env.sh
rename to docker/scripts/dev-env-create.sh
index 63eec60..0926cfa
--- a/docker/scripts/dev-env.sh
+++ b/docker/scripts/dev-env-create.sh
@@ -16,39 +16,38 @@
# 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:
+# This is a script to create/start a docker container that has all
+# tools needed to build Heron. Developer should be able to
+# build Heron in the container without any other 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
+# sh docker/scripts/dev-env-create.sh CONTAINER_NAME [OS]
#
-# After the container is started, build Heron with bazel
+# After the container is started, you can 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 first:
-# docker ps -a
-# The image name looks like: "heron-dev:ubuntu18.04".=
-# After the container is found, execute the following commands to start
-# the container in case it is not started yet, and then start a new
-# terminal in the container:
-# docker container start CONTAINER_ID
-# docker exec -it CONTAINER_ID bash
-#
+# bazel build --config=ubuntu scripts/packages:binpkgs
set -o nounset
set -o errexit
+case $# in
+ 0)
+ echo "Missing arguments."
+ echo "Usage: $0 <container_name> [OS]"
+ exit 1
+ ;;
+esac
+
# Default platform is ubuntu18.04. Other available platforms
# include centos7, debian9
-TARGET_PLATFORM=${1:-"ubuntu18.04"}
-SCRATCH_DIR=${2:-"$HOME/.heron-docker"}
+TARGET_PLATFORM=${2:-"ubuntu18.04"}
+SCRATCH_DIR="$HOME/.heron-docker"
REPOSITORY="heron-dev"
-
+CONTAINER_NAME=$1
realpath() {
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
@@ -83,6 +82,7 @@ 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 \
+ --name $CONTAINER_NAME --rm \
-e TARGET_PLATFORM=$TARGET_PLATFORM \
-e SCRATCH_DIR="/scratch" \
-v $PROJECT_DIR:/heron \
diff --git a/docker/scripts/dev-env-run.sh b/docker/scripts/dev-env-run.sh
new file mode 100755
index 0000000..669d2d7
--- /dev/null
+++ b/docker/scripts/dev-env-run.sh
@@ -0,0 +1,42 @@
+#!/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 new session of the docker container
+# created with the dev-env-create.sh script.
+# Usage:
+# sh docker/scripts/dev-env-run.sh CONTAINER_NAME
+#
+# In case you forgot the container name, you can use this command
+# to list all the existing containers (name is the last column).
+# docker container ls -a
+
+set -o nounset
+set -o errexit
+
+case $# in
+ 0)
+ echo "Missing argument."
+ echo "Usage: $0 <container_name>"
+ exit 1
+ ;;
+esac
+
+CONTAINER_NAME=$1
+
+docker container start $CONTAINER_NAME
+docker exec -it $CONTAINER_NAME bash
\ No newline at end of file