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

Fix building Docker image error #390

Merged
merged 1 commit into from
Dec 5, 2018
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
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ if [[ -z ${JAVA_HOME} ]]; then
export JAVA_HOME=${DORIS_THIRDPARTY}/installed/jdk1.8.0_131
fi

# check java version
if [[ ! -z ${JAVA_HOME} ]]; then
export JAVA=${JAVA_HOME}/bin/java
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
if [[ $JAVA_VER -lt 18 ]]; then
echo "Error: require JAVA with JDK version at least 1.8"
return 1
fi
fi

# check maven
export MVN=mvn
if ! ${MVN} --version; then
echo "Error: mvn is not found"
exit 1
fi

PARALLEL=$[$(nproc)/4+1]

# Check args
Expand Down
35 changes: 22 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ MAINTAINER tangxiaoqing214445
ENV DEFAULT_DIR /var/local

# change .bashrc
RUN echo -e "if [ ! -d "/var/local/incubator-doris/thirdparty/installed" ]; then\n\tmkdir /var/local/incubator-doris/thirdparty/installed\n\tcp -rf /var/local/thirdparty/installed/* /var/local/incubator-doris/thirdparty/installed/\nfi" >> /root/.bashrc
RUN echo -e "if [ ! -d "/var/local/incubator-doris/thirdparty/installed" ]; then\n\tmkdir /var/local/incubator-doris/thirdparty/installed\n\tcp -rf /var/local/thirdparty/installed/* /var/local/incubator-doris/thirdparty/installed/\n\texport JAVA_HOME=/var/local/incubator-doris/thirdparty/installed/jdk1.8.0_131\n\tln -s /var/local/incubator-doris/thirdparty/installed/bin/thrift /usr/bin/thrift\n\tln -s /var/local/incubator-doris/thirdparty/installed/jdk1.8.0_131/bin/java /usr/bin/java \nfi" >> /root/.bashrc

ARG GCC_VERSION=7.3.0
ARG GCC_URL=https://mirrors.ustc.edu.cn/gnu/gcc/gcc-${GCC_VERSION}

# install dependencies and build gcc
RUN yum install -y bzip2 wget gcc-c++ libstdc++-static cmake byacc flex automake libtool binutils-devel bison ncurses-devel make mlocate unzip patch which vim-common redhat-lsb-core zip \
RUN yum install -y bzip2 wget gcc-c++ libstdc++-static byacc flex automake libtool binutils-devel bison ncurses-devel make mlocate unzip patch which vim-common redhat-lsb-core zip \
&& updatedb \
&& mkdir -p /var/local/gcc \
&& curl -fsSL -o /tmp/gcc.tar.gz ${GCC_URL}/gcc-${GCC_VERSION}.tar.gz \
Expand All @@ -37,9 +37,21 @@ RUN yum install -y bzip2 wget gcc-c++ libstdc++-static cmake byacc flex automake
&& sed -i 's/ftp:\/\/gcc.gnu.org\/pub\/gcc\/infrastructure\//http:\/\/mirror.linux-ia64.org\/gnu\/gcc\/infrastructure\//g' contrib/download_prerequisites \
&& ./contrib/download_prerequisites \
&& ./configure --disable-multilib --enable-languages=c,c++ --prefix=/usr \
&& make -j 4 && make install \
&& make -j$[$(nproc)/4+1] && make install \
&& rm -rf /var/local/gcc \
&& rm -f /tmp/gcc.tar.gz

# build cmake
ARG CMAKE_VERSION=3.12.3
ARG CMAKE_DOWNLOAD_URL=https://cmake.org/files/v3.12/cmake-${CMAKE_VERSION}.tar.gz
RUN mkdir -p /tmp/cmake && curl -fsSL -o /tmp/cmake.tar.gz ${CMAKE_DOWNLOAD_URL} \
&& tar -zxf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 \
&& cd /tmp/cmake \
&& ./bootstrap --prefix=/usr/local \
&& make -j$[$(nproc)/4+1] \
&& make install \
&& rm -rf /tmp/cmake.tar.gz \
&& rm -rf /tmp/cmake

