Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Adding Bazel Platforms support #3779

Merged
merged 19 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "com_github_johnynek_bazel_jar_jar",
commit = "171f268569384c57c19474b04aebe574d85fde0d", # Latest commit SHA as at 2019/02/13
commit = "171f268569384c57c19474b04aebe574d85fde0d", # Latest commit SHA as at 2019/02/13
remote = "https://github.com/johnynek/bazel_jar_jar.git",
shallow_since = "1594234634 -1000",
)
Expand All @@ -189,6 +189,16 @@ load(

jar_jar_repositories()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
],
sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
)

http_archive(
name = "rules_python",
sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
Expand Down
1 change: 0 additions & 1 deletion docker/compile/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ RUN /usr/bin/ln -sfT /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3 \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++ \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/cpp /usr/bin/cpp

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
4 changes: 0 additions & 4 deletions docker/compile/Dockerfile.debian10
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM openjdk:11.0.6-jdk-buster

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

Expand Down Expand Up @@ -52,5 +49,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& /tmp/bazel.sh \
&& rm -rf /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
8 changes: 2 additions & 6 deletions docker/compile/Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@

FROM rockylinux:8.5

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

RUN yum -y upgrade
RUN yum -y install \
RUN yum -y upgrade \
&& yum -y install \
ant \
automake \
curl \
Expand Down Expand Up @@ -57,5 +54,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& /tmp/bazel.sh \
&& rm -rf /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
4 changes: 0 additions & 4 deletions docker/compile/Dockerfile.ubuntu18.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM ubuntu:18.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
Expand Down Expand Up @@ -57,5 +54,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& /tmp/bazel.sh \
&& rm -rf /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
4 changes: 0 additions & 4 deletions docker/compile/Dockerfile.ubuntu20.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

FROM ubuntu:20.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
Expand Down Expand Up @@ -54,5 +51,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& /tmp/bazel.sh \
&& rm -rf /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
5 changes: 1 addition & 4 deletions docker/compile/Dockerfile.ubuntu22.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

FROM ubuntu:22.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM ubuntu

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

# Docker 20.10.10 or older will not work
RUN apt-get update && apt-get -y install \
ant \
g++ \
Expand Down Expand Up @@ -54,5 +52,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& /tmp/bazel.sh \
&& rm -rf /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/compile-platform.sh /compile-platform.sh
2 changes: 1 addition & 1 deletion docker/dist/Dockerfile.dist.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#syntax=docker/dockerfile:1.2
FROM rockylinux:8.5

RUN yum -y install epel-release \
RUN yum -y upgrade \
&& yum -y install \
curl \
java-11-openjdk-headless \
Expand Down
1 change: 1 addition & 0 deletions docker/dist/Dockerfile.dist.ubuntu20.04
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ARG DEBIAN_FRONTEND=noninteractive
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

# Docker 20.10.10 or older will not work
RUN apt-get -y update \
&& apt-get -y install \
curl \
Expand Down
66 changes: 66 additions & 0 deletions docker/dist/Dockerfile.dist.ubuntu22.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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.

#syntax=docker/dockerfile:1.2
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

# Docker 20.10.10 or older will not work
RUN apt-get -y update \
&& apt-get -y install \
curl \
openjdk-11-jdk-headless \
netcat-openbsd \
python3 \
python3-distutils \
supervisor \
unzip \
&& apt-get clean

ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
RUN update-ca-certificates -f

# run Heron installer
RUN --mount=type=bind,source=artifacts,target=/tmp/heron /tmp/heron/heron-install.sh \
&& rm -f /usr/local/heron/dist/heron-core.tar.gz

WORKDIR /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/
RUN export HERON_HOME

# install Zookeeper
ARG ZK_DIST=zookeeper-3.5.8

RUN --mount=type=bind,source=dist,target=/opt/heron-docker/ sh /opt/heron-docker/scripts/install-zookeeper.sh $ZK_DIST

ADD dist/conf/zookeeper.conf /opt/zookeeper/conf/zookeeper.conf
ADD dist/conf/sandbox.conf /etc/supervisor/conf.d/
5 changes: 0 additions & 5 deletions docker/scripts/compile-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ dockerfile_path_for_platform() {
echo "$SCRATCH_DIR/compile/Dockerfile.$1"
}

copy_bazel_rc_to() {
cp $PROJECT_DIR/tools/docker/bazel.rc $1
}

nicknezis marked this conversation as resolved.
Show resolved Hide resolved
DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM)
verify_dockerfile_exists $DOCKER_FILE
copy_bazel_rc_to $SCRATCH_DIR/bazelrc

echo "Building heron-compiler container"
docker buildx build -t heron-compiler:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR
Expand Down
21 changes: 3 additions & 18 deletions docker/scripts/compile-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,14 @@ cd $SCRATCH_DIR
echo "Extracting source"
tar -C . -xzf $SOURCE_TARBALL

if [[ "$TARGET_PLATFORM" =~ "ubuntu" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "centos" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "rocky" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "debian" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "darwin" ]]; then
CONFIG_PLATFORM=darwin_nostyle
else
echo "Unknown platform: $TARGET_PLATFORM"
exit 1
fi

bazel version
./bazel_configure.py
bazel clean

