|
| 1 | +#!/bin/bash |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | +set -o nounset |
| 19 | +set -o errexit |
| 20 | + |
| 21 | +realpath() { |
| 22 | + echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" |
| 23 | +} |
| 24 | + |
| 25 | +DOCKER_DIR=$(dirname $(dirname $(realpath $0))) |
| 26 | +PROJECT_DIR=$(dirname $DOCKER_DIR) |
| 27 | + |
| 28 | +verify_dockerfile_exists() { |
| 29 | + if [ ! -f $1 ]; then |
| 30 | + echo "The Dockerfiler $1 does not exist" |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | +} |
| 34 | + |
| 35 | +dockerfile_path_for_platform() { |
| 36 | + echo "$SCRATCH_DIR/test/Dockerfile.$1" |
| 37 | +} |
| 38 | + |
| 39 | +copy_bazel_rc_to() { |
| 40 | + cp $PROJECT_DIR/tools/docker/bazel.rc $1 |
| 41 | +} |
| 42 | + |
| 43 | +DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM) |
| 44 | +verify_dockerfile_exists $DOCKER_FILE |
| 45 | +copy_bazel_rc_to $SCRATCH_DIR/bazelrc |
| 46 | + |
| 47 | +echo "Building heron-compiler container" |
| 48 | +docker build -t heron-compiler:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR |
| 49 | + |
| 50 | +echo "Running build in container" |
| 51 | +docker run \ |
| 52 | + --rm \ |
| 53 | + -e TARGET_PLATFORM=$TARGET_PLATFORM \ |
| 54 | + -e SCRATCH_DIR="/scratch" \ |
| 55 | + -e SOURCE_TARBALL="/src.tar.gz" \ |
| 56 | + -e HERON_VERSION=$HERON_VERSION \ |
| 57 | + -e HERON_GIT_REV="${HERON_GIT_REV}" \ |
| 58 | + -e HERON_BUILD_VERSION="${HERON_BUILD_VERSION}" \ |
| 59 | + -e HERON_BUILD_HOST="${HERON_BUILD_HOST}" \ |
| 60 | + -e HERON_BUILD_USER="${HERON_BUILD_USER}" \ |
| 61 | + -e HERON_BUILD_TIME="${HERON_BUILD_TIME}" \ |
| 62 | + -e HERON_TREE_STATUS="${HERON_TREE_STATUS}" \ |
| 63 | + -v "$SOURCE_TARBALL:/src.tar.gz:ro" \ |
| 64 | + -t heron-compiler:$TARGET_PLATFORM /test-platform.sh |
0 commit comments