Skip to content

Commit

Permalink
Fix docker develop dockerfile (hyperledger-iroha#1064)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Vaneev <[email protected]>
  • Loading branch information
Warchant authored and x3medima17 committed Mar 30, 2018
1 parent b1a12ac commit 98fc6ba
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 70 deletions.
29 changes: 11 additions & 18 deletions cmake/Modules/Findgrpc.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
add_library(grpc UNKNOWN IMPORTED)
add_library(grpc++ UNKNOWN IMPORTED)
add_library(grpc++_reflection UNKNOWN IMPORTED)
add_library(gpr UNKNOWN IMPORTED)
add_executable(grpc_cpp_plugin IMPORTED)

Expand All @@ -13,9 +12,6 @@ mark_as_advanced(grpc_LIBRARY)
find_library(grpc_grpc++_LIBRARY grpc++)
mark_as_advanced(grpc_grpc++_LIBRARY)

find_library(grpc_grpc++_reflection_LIBRARY grpc++_reflection)
mark_as_advanced(grpc_grpc++_reflection_LIBRARY)

find_library(gpr_LIBRARY gpr)
mark_as_advanced(gpr_LIBRARY)

Expand All @@ -26,7 +22,6 @@ find_package_handle_standard_args(grpc DEFAULT_MSG
grpc_LIBRARY
grpc_INCLUDE_DIR
gpr_LIBRARY
grpc_grpc++_reflection_LIBRARY
grpc_CPP_PLUGIN
)

Expand All @@ -39,12 +34,18 @@ if (NOT grpc_FOUND)
externalproject_add(grpc_grpc
GIT_REPOSITORY ${URL}
GIT_TAG ${VERSION}
CMAKE_ARGS -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG -DProtobuf_DIR=${EP_PREFIX}/src/google_protobuf-build/lib/cmake/protobuf -DgRPC_ZLIB_PROVIDER=package -DBUILD_SHARED_LIBS=ON
CMAKE_ARGS
-DgRPC_PROTOBUF_PROVIDER=package
-DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG
-DProtobuf_DIR=${EP_PREFIX}/src/google_protobuf-build/lib/cmake/protobuf
-DgRPC_ZLIB_PROVIDER=package
-DBUILD_SHARED_LIBS=ON
PATCH_COMMAND ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR}/patch/fix-protobuf-package-include.patch || true
BUILD_BYPRODUCTS ${EP_PREFIX}/src/grpc_grpc-build/grpc_cpp_plugin
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}grpc${CMAKE_SHARED_LIBRARY_SUFFIX}
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}grpc++${CMAKE_SHARED_LIBRARY_SUFFIX}
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}grpc++_reflection${CMAKE_SHARED_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS
${EP_PREFIX}/src/grpc_grpc-build/grpc_cpp_plugin
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}gpr${CMAKE_SHARED_LIBRARY_SUFFIX}
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}grpc${CMAKE_SHARED_LIBRARY_SUFFIX}
${EP_PREFIX}/src/grpc_grpc-build/${CMAKE_SHARED_LIBRARY_PREFIX}grpc++${CMAKE_SHARED_LIBRARY_SUFFIX}
INSTALL_COMMAND "" # remove install step
TEST_COMMAND "" # remove test step
UPDATE_COMMAND "" # remove update step
Expand All @@ -53,15 +54,13 @@ if (NOT grpc_FOUND)
set(grpc_INCLUDE_DIR ${source_dir}/include)
set(grpc_LIBRARY ${binary_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}grpc${CMAKE_SHARED_LIBRARY_SUFFIX})
set(grpc_grpc++_LIBRARY ${binary_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}grpc++${CMAKE_SHARED_LIBRARY_SUFFIX})
set(grpc_grpc++_reflection_LIBRARY ${binary_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}grpc++_reflection${CMAKE_SHARED_LIBRARY_SUFFIX})
set(grpc_CPP_PLUGIN ${binary_dir}/grpc_cpp_plugin)
file(MAKE_DIRECTORY ${grpc_INCLUDE_DIR})
link_directories(${binary_dir})

add_dependencies(grpc_grpc protobuf)
add_dependencies(grpc grpc_grpc)
add_dependencies(grpc++ grpc_grpc)
add_dependencies(grpc++_reflection grpc_grpc)
add_dependencies(grpc_cpp_plugin grpc_grpc protoc)
endif ()

