Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRILL-7803] Docker based developer build environment #2115

Merged
merged 1 commit into from
Nov 16, 2020
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
155 changes: 155 additions & 0 deletions dev-support/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#
# 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.
#

# Dockerfile for installing the necessary dependencies for building Drill.
# See BUILDING.txt.

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

WORKDIR /root

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

#####
# Disable suggests/recommends
#####
RUN echo APT::Install-Recommends "0"\; > /etc/apt/apt.conf.d/10disableextras
RUN echo APT::Install-Suggests "0"\; >> /etc/apt/apt.conf.d/10disableextras

ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_TERSE true


# hadolint ignore=DL3008
RUN apt -q update \
&& apt install -y software-properties-common apt-utils apt-transport-https \
# Repo for different Python versions
&& add-apt-repository -y ppa:deadsnakes/ppa \
&& apt-get -q install -y --no-install-recommends \
ant \
bats \
bash-completion \
build-essential \
bzip2 \
ca-certificates \
clang \
cmake \
curl \
docker.io \
doxygen \
findbugs \
fuse \
g++ \
gcc \
git \
gnupg-agent \
libaio1 \
libbcprov-java \
libbz2-dev \
libcurl4-openssl-dev \
libfuse-dev \
libnuma-dev \
libncurses5 \
libprotobuf-dev \
libprotoc-dev \
libsasl2-dev \
libsnappy-dev \
libssl-dev \
libtool \
libzstd-dev \
locales \
make \
maven \
# openjdk-11-jdk \
openjdk-8-jdk \
pinentry-curses \
pkg-config \
python \
python2.7 \
# python-pip \
python-pkg-resources \
python-setuptools \
# python-wheel \
python3-setuptools \
python3-pip \
python3.5 \
python3.6 \
python3.7 \
python2.7 \
virtualenv \
tox \
rsync \
shellcheck \
software-properties-common \
sudo \
valgrind \
vim \
wget \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

###
# Install grpcio-tools mypy-protobuf for `python3 sdks/python/setup.py sdist` to work
###
RUN pip3 install grpcio-tools mypy-protobuf

###
# Install Go
###
RUN mkdir -p /goroot \
&& curl https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1 \
&& chmod a+rwX -R /goroot

# Set environment variables for Go
ENV GOROOT /goroot
ENV GOPATH /gopath
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
CMD go get github.com/linkedin/goavro

###
# Miscelaneous fixes...
###
# Turns out some build tools use 'time' and in this docker image this is no longer
# an executable but ONLY an internal command of bash
COPY time.sh /usr/bin/time
RUN chmod 755 /usr/bin/time

# Force the complete use of Java 8
RUN apt remove -y openjdk-11-jre openjdk-11-jre-headless
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/


###
# Avoid out of memory errors in builds
###
ENV MAVEN_OPTS -Xmx4g -XX:MaxPermSize=512m

###
# Add a welcome message and environment checks.
###
RUN mkdir /scripts
COPY drill_env_checks.sh /scripts/drill_env_checks.sh
COPY bashcolors.sh /scripts/bashcolors.sh
RUN chmod 755 /scripts /scripts/drill_env_checks.sh /scripts/bashcolors.sh

# hadolint ignore=SC2016
RUN echo '. /etc/bash_completion' >> /root/.bash_aliases
RUN echo '. /scripts/drill_env_checks.sh' >> /root/.bash_aliases
93 changes: 93 additions & 0 deletions dev-support/docker/bashcolors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env 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.
#

# Based upon info on https://wiki.archlinux.org/index.php/Color_Bash_Prompt

# Reset
export Color_Off='\e[0m' # Text Reset

# Regular Colors
export Black='\e[0;30m' # Black
export Red='\e[0;31m' # Red
export Green='\e[0;32m' # Green
export Yellow='\e[0;33m' # Yellow
export Blue='\e[0;34m' # Blue
export Purple='\e[0;35m' # Purple
export Cyan='\e[0;36m' # Cyan
export White='\e[0;37m' # White

# Bold
export BBlack='\e[1;30m' # Black
export BRed='\e[1;31m' # Red
export BGreen='\e[1;32m' # Green
export BYellow='\e[1;33m' # Yellow
export BBlue='\e[1;34m' # Blue
export BPurple='\e[1;35m' # Purple
export BCyan='\e[1;36m' # Cyan
export BWhite='\e[1;37m' # White

# Underline
export UBlack='\e[4;30m' # Black
export URed='\e[4;31m' # Red
export UGreen='\e[4;32m' # Green
export UYellow='\e[4;33m' # Yellow
export UBlue='\e[4;34m' # Blue
export UPurple='\e[4;35m' # Purple
export UCyan='\e[4;36m' # Cyan
export UWhite='\e[4;37m' # White

# Background
export On_Black='\e[40m' # Black
export On_Red='\e[41m' # Red
export On_Green='\e[42m' # Green
export On_Yellow='\e[43m' # Yellow
export On_Blue='\e[44m' # Blue
export On_Purple='\e[45m' # Purple
export On_Cyan='\e[46m' # Cyan
export On_White='\e[47m' # White