echo "Creating packages"
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/packages:tarpkgs
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/packages:binpkgs
bazel build -c opt --jobs 25 --config=$CONFIG_PLATFORM scripts/images:heron.tar
bazel build -c opt --copt=-O3 scripts/packages:tarpkgs
bazel build -c opt --copt=-O3 scripts/packages:binpkgs
bazel build -c opt --copt=-O3 scripts/images:heron.tar

echo "Moving packages to /$OUTPUT_DIRECTORY"
for file in ./bazel-bin/scripts/packages/*.tar.gz; do
Expand Down
5 changes: 2 additions & 3 deletions docker/scripts/dev-env-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
# After the container is started, you can build Heron with bazel
# (ubuntu config is used in the example):
# ./bazel_configure.py
# bazel build --config=linux heron/...
# bazel build --config=linux scripts/packages:binpkgs
# bazel build heron/...
# bazel build scripts/packages:binpkgs

set -o nounset
set -o errexit
Expand Down Expand Up @@ -69,7 +69,6 @@ dockerfile_path_for_platform() {

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
}

Expand Down
5 changes: 0 additions & 5 deletions docker/scripts/test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ dockerfile_path_for_platform() {
echo "$SCRATCH_DIR/test/Dockerfile.$1"
}

copy_bazel_rc_to() {
cp $PROJECT_DIR/tools/docker/bazel.rc $1
}

DOCKER_FILE=$(dockerfile_path_for_platform $TARGET_PLATFORM)
verify_dockerfile_exists $DOCKER_FILE
copy_bazel_rc_to $SCRATCH_DIR/bazelrc

echo "Building heron-compiler container"
docker buildx build -t heron-compiler:$TARGET_PLATFORM -f $DOCKER_FILE $SCRATCH_DIR
Expand Down
18 changes: 1 addition & 17 deletions docker/scripts/test-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,12 @@ cd $SCRATCH_DIR
echo "Extracting source"
tar -C . -xzf $SOURCE_TARBALL

if [[ "$TARGET_PLATFORM" =~ "ubuntu" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "centos" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "rocky" ]]; then
CONFIG_PLATFORM=linux_nostyle
elif [[ "$TARGET_PLATFORM" =~ "darwin" ]]; then
CONFIG_PLATFORM=darwin
elif [[ "$TARGET_PLATFORM" =~ "debian" ]]; then
CONFIG_PLATFORM=linux_nostyle
else
echo "Unknown platform: $TARGET_PLATFORM"
exit 1
fi

bazel version
./bazel_configure.py
bazel clean

echo "UnitTest"
bazel test -c opt --jobs 25 \
--config=$CONFIG_PLATFORM \
bazel test -c opt \
--test_output=all \
--test_summary=detailed \
heron/... \
Expand Down
7 changes: 2 additions & 5 deletions docker/test/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

FROM centos:centos7

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux
ENV LC_ALL en_US.utf8

RUN yum -y upgrade && yum -y install centos-release-scl-rh
RUN yum -y install \
automake \
Expand All @@ -31,6 +27,7 @@ RUN yum -y install \
devtoolset-8-gcc \
devtoolset-8-gcc-c++ \
git \
glibc-langpack-en \
kernel-devel \
libtool \
make \
Expand All @@ -51,6 +48,7 @@ RUN /usr/bin/ln -sfT /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3 \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++ \
&& /usr/bin/ln -sfT /opt/rh/devtoolset-8/root/bin/cpp /usr/bin/cpp

ENV LC_ALL en_US.utf8
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk

ENV bazelVersion 4.2.2
Expand All @@ -59,5 +57,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& chmod +x /tmp/bazel.sh \
&& /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/test-platform.sh /test-platform.sh
4 changes: 2 additions & 2 deletions docker/test/Dockerfile.rocky8
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ FROM rockylinux:8.5
# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux

RUN yum -y upgrade
RUN yum -y install \
RUN yum -y upgrade \
&& yum -y install \
automake \
curl \
cmake \
Expand Down
5 changes: 2 additions & 3 deletions docker/test/Dockerfile.ubuntu18.04
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

FROM ubuntu:18.04

# This is passed to the heron build command via the --config flag
ENV TARGET_PLATFORM linux
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

RUN apt-get update && apt-get -y install \
g++ \
Expand Down Expand Up @@ -47,5 +47,4 @@ RUN wget -O /tmp/bazel.sh https://github.com/bazelbuild/bazel/releases/download/
&& chmod +x /tmp/bazel.sh \
&& /tmp/bazel.sh

ADD bazelrc /root/.bazelrc
ADD scripts/test-platform.sh /test-platform.sh
2 changes: 1 addition & 1 deletion examples/src/scala/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function die {
which scalac || die "scalac must be installed to run this script. Exiting."

rm -f heron-storm.jar
(cd $root && bazel build --config=darwin scripts/packages:tarpkgs)
(cd $root && bazel build scripts/packages:tarpkgs)

# Verify storm and heron bolts compile with heron-storm.jar
scalac -cp bazel-bin/./storm-compatibility/v0.10.2/src/java/heron-storm.jar \
Expand Down
2 changes: 1 addition & 1 deletion heron/common/src/cpp/basics/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cc_library(
"@com_github_corvusoft_kashmir_cpp//:kashmir-cxx",
"@com_google_protobuf//:protobuf",
] + select({
"//tools/platform:darwin": [],
"@platforms//os:osx": [],
"//conditions:default": ["@org_nongnu_libunwind//:libunwind"],
}),
)
Loading