# install maven 3.6.0
ARG MAVEN_VERSION=3.6.0
Expand All @@ -64,19 +76,16 @@ ARG DORIS_THRIDPARTY_URL=http://doris-opensource.bj.bcebos.com/doris-thirdparty-
# clone source code and build third party
RUN yum install -y git \
&& git clone https://github.com/apache/incubator-doris.git \
&& mkdir -p ${DEFAULT_DIR}/thirdparty/src ${DEFAULT_DIR}/doris-thirdparty \
&& cp -rf ${DEFAULT_DIR}/incubator-doris/thirdparty/* ${DEFAULT_DIR}/thirdparty/ \
&& mkdir -p ${DEFAULT_DIR}/incubator-doris/thirdparty/src ${DEFAULT_DIR}/doris-thirdparty \
&& curl -fsSL -o ${DEFAULT_DIR}/doris-thirdparty.tar.gz ${DORIS_THRIDPARTY_URL} \
&& tar -zxf ${DEFAULT_DIR}/doris-thirdparty.tar.gz -C ${DEFAULT_DIR}/doris-thirdparty --strip-components=1 \
&& mv ${DEFAULT_DIR}/doris-thirdparty/* ${DEFAULT_DIR}/thirdparty/src/ \
&& /bin/bash thirdparty/build-thirdparty.sh \
&& ln -s ${DEFAULT_DIR}/thirdparty/installed/bin/thrift /usr/bin/thrift \
&& ln -s ${DEFAULT_DIR}/thirdparty/installed/jdk1.8.0_131/bin/java /usr/bin/java \
&& rm -rf ${DEFAULT_DIR}/thirdparty/src \
&& mv ${DEFAULT_DIR}/doris-thirdparty/* ${DEFAULT_DIR}/incubator-doris/thirdparty/src/ \
&& cd ${DEFAULT_DIR}/incubator-doris && /bin/bash thirdparty/build-thirdparty.sh \
&& rm -rf ${DEFAULT_DIR}/incubator-doris/thirdparty/src \
&& rm -rf ${DEFAULT_DIR}/doris-thirdparty.tar.gz \
&& rm -rf ${DEFAULT_DIR}/doris-thirdparty

ENV JAVA_HOME ${DEFAULT_DIR}/thirdparty/installed/jdk1.8.0_131
&& rm -rf ${DEFAULT_DIR}/doris-thirdparty \
&& mkdir -p ${DEFAULT_DIR}/thirdparty \
&& mv ${DEFAULT_DIR}/incubator-doris/thirdparty/installed ${DEFAULT_DIR}/thirdparty/

WORKDIR ${DEFAULT_DIR}/incubator-doris

17 changes: 0 additions & 17 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@ if [[ -z ${DORIS_THIRDPARTY} ]]; then
export DORIS_THIRDPARTY=${DORIS_HOME}/thirdparty
fi

# check java version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check Java and maven version here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen the build script, the check java also in build.sh. Why you build jdk after check java in the build-thirdparty.sh? And I have test the build after I delete this. You can test it in your environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAVA_HOME can be set by user in his environment, and not everyone use thirdparty's JDK as his JAVA_HOME.
So, we need to check java's version to make sure it can work with our project.

if [[ ! -z ${JAVA_HOME} ]]; then
export JAVA=${JAVA_HOME}/bin/java
JAVA_VER=$(${JAVA} -version 2>&1 | sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q' | cut -f1 -d " ")
if [[ $JAVA_VER -lt 18 ]]; then
echo "Error: require JAVA with JDK version at least 1.8"
return 1
fi
fi

# check maven
export MVN=mvn
if ! ${MVN} --version; then
echo "Error: mvn is not found"
exit 1
fi

# check python
export PYTHON=python
if ! ${PYTHON} --version; then
Expand Down