Yaoli/fix dockerfiles (#3160)

* only_using_heron-install.sh_for_building_docker_image

Heron-install.sh contains everything needed for building Heron docker images. There is no need to copy heron-core.tar.gz into images, which will increase the image size.
diff --git a/docker/dist/Dockerfile.dist.centos7 b/docker/dist/Dockerfile.dist.centos7
index 0625068..950c40a 100644
--- a/docker/dist/Dockerfile.dist.centos7
+++ b/docker/dist/Dockerfile.dist.centos7
@@ -35,13 +35,18 @@
 WORKDIR /heron
 
 # run heron installer
-RUN /heron/heron-install.sh
+RUN /heron/heron-install.sh \
+    && rm -f /heron/heron-install.sh
 
-RUN mkdir -p /opt/heron && \
-    tar --strip-components=1 -m -zxvf /heron/heron-core.tar.gz -C /heron
-
-RUN rm -f /heron/heron-install.sh
-RUN rm -f /heron/heron-core.tar.gz
+RUN ln -s /usr/local/heron/dist/heron-core /heron \
+    && mkdir -p /heron/heron-tools \
+    && ln -s /usr/local/heron/bin /heron/heron-tools \
+    && ln -s /usr/local/heron/conf /heron/heron-tools \
+    && ln -s /usr/local/heron/dist /heron/heron-tools \
+    && ln -s /usr/local/heron/lib /heron/heron-tools \
+    && ln -s /usr/local/heron/release.yaml /heron/heron-tools \
+    && ln -s /usr/local/heron/examples /heron \
+    && ln -s /usr/local/heron/release.yaml /heron
 
 ENV HERON_HOME /heron/heron-core/
 RUN export HERON_HOME
diff --git a/docker/dist/Dockerfile.dist.debian9 b/docker/dist/Dockerfile.dist.debian9
index d7394e3..91441b9 100644
--- a/docker/dist/Dockerfile.dist.debian9
+++ b/docker/dist/Dockerfile.dist.debian9
@@ -31,16 +31,23 @@
 
 WORKDIR /heron
 
-
 # run heron installer
 RUN /heron/heron-install.sh && \
-    tar --strip-components=1 -m -zxvf /heron/heron-core.tar.gz -C /heron && \
-    rm -rf /heron/heron-core.tar.gz && \
     rm -rf /heron/heron-install.sh && \
     rm -rf /opt/heron/heron-core/lib/scheduler/heron-local-scheduler.jar && \
     rm -rf /opt/heron/heron-core/lib/scheduler/heron-mesos-scheduler.jar && \
     rm -rf /opt/heron/heron-core/lib/scheduler/heron-slurm-scheduler.jar
 
+RUN ln -s /usr/local/heron/dist/heron-core /heron \
+    && mkdir -p /heron/heron-tools \
+    && ln -s /usr/local/heron/bin /heron/heron-tools \
+    && ln -s /usr/local/heron/conf /heron/heron-tools \
+    && ln -s /usr/local/heron/dist /heron/heron-tools \
+    && ln -s /usr/local/heron/lib /heron/heron-tools \
+    && ln -s /usr/local/heron/release.yaml /heron/heron-tools \
+    && ln -s /usr/local/heron/examples /heron \
+    && ln -s /usr/local/heron/release.yaml /heron
+
 ENV HERON_HOME /heron/heron-core/
 
 # install zookeeper
diff --git a/docker/dist/Dockerfile.dist.ubuntu14.04 b/docker/dist/Dockerfile.dist.ubuntu14.04
index e448fe7..bb9f99b 100644
--- a/docker/dist/Dockerfile.dist.ubuntu14.04
+++ b/docker/dist/Dockerfile.dist.ubuntu14.04
@@ -37,7 +37,15 @@
 # run heron installer
 RUN /heron/heron-install.sh
 
-RUN tar --strip-components=1 -m -zxvf /heron/heron-core.tar.gz -C /heron
+RUN ln -s /usr/local/heron/dist/heron-core /heron \
+    && mkdir -p /heron/heron-tools \
+    && ln -s /usr/local/heron/bin /heron/heron-tools \
+    && ln -s /usr/local/heron/conf /heron/heron-tools \
+    && ln -s /usr/local/heron/dist /heron/heron-tools \
+    && ln -s /usr/local/heron/lib /heron/heron-tools \
+    && ln -s /usr/local/heron/release.yaml /heron/heron-tools \
+    && ln -s /usr/local/heron/examples /heron \
+    && ln -s /usr/local/heron/release.yaml /heron
 
 ENV HERON_HOME /heron/heron-core/
 
diff --git a/docker/dist/Dockerfile.dist.ubuntu16.04 b/docker/dist/Dockerfile.dist.ubuntu16.04
index 3ec11da..cf4be9c 100644
--- a/docker/dist/Dockerfile.dist.ubuntu16.04
+++ b/docker/dist/Dockerfile.dist.ubuntu16.04
@@ -35,12 +35,18 @@
 WORKDIR /heron
 
 # run heron installer
-RUN /heron/heron-install.sh
+RUN /heron/heron-install.sh \
+    && rm -f /heron/heron-install.sh
 
-RUN tar --strip-components=1 -m -zxvf /heron/heron-core.tar.gz -C /heron
-
-RUN rm -f /heron/heron-install.sh
-RUN rm -f /heron/heron-core.tar.gz
+RUN ln -s /usr/local/heron/dist/heron-core /heron \
+    && mkdir -p /heron/heron-tools \
+    && ln -s /usr/local/heron/bin /heron/heron-tools \
+    && ln -s /usr/local/heron/conf /heron/heron-tools \
+    && ln -s /usr/local/heron/dist /heron/heron-tools \
+    && ln -s /usr/local/heron/lib /heron/heron-tools \
+    && ln -s /usr/local/heron/release.yaml /heron/heron-tools \
+    && ln -s /usr/local/heron/examples /heron \
+    && ln -s /usr/local/heron/release.yaml /heron \
 
 ENV HERON_HOME /heron/heron-core/
 RUN export HERON_HOME
diff --git a/docker/dist/Dockerfile.dist.ubuntu18.04 b/docker/dist/Dockerfile.dist.ubuntu18.04
index 5f7f921..66960e5 100644
--- a/docker/dist/Dockerfile.dist.ubuntu18.04
+++ b/docker/dist/Dockerfile.dist.ubuntu18.04
@@ -12,12 +12,18 @@
 WORKDIR /heron
 
 # run heron installers
-RUN /heron/heron-install.sh
+RUN /heron/heron-install.sh \
+    && rm -f /heron/heron-install.sh
 
-RUN tar --strip-components=1 -m -zxvf /heron/heron-core.tar.gz -C /heron
-
-RUN rm -f /heron/heron-install.sh
-RUN rm -f /heron/heron-core.tar.gz
+RUN ln -s /usr/local/heron/dist/heron-core /heron \
+    && mkdir -p /heron/heron-tools \
+    && ln -s /usr/local/heron/bin /heron/heron-tools \
+    && ln -s /usr/local/heron/conf /heron/heron-tools \
+    && ln -s /usr/local/heron/dist /heron/heron-tools \
+    && ln -s /usr/local/heron/lib /heron/heron-tools \
+    && ln -s /usr/local/heron/release.yaml /heron/heron-tools \
+    && ln -s /usr/local/heron/examples /heron \
+    && ln -s /usr/local/heron/release.yaml /heron
 
 ENV HERON_HOME /heron/heron-core/
 RUN export HERON_HOME
diff --git a/docker/scripts/build-docker.sh b/docker/scripts/build-docker.sh
index 8359aa3..17bcfa2 100755
--- a/docker/scripts/build-docker.sh
+++ b/docker/scripts/build-docker.sh
@@ -54,14 +54,9 @@
 
   setup_scratch_dir $SCRATCH_DIR
 
-  # need to copy artifacts locally
-  CORE_FILE="$OUTPUT_DIRECTORY/heron-core-$HERON_VERSION-$TARGET_PLATFORM.tar.gz"
-  CORE_OUT_FILE="$SCRATCH_DIR/artifacts/heron-core.tar.gz"
-
   ALL_FILE="$OUTPUT_DIRECTORY/heron-install-$HERON_VERSION-$TARGET_PLATFORM.sh"
   ALL_OUT_FILE="$SCRATCH_DIR/artifacts/heron-install.sh"
 
-  cp $CORE_FILE $CORE_OUT_FILE
   cp $ALL_FILE $ALL_OUT_FILE
   export HERON_VERSION