Expand All @@ -77,12 +76,6 @@ set_target_properties(grpc++ PROPERTIES
IMPORTED_LOCATION ${grpc_grpc++_LIBRARY}
)

set_target_properties(grpc++_reflection PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${grpc_INCLUDE_DIR}
INTERFACE_LINK_LIBRARIES grpc++
IMPORTED_LOCATION ${grpc_grpc++_reflection_LIBRARY}
)

set_target_properties(grpc_cpp_plugin PROPERTIES
IMPORTED_LOCATION ${grpc_CPP_PLUGIN}
)
Expand Down
128 changes: 77 additions & 51 deletions docker/develop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM ubuntu:16.04
# number of concurrent threads during build
# usage: docker build --build-arg PARALLELISM=8 -t name/name .
ARG PARALLELISM=1
ARG CMAKE_BUILD_TYPE=Release

ENV IROHA_HOME /opt/iroha
ENV IROHA_BUILD /opt/iroha/build
Expand All @@ -12,26 +13,25 @@ RUN apt-get update; \
apt-get -y --no-install-recommends install apt-utils software-properties-common; \
apt-get -y clean


# add git repository
RUN add-apt-repository -y ppa:git-core/ppa; \
apt-get update


RUN apt-get -y --no-install-recommends install build-essential python-software-properties \
automake libtool \
# dev dependencies
libssl-dev zlib1g-dev libc6-dbg golang \
# CircleCI dependencies
git ssh tar gzip ca-certificates python3 python3-pip python3-setuptools \
git ssh tar gzip ca-certificates python python-pip python-setuptools \
# code coverage
lcov \
# other
wget curl file unzip gdb iputils-ping vim ccache \
gcovr cppcheck doxygen graphviz graphviz-dev; \
apt-get -y clean

RUN pip3 install --upgrade pip; \
pip3 install flask requests

# install cmake 3.5.1
RUN git clone https://gitlab.kitware.com/cmake/cmake.git /tmp/cmake; \
(cd /tmp/cmake ; git checkout 64130a7e793483e24c1d68bdd234f81d5edb2d51); \
Expand All @@ -43,8 +43,7 @@ RUN git clone https://gitlab.kitware.com/cmake/cmake.git /tmp/cmake; \
# install boost 1.65.1
RUN git clone https://github.com/boostorg/boost /tmp/boost; \
(cd /tmp/boost ; git checkout 436ad1dfcfc7e0246141beddd11c8a4e9c10b146); \
(cd /tmp/boost ; git submodule init); \
(cd /tmp/boost ; git submodule update --recursive -j ${PARALLELISM}); \
(cd /tmp/boost ; git submodule update --init --recursive); \
(cd /tmp/boost ; /tmp/boost/bootstrap.sh --with-libraries=system,filesystem); \
(cd /tmp/boost ; /tmp/boost/b2 headers); \
(cd /tmp/boost ; /tmp/boost/b2 cxxflags="-std=c++14" -j ${PARALLELISM} install); \
Expand All @@ -53,61 +52,92 @@ RUN git clone https://github.com/boostorg/boost /tmp/boost; \
# install protobuf
RUN git clone https://github.com/google/protobuf /tmp/protobuf; \
(cd /tmp/protobuf ; git checkout 80a37e0782d2d702d52234b62dd4b9ec74fd2c95); \
cmake -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -H/tmp/protobuf/cmake -B/tmp/protobuf/.build; \
cmake --build /tmp/protobuf/.build --target install -- -j${PARALLELISM}; \
ldconfig; \
rm -rf /tmp/protobuf
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_BUILD_SHARED_LIBS=ON \
-H/tmp/protobuf/cmake \
-B/tmp/protobuf/.build; \
cmake --build /tmp/protobuf/.build --target install -- -j${PARALLELISM}

# install gflags
RUN git clone https://github.com/gflags/gflags /tmp/gflags; \
(cd /tmp/gflags ; git checkout f8a0efe03aa69b3336d8e228b37d4ccb17324b88); \
cmake -H/tmp/gflags -B/tmp/gflags/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-H/tmp/gflags \
-B/tmp/gflags/build; \
cmake --build /tmp/gflags/build --target install -- -j${PARALLELISM}; \
rm -rf /tmp/gflags