# High Intensity
export IBlack='\e[0;90m' # Black
export IRed='\e[0;91m' # Red
export IGreen='\e[0;92m' # Green
export IYellow='\e[0;93m' # Yellow
export IBlue='\e[0;94m' # Blue
export IPurple='\e[0;95m' # Purple
export ICyan='\e[0;96m' # Cyan
export IWhite='\e[0;97m' # White

# Bold High Intensity
export BIBlack='\e[1;90m' # Black
export BIRed='\e[1;91m' # Red
export BIGreen='\e[1;92m' # Green
export BIYellow='\e[1;93m' # Yellow
export BIBlue='\e[1;94m' # Blue
export BIPurple='\e[1;95m' # Purple
export BICyan='\e[1;96m' # Cyan
export BIWhite='\e[1;97m' # White

# High Intensity backgrounds
export On_IBlack='\e[0;100m' # Black
export On_IRed='\e[0;101m' # Red
export On_IGreen='\e[0;102m' # Green
export On_IYellow='\e[0;103m' # Yellow
export On_IBlue='\e[0;104m' # Blue
export On_IPurple='\e[0;105m' # Purple
export On_ICyan='\e[0;106m' # Cyan
export On_IWhite='\e[0;107m' # White
121 changes: 121 additions & 0 deletions dev-support/docker/drill_env_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env 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.
#

# SHELLDOC-IGNORE

# -------------------------------------------------------
function showWelcome {
# http://patorjk.com/software/taag/#p=display&f=Doom&t=Drill%20Build%20Env.
cat << "Welcome-message"

______ _ _ _ ______ _ _ _ _____
| _ \ (_) | | | ___ \ (_) | | | | ___|
| | | |_ __ _| | | | |_/ /_ _ _| | __| | | |__ _ ____ __
| | | | '__| | | | | ___ \ | | | | |/ _` | | __| '_ \ \ / /
| |/ /| | | | | | | |_/ / |_| | | | (_| | | |__| | | \ V /
|___/ |_| |_|_|_| \____/ \__,_|_|_|\__,_| \____/_| |_|\_(_)

This is the standard Drill Developer build environment.
This has all the right tools installed required to build
Apache Drill from source.

Welcome-message
}

# -------------------------------------------------------

function showAbort {
cat << "Abort-message"

___ _ _ _
/ _ \| | | | (_)
/ /_\ \ |__ ___ _ __| |_ _ _ __ __ _
| _ | '_ \ / _ \| '__| __| | '_ \ / _\` |
| | | | |_) | (_) | | | |_| | | | | (_| |
\_| |_/_.__/ \___/|_| \__|_|_| |_|\__, |
__/ |
|___/

Abort-message
}

# -------------------------------------------------------

function failIfUserIsRoot {
if [ "$(id -u)" -eq "0" ]; # If you are root then something went wrong.
then
cat <<End-of-message

Apparently you are inside this docker container as the user root.
Putting it simply:

This should not occur.

Known possible causes of this are:
1) Running this script as the root user ( Just don't )
2) Running an old docker version ( upgrade to 1.4.1 or higher )

End-of-message

showAbort

logout

fi
}

# -------------------------------------------------------

function warnIfLowMemory {
MINIMAL_MEMORY=2046755
INSTALLED_MEMORY=$(grep -F MemTotal /proc/meminfo | awk '{print $2}')
if [[ $((INSTALLED_MEMORY)) -lt $((MINIMAL_MEMORY)) ]]; then
cat <<End-of-message

_ ___ ___
| | | \\/ |
| | _____ __ | . . | ___ _ __ ___ ___ _ __ _ _
| | / _ \\ \\ /\\ / / | |\\/| |/ _ \\ '_ \` _ \\ / _ \\| '__| | | |
| |___| (_) \\ V V / | | | | __/ | | | | | (_) | | | |_| |
\\_____/\\___/ \\_/\\_/ \\_| |_/\\___|_| |_| |_|\\___/|_| \\__, |
__/ |
|___/

Your system is running on very little memory.
This means it may work but it wil most likely be slower than needed.

If you are running this via boot2docker you can simply increase
the available memory to at least ${MINIMAL_MEMORY}KiB
(you have ${INSTALLED_MEMORY}KiB )

End-of-message
fi
}

# -------------------------------------------------------

showWelcome
warnIfLowMemory
failIfUserIsRoot

# -------------------------------------------------------

. "/scripts/bashcolors.sh"
. "/usr/lib/git-core/git-sh-prompt"
export PS1='\['${IBlue}${On_Black}'\] \u@\['${IWhite}${On_Red}'\][Drill Build Env.]\['${IBlue}${On_Black}'\]:\['${Cyan}${On_Black}'\]\w$(declare -F __git_ps1 &>/dev/null && __git_ps1 " \['${BIPurple}'\]{\['${BIGreen}'\]%s\['${BIPurple}'\]}")\['${BIBlue}'\] ]\['${Color_Off}'\]\n$ '
20 changes: 20 additions & 0 deletions dev-support/docker/time.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env 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.
#

time "$@"
Loading