From 6c670c839fb4f45a5f3bed3538a7ceb34b4da2cd Mon Sep 17 00:00:00 2001 From: aandyl Date: Tue, 8 Oct 2019 06:44:28 -0700 Subject: [PATCH] fixes for building OpenJ9 using docker (#1171) * fixes for building OpenJ9 using docker * some shell script changes to avoid errors from `set -u` * separate the openj9 Dockerfile from the base dockerfile --- .dockerignore | 1 + docker-build.sh | 6 ++-- docker/jdk8/x86_64/ubuntu/Dockerfile | 3 +- docker/jdk8/x86_64/ubuntu/Dockerfile-openj9 | 39 ++++++++++++++++++--- sbin/common/common.sh | 2 +- 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..00d51f95a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +workspace/build/ diff --git a/docker-build.sh b/docker-build.sh index 1286c2f41..ba9aa8fa0 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -143,16 +143,16 @@ buildOpenJDKViaDocker() -v "${hostDir}"/pipelines:/openjdk/pipelines -e "DEBUG_DOCKER_FLAG=${BUILD_CONFIG[DEBUG_DOCKER]}" -e "BUILD_VARIANT=${BUILD_CONFIG[BUILD_VARIANT]}" - "${dockerEntrypoint[@]}") + "${dockerEntrypoint[@]:+${dockerEntrypoint[@]}}") # If build specifies --ssh, add array to the command string if [[ "${BUILD_CONFIG[USE_SSH]}" == "true" ]] ; then - commandString=("${gitSshAccess[@]}" "${commandString[@]}") + commandString=("${gitSshAccess[@]:+${gitSshAccess[@]}}" "${commandString[@]}") fi # If build specifies --debug-docker, add array to the command string if [[ "${BUILD_CONFIG[DEBUG_DOCKER]}" == "true" ]] ; then - commandString=("${dockerMode[@]}" "${commandString[@]}") + commandString=("${dockerMode[@]:+${dockerMode[@]}}" "${commandString[@]}") echo "DEBUG DOCKER MODE. To build jdk run /openjdk/sbin/build.sh" fi diff --git a/docker/jdk8/x86_64/ubuntu/Dockerfile b/docker/jdk8/x86_64/ubuntu/Dockerfile index d773786cc..bf470275b 100644 --- a/docker/jdk8/x86_64/ubuntu/Dockerfile +++ b/docker/jdk8/x86_64/ubuntu/Dockerfile @@ -44,11 +44,12 @@ RUN apt-get update \ libxt-dev \ libxtst-dev \ make \ + ssh \ systemtap-sdt-dev \ unzip \ wget \ zip \ - ssh \ + zulu-7 \ && rm -rf /var/lib/apt/lists/* # Pick up build instructions diff --git a/docker/jdk8/x86_64/ubuntu/Dockerfile-openj9 b/docker/jdk8/x86_64/ubuntu/Dockerfile-openj9 index 013562822..8e995aa7b 100644 --- a/docker/jdk8/x86_64/ubuntu/Dockerfile-openj9 +++ b/docker/jdk8/x86_64/ubuntu/Dockerfile-openj9 @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM openjdk_container +FROM ubuntu:16.04 MAINTAINER AdoptOpenJDK @@ -21,26 +21,55 @@ RUN apt-get update \ autoconf \ ccache \ cpio \ + curl \ file \ g++-4.8 \ gcc-4.8 \ + git \ + gnupg2 \ + libasound2-dev \ + libcups2-dev \ libdwarf-dev \ libelf-dev \ - libfontconfig \ + libfontconfig1-dev \ libfreetype6-dev \ libnuma-dev \ + libx11-dev \ + libxext-dev \ + libxrender-dev \ + libxt-dev \ + libxtst-dev \ + make \ + nasm \ + openjdk-8-jdk \ pkg-config \ ssh \ + unzip \ + wget \ + zip \ && rm -rf /var/lib/apt/lists/* # Make sure build uses 4.8 -RUN rm /usr/bin/gcc \ - && rm /usr/bin/g++ \ - && rm /usr/bin/c++ \ +RUN rm -f /usr/bin/gcc \ + && rm -f /usr/bin/g++ \ + && rm -f /usr/bin/c++ \ && ln -s /usr/bin/gcc-4.8 /usr/bin/gcc \ && ln -s /usr/bin/g++-4.8 /usr/bin/g++ \ && ln -s /usr/bin/g++-4.8 /usr/bin/c++ +# Pick up build instructions +RUN mkdir -p /openjdk/target + +COPY sbin /openjdk/sbin +COPY workspace/config /openjdk/config +COPY pipelines /openjdk/pipelines + +RUN mkdir -p /openjdk/build +RUN useradd -ms /bin/bash build +RUN chown -R build: /openjdk/ +USER build +WORKDIR /openjdk/build/ + ARG OPENJDK_CORE_VERSION ENV OPENJDK_CORE_VERSION=$OPENJDK_CORE_VERSION ENV JDK_PATH=jdk diff --git a/sbin/common/common.sh b/sbin/common/common.sh index 3014cc60e..60814bff5 100755 --- a/sbin/common/common.sh +++ b/sbin/common/common.sh @@ -52,7 +52,7 @@ function crossPlatformRealPath() { local name=$(basename "$target") fi - local fullPath="$PWD/$name" + local fullPath="$PWD/${name:+${name}}" cd "$currentDir" echo "$fullPath" }