# install c-ares
RUN git clone https://github.com/c-ares/c-ares /tmp/c-ares; \
(cd /tmp/c-ares ; git checkout 3be1924221e1326df520f8498d704a5c4c8d0cce); \
cmake -H/tmp/c-ares -B/tmp/c-ares/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-H/tmp/c-ares \
-B/tmp/c-ares/build; \
cmake --build /tmp/c-ares/build --target install -- -j${PARALLELISM}; \
ldconfig; \
rm -rf /tmp/c-ares

# install grpc
RUN git clone https://github.com/grpc/grpc /tmp/grpc; \
(cd /tmp/grpc ; git checkout bfcbad3b86c7912968dc8e64f2121c920dad4dfb); \
(cd /tmp/grpc ; git submodule update --init third_party/benchmark); \
cmake -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package -DgRPC_GFLAGS_PROVIDER=package -DBUILD_SHARED_LIBS=ON -H/tmp/grpc -B/tmp/grpc/.build; \
cmake --build /tmp/grpc/.build --target install -- -j${PARALLELISM}; \
ldconfig; \
cd /tmp/grpc; \
git checkout bfcbad3b86c7912968dc8e64f2121c920dad4dfb; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DgRPC_BENCHMARK_PROVIDER="" \
-DgRPC_ZLIB_PROVIDER=package \
-DgRPC_CARES_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package \
-DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_GFLAGS_PROVIDER=package \
-DBUILD_SHARED_LIBS=ON \
-H/tmp/grpc \
-B/tmp/grpc/.build; \
cd /tmp/grpc/.build; \
make -j${PARALLELISM} gpr grpc grpc++ grpc_cpp_plugin; \
cp lib{gpr,grpc,grpc++,grpc_plugin_support}.so /usr/local/lib; \
cp grpc_cpp_plugin /usr/local/bin; \
rm -rf /tmp/grpc

# install gtest
RUN git clone https://github.com/google/googletest /tmp/googletest; \
(cd /tmp/googletest ; git checkout ec44c6c1675c25b9827aacd08c02433cccde7780); \
cmake -H/tmp/googletest -B/tmp/googletest/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-H/tmp/googletest \
-B/tmp/googletest/build; \
cmake --build /tmp/googletest/build --target install -- -j${PARALLELISM}; \
rm -rf /tmp/googletest

# install spdlog v0.16.3
RUN git clone https://github.com/gabime/spdlog /tmp/spdlog; \
(cd /tmp/spdlog ; git checkout ccd675a286f457068ee8c823f8207f13c2325b26); \
cmake -DSPDLOG_BUILD_TESTING=OFF -H/tmp/spdlog -B/tmp/spdlog/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DSPDLOG_BUILD_TESTING=OFF -H/tmp/spdlog -B/tmp/spdlog/build; \
cmake --build /tmp/spdlog/build --target install; \
rm -rf /tmp/spdlog

# install rxcpp
RUN git clone https://github.com/Reactive-Extensions/RxCpp /tmp/RxCpp; \
(cd /tmp/RxCpp ; git checkout 1b2e0589f19cb34d8cd58803677701dcf2161876); \
cmake -H/tmp/RxCpp -B/tmp/RxCpp/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-H/tmp/RxCpp \
-B/tmp/RxCpp/build; \
cmake --build /tmp/RxCpp/build --target install; \
rm -rf /tmp/RxCpp

# install rapidjson
RUN git clone https://github.com/miloyip/rapidjson /tmp/rapidjson; \
(cd /tmp/rapidjson ; git checkout f54b0e47a08782a6131cc3d60f94d038fa6e0a51); \
cmake -DRAPIDJSON_BUILD_EXAMPLES=OFF -H/tmp/rapidjson -B/tmp/rapidjson/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DRAPIDJSON_BUILD_EXAMPLES=OFF \
-H/tmp/rapidjson \
-B/tmp/rapidjson/build; \
cmake --build /tmp/rapidjson/build --target install; \
rm -rf /tmp/rapidjson

Expand All @@ -118,14 +148,20 @@ RUN git clone https://github.com/martinmoene/optional-lite /tmp/optional-lite; \
rm -rf /tmp/optional-lite

