From 202b957d587ffdb502bdd91ee92878c248bf45ec Mon Sep 17 00:00:00 2001 From: Liu Jiaming Date: Sun, 7 Jun 2020 22:10:41 -0700 Subject: [PATCH] Docker: build poco from source to reduce image size --- docker/build/installers/install_cyber_deps.sh | 26 +++++------- docker/build/installers/install_poco.sh | 42 ++++++++++++++++--- external/poco.BUILD | 5 ++- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/docker/build/installers/install_cyber_deps.sh b/docker/build/installers/install_cyber_deps.sh index 6527f5f34b..aca01d49a0 100755 --- a/docker/build/installers/install_cyber_deps.sh +++ b/docker/build/installers/install_cyber_deps.sh @@ -21,32 +21,28 @@ set -e cd "$(dirname "${BASH_SOURCE[0]}")" +. /tmp/installers/installer_base.sh + +info "Install poco ..." +bash /tmp/installers/install_poco.sh + apt-get -y update && \ apt-get -y install \ - libpocofoundation50 \ - libpoco-dev \ ncurses-dev \ libuuid1 \ - uuid-dev \ - libboost-all-dev \ - libxml2-dev + uuid-dev -python3 -m pip install --no-cache-dir grpcio-tools +info "Install gflags & glog..." +bash /tmp/installers/install_gflags_glog.sh -. /tmp/installers/installer_base.sh +pip3_install grpcio-tools -info "Install Protobuf ..." +info "Install protobuf ..." bash /tmp/installers/install_protobuf.sh -info "Install GFlags & GLog..." -bash /tmp/installers/install_gflags_glog.sh - -info "Install Fast-RTPS ..." +info "Install fast-rtps ..." bash /tmp/installers/install_fast-rtps.sh -info "Install Poco ..." -bash /tmp/installers/install_poco.sh - # Clean up cache to reduce layer size. apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_poco.sh b/docker/build/installers/install_poco.sh index 4f3915116b..cb8dcc4197 100755 --- a/docker/build/installers/install_poco.sh +++ b/docker/build/installers/install_poco.sh @@ -21,12 +21,12 @@ set -e cd "$(dirname "${BASH_SOURCE[0]}")" -apt-get -y update && \ - apt-get -y install \ - libssl-dev \ - libpoco-dev +# To reduce image size +# apt-get -y update && \ +# apt-get -y install \ +# libssl-dev +# libpoco-dev -exit 0 . /tmp/installers/installer_base.sh @@ -44,10 +44,40 @@ tar xzf poco-${VERSION}-release.tar.gz pushd poco-poco-${VERSION}-release mkdir cmakebuild && cd cmakebuild - cmake .. -DBUILD_SHARED_LIBS=ON + # Keep only PocoFoundation + cmake .. \ + -DENABLE_NETSSL=OFF \ + -DENABLE_CRYPTO=OFF \ + -DENABLE_JWT=OFF \ + -DENABLE_APACHECONNECTOR=OFF \ + -DENABLE_DATA_MYSQL=OFF \ + -DENABLE_DATA_POSTGRESQL=OFF \ + -DENABLE_DATA_ODBC=OFF \ + -DENABLE_MONGODB=OFF \ + -DENABLE_REDIS=OFF \ + -DENABLE_DATA_SQLITE=OFF \ + -DENABLE_DATA=OFF \ + -DENABLE_PAGECOMPILER=OFF \ + -DENABLE_PAGECOMPILER_FILE2PAGE=OFF \ + -DENABLE_ZIP=OFF \ + -DENABLE_NET=OFF \ + -DENABLE_JSON=OFF \ + -DENABLE_XML=OFF \ + -DENABLE_PDF=OFF \ + -DENABLE_POCODOC=OFF \ + -DENABLE_ENCODINGS=OFF \ + -DENABLE_UTIL=OFF \ + -DENABLE_CPPPARSER=OFF \ + -DENABLE_TESTS=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_INSTALL_PREFIX="${SYSROOT_DIR}" \ + -DCMAKE_BUILD_TYPE=Release + make -j${THREAD_NUM} make install popd +ldconfig + # clean up rm -rf poco-${VERSION}-release.tar.gz poco-poco-${VERSION}-release diff --git a/external/poco.BUILD b/external/poco.BUILD index e23f72d99e..483a8fb7a2 100644 --- a/external/poco.BUILD +++ b/external/poco.BUILD @@ -7,5 +7,8 @@ licenses(["notice"]) cc_library( name = "PocoFoundation", includes = ["."], - linkopts = ["-lPocoFoundation"], + linkopts = [ + "-L/opt/apollo/sysroot/lib", + "-lPocoFoundation", + ], ) -- GitLab