From 54837b865b5413ce1ef85eb661ab8f923f4ec39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B3zes=20L=C3=A1szl=C3=B3=20M=C3=A1t=C3=A9?= <127779457+mozesl@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:23:45 +0100 Subject: [PATCH] Update docker images to Ubuntu 22.04 (#644) --- CMakeLists.txt | 2 +- FindOdb.cmake => FindODB.cmake | 0 docker/README.md | 1 + docker/dev/Dockerfile | 40 ++++++++++------- docker/dev/install_odb.sh | 43 ++++++++++++++++++ docker/runtime/Dockerfile | 45 ++++++++++--------- docker/web/Dockerfile | 25 +++++++---- plugins/git/CMakeLists.txt | 2 +- .../git/{FindGit2.cmake => FindLibGit2.cmake} | 2 +- 9 files changed, 111 insertions(+), 49 deletions(-) rename FindOdb.cmake => FindODB.cmake (100%) create mode 100644 docker/dev/install_odb.sh rename plugins/git/{FindGit2.cmake => FindLibGit2.cmake} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 921914e3a..72f8bda3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include(Testing.cmake) find_package(Boost REQUIRED COMPONENTS filesystem log program_options regex system thread) find_package(Java REQUIRED) -find_package(Odb REQUIRED) +find_package(ODB REQUIRED) find_package(Threads REQUIRED) find_package(Thrift REQUIRED) find_package(GTest) diff --git a/FindOdb.cmake b/FindODB.cmake similarity index 100% rename from FindOdb.cmake rename to FindODB.cmake diff --git a/docker/README.md b/docker/README.md index a3c8e566b..f830c4b08 100644 --- a/docker/README.md +++ b/docker/README.md @@ -128,6 +128,7 @@ variables: | Variable | Meaning | | -------------------- | ---------------------------------------- | +| `CC_REPO_URL` | The URL of the CodeCompass repository to use. | | `CC_VERSION` | The branch, version hash or tag of the CodeCompass repository to use. | | `CC_DATABASE`| Database type. Possible values are **sqlite**, **pgsql**. | | `CC_BUILD_TYPE` | Specifies the build type. Supported values are **`Debug`** and **`Release`**. | diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 8db4369a4..20a236ece 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 # tzdata package is installed implicitly in the following command. This package # sets timezone interactively during the installation process. This environment @@ -10,12 +10,11 @@ RUN set -x && apt-get update -qq \ && apt-get -y install --no-install-recommends \ cmake make \ default-jdk \ - ctags \ - ca-certificates \ - curl \ - gnupg \ + universal-ctags \ + curl ca-certificates gnupg \ + wget \ doxygen \ - gcc-9 gcc-9-plugin-dev g++-9 \ + gcc-11 gcc-11-plugin-dev g++-11 \ libboost-filesystem-dev \ libboost-log-dev \ libboost-program-options-dev \ @@ -28,11 +27,16 @@ RUN set -x && apt-get update -qq \ libsqlite3-dev \ libssl-dev \ llvm-11 clang-11 llvm-11-dev libclang-11-dev \ - npm \ thrift-compiler libthrift-dev \ - odb libodb-sqlite-dev libodb-pgsql-dev && \ - ln -s /usr/bin/gcc-9 /usr/bin/gcc && \ - ln -s /usr/bin/g++-9 /usr/bin/g++ + postgresql-server-dev-14 && \ + ln -s /usr/bin/gcc-11 /usr/bin/gcc && \ + ln -s /usr/bin/g++-11 /usr/bin/g++ + +# Copy install script +COPY docker/dev/install_odb.sh / + +# Build ODB from source +RUN sh /install_odb.sh && rm /install_odb.sh # Install NodeJS from NodeSource. RUN mkdir -p /etc/apt/keyrings && \ @@ -45,12 +49,12 @@ RUN mkdir -p /etc/apt/keyrings && \ # Build GTest. RUN cd /usr/src/googletest && \ - mkdir build && \ - cd build && \ - cmake .. && \ - make install && \ - cd / && \ - rm -rf /usr/src/googletest/build + mkdir build && \ + cd build && \ + cmake .. && \ + make install && \ + cd / && \ + rm -rf /usr/src/googletest/build # Adding CodeCompass builder script. COPY docker/dev/codecompass-build.sh /usr/local/bin @@ -64,6 +68,8 @@ ENV DATABASE=sqlite \ SOURCE_DIR=/CodeCompass/CodeCompass \ TEST_WORKSPACE=/CodeCompass/test_workspace \ TEST_DB="sqlite:database=$TEST_WORKSPACE/cc_test.sqlite" \ - WITH_AUTH="plain;ldap" + WITH_AUTH="plain;ldap" \ + LLVM_DIR=/usr/lib/llvm-11/cmake \ + Clang_DIR=/usr/lib/cmake/clang-11 ENV PATH="$INSTALL_DIR/bin:$PATH" diff --git a/docker/dev/install_odb.sh b/docker/dev/install_odb.sh new file mode 100644 index 000000000..1ebe893fd --- /dev/null +++ b/docker/dev/install_odb.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +opt=${1:-"all"} + +wget https://raw.githubusercontent.com/Ericsson/CodeCompass/master/scripts/install_latest_build2.sh +sh install_latest_build2.sh "/build2_install" +export PATH=/build2_install/bin:$PATH +# Configuring the build +mkdir /odb_build +cd /odb_build +bpkg create --quiet --jobs $(nproc) cc \ + config.cxx=g++ \ + config.cc.coptions=-O3 \ + config.bin.rpath=/usr/local/lib \ + config.install.root=/usr/local +# Getting the source +bpkg add https://pkg.cppget.org/1/beta --trust-yes +bpkg fetch --trust-yes +# Building ODB +BUILD_LIST="libodb" +case $opt in + "sqlite") + BUILD_LIST="$BUILD_LIST libodb-sqlite" + ;; + "pgsql") + BUILD_LIST="$BUILD_LIST libodb-pgsql" + ;; + *) + BUILD_LIST="$BUILD_LIST odb libodb-sqlite libodb-pgsql" + ;; +esac +for pack in "$BUILD_LIST"; do + bpkg build $pack --yes +done +# Install ODB (to /usr/local) +INSTALL_LIST="$BUILD_LIST libstudxml libcutl" +for pack in "$INSTALL_LIST"; do + bpkg install $pack +done +# Clean up +cd / +sh install_latest_build2.sh --uninstall +rm -rf /odb_build install_latest_build2.sh build2-toolchain-*.tar.gz \ No newline at end of file diff --git a/docker/runtime/Dockerfile b/docker/runtime/Dockerfile index 9622a434c..620fee50f 100644 --- a/docker/runtime/Dockerfile +++ b/docker/runtime/Dockerfile @@ -6,6 +6,9 @@ ARG CC_DATABASE=sqlite FROM codecompass:dev as builder +ARG CC_REPO_URL="https://github.com/Ericsson/CodeCompass.git" +ENV CC_REPO_URL ${CC_REPO_URL} + ARG CC_VERSION=master ENV CC_VERSION ${CC_VERSION} @@ -19,7 +22,7 @@ RUN apt-get update -qq && \ apt-get install --yes git # Download CodeCompass release. -RUN git clone https://github.com/Ericsson/CodeCompass.git /CodeCompass +RUN git clone ${CC_REPO_URL} /CodeCompass WORKDIR /CodeCompass RUN git checkout ${CC_VERSION} @@ -38,7 +41,7 @@ RUN mkdir /CodeCompass-build && \ #-------------------------- PRODUCTION STAGE ----------------------------# ############################################################################### -FROM ubuntu:20.04 +FROM ubuntu:22.04 # tzdata package is installed implicitly in the following command. This package # sets timezone interactively during the installation process. This environment @@ -48,41 +51,43 @@ ARG DEBIAN_FRONTEND=noninteractive ARG CC_DATABASE ENV CC_DATABASE ${CC_DATABASE} -RUN if [ "pgsql" = "${CC_DATABASE}" ]; then \ - apt-get update -qq --yes && \ - apt-get install -qq --yes --no-install-recommends \ - postgresql-server-dev-12 \ - libodb-pgsql-dev; \ - else \ - apt-get update -qq && \ - apt-get install -qq --yes --no-install-recommends \ - libsqlite3-dev \ - libodb-sqlite-dev; \ - fi; - +# Copy install script +COPY docker/dev/install_odb.sh / + RUN set -x && apt-get update -qq && \ apt-get install -qq --yes --no-install-recommends \ + curl ca-certificates gnupg \ + wget \ llvm-11 \ libboost-filesystem-dev libboost-log-dev libboost-program-options-dev \ default-jre \ libgit2-dev \ - libssl1.1 \ + libssl3 \ libgvc6 \ - libldap-2.4-2 \ + libldap-2.5-0 \ libmagic-dev \ libthrift-dev \ - ctags \ + universal-ctags \ + gcc-11 g++-11 \ tini && \ + ln -s /usr/bin/gcc-11 /usr/bin/gcc && \ + ln -s /usr/bin/g++-11 /usr/bin/g++ && \ + if [ "pgsql" = "${CC_DATABASE}" ]; then \ + apt-get install -qq --yes --no-install-recommends \ + libpq5 \ + postgresql-server-dev-14; \ + else \ + apt-get install -qq --yes --no-install-recommends \ + libsqlite3-dev; \ + fi && \ + sh /install_odb.sh "${CC_DATABASE}" && \ apt-get clean && \ rm -rf /var/lib/apt/lists/ && \ set +x - # Copy CodeCompass installed directory. (Change permission of the CodeCompass package.) COPY --from=builder /CodeCompass-install /codecompass ENV PATH="/codecompass/bin:$PATH" - ENTRYPOINT ["tini", "--"] - diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile index 68daac16f..b94c4630f 100644 --- a/docker/web/Dockerfile +++ b/docker/web/Dockerfile @@ -8,37 +8,44 @@ FROM codecompass:runtime as runtime #------------------------ EXECUTABLE CONTAINER --------------------------# ############################################################################### -FROM ubuntu:20.04 +FROM ubuntu:22.04 # tzdata package is installed implicitly in the following command. This package # sets timezone interactively during the installation process. This environment # variable prevents this interaction. ARG DEBIAN_FRONTEND=noninteractive +# Copy install script +COPY docker/dev/install_odb.sh / + RUN set -x && apt-get update -qq \ && apt-get install -qqy --no-install-recommends \ llvm-11 \ libboost-filesystem-dev libboost-log-dev libboost-program-options-dev \ libsqlite3-dev \ - postgresql-server-dev-12 \ + postgresql-server-dev-14 \ default-jre \ libgit2-dev \ - libldap-2.4-2 \ - libssl1.1 \ + libldap-2.5-0 \ + libssl3 \ libgvc6 \ libthrift-dev \ - libodb-sqlite-dev \ - libodb-pgsql-dev \ + libpq5 \ # To switch user and exec command. gosu \ tini \ - ca-certificates \ - curl \ - gnupg \ + curl ca-certificates gnupg \ + wget \ + gcc-11 g++-11 \ + && ln -s /usr/bin/gcc-11 /usr/bin/gcc \ + && ln -s /usr/bin/g++-11 /usr/bin/g++ \ && apt-get clean \ && rm -rf /var/lib/apt/lists/ \ && set +x +# Build ODB from source +RUN sh /install_odb.sh && rm /install_odb.sh + # Install NodeJS from NodeSource. RUN mkdir -p /etc/apt/keyrings && \ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ diff --git a/plugins/git/CMakeLists.txt b/plugins/git/CMakeLists.txt index 798355345..a343bc2e5 100644 --- a/plugins/git/CMakeLists.txt +++ b/plugins/git/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Git2 REQUIRED) +find_package(LibGit2 REQUIRED) add_subdirectory(parser) add_subdirectory(service) diff --git a/plugins/git/FindGit2.cmake b/plugins/git/FindLibGit2.cmake similarity index 93% rename from plugins/git/FindGit2.cmake rename to plugins/git/FindLibGit2.cmake index a93945552..e1e878955 100644 --- a/plugins/git/FindGit2.cmake +++ b/plugins/git/FindLibGit2.cmake @@ -29,6 +29,6 @@ FIND_LIBRARY(LIBGIT2_LIBRARIES NAMES git2 INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(libgit2 DEFAULT_MSG LIBGIT2_LIBRARIES LIBGIT2_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibGit2 DEFAULT_MSG LIBGIT2_LIBRARIES LIBGIT2_INCLUDE_DIR) MARK_AS_ADVANCED(LIBGIT2_INCLUDE_DIR LIBGIT2_LIBRARIES) \ No newline at end of file