# install libpq
RUN git clone https://git.postgresql.org/git/postgresql.git /tmp/postgresql; \
(cd /tmp/postgresql ; git checkout 029386ccbddd0a33d481b94e511f5219b03e6636); \
(cd /tmp/postgresql ; /tmp/postgresql/configure --without-readline --prefix=/usr/local); \
make -j${PARALLELISM} -C /tmp/postgresql/src/bin/pg_config; \
make -j${PARALLELISM} -C /tmp/postgresql/src/interfaces/libpq; \
make -C /tmp/postgresql/src/bin/pg_config install; \
make -C /tmp/postgresql/src/interfaces/libpq install; \
make -C /tmp/postgresql/src/include install; \
RUN git clone --progress https://git.postgresql.org/git/postgresql.git /tmp/postgresql; \
cd /tmp/postgresql; \
git checkout 029386ccbddd0a33d481b94e511f5219b03e6636; \
./configure --without-readline --prefix=/usr/local; \
# build
make -j${PARALLELISM} -C src/bin/pg_config; \
make -j${PARALLELISM} -C src/interfaces/libpq; \
make -j${PARALLELISM} -C src/backend/utils fmgroids.h; \
cp src/backend/utils/fmgroids.h src/include/utils/fmgroids.h; \
# install
make -C src/bin/pg_config install; \
make -C src/interfaces/libpq install; \
make -C src/include install; \
# remove
rm -rf /tmp/postgresql

# install pqxx
Expand All @@ -143,7 +179,6 @@ RUN git clone https://github.com/01org/tbb /tmp/tbb; \
cp /tmp/tbb/build/build_debug/*.so* /usr/local/lib; \
cp /tmp/tbb/build/build_release/*.so* /usr/local/lib; \
cp -r /tmp/tbb/include/* /usr/local/include; \
ldconfig; \
rm -rf /tmp/tbb

# install docker
Expand All @@ -163,27 +198,15 @@ RUN mkdir -p /opt/sonar; \
ln -s -f /opt/sonar/scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner; \
rm -rf /tmp/sonar*

# install sonar build wrapper
RUN curl -L -o /tmp/sonar-build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip; \
unzip -o -d /tmp/sonar-build-wrapper /tmp/sonar-build-wrapper.zip; \
mv /tmp/sonar-build-wrapper/build-wrapper-linux-x86 /opt/sonar/build-wrapper; \
ln -s -f /opt/sonar/build-wrapper/build-wrapper-linux-x86-64 /usr/local/bin/sonar-build-wrapper; \
rm -rf /tmp/sonar*

# install latest valgrind
RUN git clone git://sourceware.org/git/valgrind.git /tmp/valgrind; \
(cd /tmp/valgrind ; /tmp/valgrind/autogen.sh); \
(cd /tmp/valgrind ; /tmp/valgrind/configure); \
make -j${PARALLELISM} -C /tmp/valgrind; \
make -C /tmp/valgrind install; \
rm -rf /tmp/valgrind

# install ed25519
RUN git clone git://github.com/hyperledger/iroha-ed25519.git /tmp/ed25519; \
(cd /tmp/ed25519 ; git checkout e7188b8393dbe5ac54378610d53630bd4a180038); \
cmake -DCMAKE_BUILD_TYPE=Debug -DTESTING=OFF -H/tmp/ed25519 -B/tmp/ed25519/build; \
cmake \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DTESTING=OFF \
-H/tmp/ed25519 \
-B/tmp/ed25519/build; \
cmake --build /tmp/ed25519/build --target install -- -j${PARALLELISM}; \
ldconfig; \
rm -rf /tmp/ed25519

# non-interactive adduser
Expand All @@ -197,7 +220,10 @@ RUN useradd -ms /bin/bash iroha-ci -u 1000 -U

WORKDIR /opt/iroha
RUN chmod -R 777 /opt/iroha; \
mkdir -p /tmp/ccache -m 777;
mkdir -p /tmp/ccache -m 777; \
ldconfig; \
ccache --clear


USER iroha-ci
CMD ["/bin/bash"]
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ parts:
make -C src/bin/pg_config
make -C src/interfaces/libpq
make -C src/backend/utils fmgroids.h
ln -s $(pwd)/src/backend/utils/fmgroids.h src/include/utils/fmgroids.h
cp $(pwd)/src/backend/utils/fmgroids.h src/include/utils/fmgroids.h
install: |
make -C src/bin/pg_config install DESTDIR=$SNAPCRAFT_PART_INSTALL
make -C src/interfaces/libpq install DESTDIR=$SNAPCRAFT_PART_INSTALL
Expand Down

0 comments on commit 98fc6ba

Please sign in to comment.